1 of 16

Git Refactoring - Paving the Way for Anonymous, Decentralized Open Source in the Web 3.0

Eli Ma <eli.ma@web3infra.foundation>

2 of 16

Eli Ma

Individual Member of Governing Board of Web3 Infrastructure Foundation

3 of 16

Background: VCS at Google

CVS

1998

Piper

CitC + Piper

CitC + Piper + jj�(Fig NG)

CitC + Piper + Mercurial�(a.k.a. Fig)

Perforce

4 of 16

Background: Mega Story

From Multi Repos to Monorepo

From Enterprise to Individual

From Centralized to Decentralized

Web3 Developer Infrastructure

5 of 16

Git - Addressable Content Filesystem/Database

6 of 16

Git Internal Objects

Blob

Tree

Commit

Tag

b

l

o

b

1

2

space

H

e

l

l

o

\0

,

w

o

r

l

d

!

Type

Size

Content

7 of 16

Variable-Length Decoding

1

1

0

1

0

1

0

1

0

0

0

0

0

1

0

1

1

0

1

0

1

0

1

0

0

0

0

1

0

1

1

0

1

0

1

0

1

MSB = 1

MSB = 0

Size

Size

Size = 1011010101

8 of 16

Git Pack File

1

0

0

1

0

1

0

1

0

1

0

1

0

1

0

1

MSB

Version

Object Type

Size

Size

b

l

o

b

1

2

space

H

e

l

l

o

\0

,

w

o

r

l

d

!

Type

Size

Content

P

A

C

K

Magic

2

1

0

1

Number

HEADER

Object

MSB

9 of 16

Git SSH Protocol

sequenceDiagram

participant Server

participant Client

Client ->> Server: Request to make a connection

Server ->> Client: Connection Established

Client ->> Server: Send repo info to Server

Server ->> Client: Send refs to Client

Client ->> Server: Send Computed data to Server

Server -> Client: Send pack to Client

Client -> Server: close a connection

Client -->> Client: Decode pack & update the local

10 of 16

Git URI - p2p://<peerID>/<repo>.git

[<protocol>://]<username>[:<password>]@<hostname>[:<port>]/<path>[.git]

  1. The <protocol> could be an optional prefix like p2p:// or mega:// to indicate the p2p protocol.
  2. The <username> represents the node key accessing the repository so that we could replace it with for the p2p identity.
  3. The <password> is unnecessary for public repositories.
  4. The <hostname> typically represents the server, but in p2p, it maps to the node key hosting the repo. We could reuse <key> here or use a different term like <hostkey> to avoid confusion.
  5. The <port> may not be relevant for p2p networking?
  6. For <path>, mega uses monorepos so there are no <namespaces> or <repo> names, only paths. We could design a virtual path scheme to map paths to exposed public paths privately.

11 of 16

DHT Data Format

[

{

"upstream":"12D3KooWFgpUQa9WnTztcvs5LLMJmwsMoGZcrTHdt9LKYwerxK",

"peerId":"node_a_peerId ",

"hash":"12D3KooWFgpUQa9WnTztcvs5LLMJmwsMoGZcrTHdt9LKYKpM4MiK",

"timestamp":1690191636

},

{

"upstream":"12D3KooWFgpU4564WnTztcvs5LLMJmwsMoGZcrTHdt9LKYKpM4MiK",

"peerId":"12D3KooWFgpUQa9WnTztcvs5LLMJmwsMoGZcrTHdt9LKYKpM4MiK ",

"hash":"ddddddd",

"timestamp":1690128000

}

]

12 of 16

P2P Process through DHT

13 of 16

Distributed Open Source Collaboration through Nostr

14 of 16

NIP 111 - Repo Broadcast

15 of 16

NIP 111 - Merge Request

16 of 16

Anonymous, Decentralized Open Source

End & Thanks

https://github.com/web3infra-foundation/mega