I’m building Project: Gimli, you might’ve heard of it before (yes, it’s the same one planning E2EE over AP and federated democracy. Making a discord alternative is complicated — it has tons of features, and a lot of missing ones too). It’s an exploratory project, where I’m implementing whatever interesting Fediverse concepts I come around. I’m documenting here, as I want to have a long-form text about it, and some people don’t want to use Google docs.
The intention here is to show how Mastodon is a legacy platform, limited by backwards compatibility to itself and lackluster database design, and more importantly, to show an example of how to do better. Plus, to create interesting discussions. Please ask questions!
Identifiers
Mastodon uses URIs to identify objects, and associates one immutable URI with one object (excluding actors, that it has hacked support of multiple predefined URIs for).
Gimli’s database uses three kinds of identifiers for every object:
- An internal UUIDv7. That one’s boring.
- A (nullable) federated UUIDv7. I don’t know how exactly I’m gonna use it yet, but it’ll be the main identifier for most objects. I have two concepts:
- Use
did:uuid:abc123?host=example.social
as an@id
. Most likely ain’t gonna use it as a primary URI (see below), as it’s gonna break compatibility with literally everything. - Have a
uuid
Json property or something. Might as well use a public/private key here, though.
- Use
- URIs, one of which is considered the primary URI, and is the one used as an
@id
and in Webfinger’ssubject
. They’re stored funnily in the Database; every Instance has one or more socket addresses (again, one of which primary) assigned to it (a port of zero signifies usage of the protocol’s default port, everywhere), and another table contains all other parts (user information, path, and scheme) with some checks to forbid HTTP in favour of HTTPS, and to make sure URIs are valid in the ACCT and HTTPS schemes. The idea is that it’s easy to dereference any URI; grab the hostname, add/.well-known/webfinger?resource=
, then the entire URI again. Add some fancy rendering client-side, and no more cursed hacks (ehm ehm Mastodon constructingacct
URIs fromas:preferredUsername
).
This variety and multi-URI-ability allow to federate with theoretically any platform. Plus, each instance can have multiple hostnames.
Basically, we removed the incredibly annoying username immutability without breaking compatibility at all; servers that only support a single URI can just handle different URIs as if they were different objects.
Note, I’m not intending on allowing multiple URIs per post. I think.
Self-storage
The database marks an instance’ source of truth as itself by having a column equal to null.
…which means we can have multiple instances have said column equal to null. Which means we can host multiple instances on the same database. And supporting multiple instances per server means we can easily support multiple databases per server (with each database managing different instances).
Keys
The server isn’t going to manage private keys. This is security hell and something I’m simply not intending to hold responsibility of.