1// Package gnopm is the domain model of a source registry for gno packages: a2// map from a deployed package path back to the repository, commit and directory3// that produced it.4//5// It exists because gno deliberately broke the link Go gets for free. A Go6// import path IS a repository URL, so pkg.go.dev needs no registry; a gno7// import path is a chain address, so nothing anywhere says which source
Functions
not supported for pure packages by the node (vm/qfuncs)
Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.
8// produced the bytes running at gno.land/p/nt/tinyavl/v0.
9//
10// # What this can and cannot promise
11//
12// It cannot promise anything, and the design is built around saying so rather
13// than around hiding it. Two claims look alike and are not the same:
14//
15// 1. "this package came from that repository". UNPROVABLE, here or anywhere.
16// Anyone may deploy any bytes and anyone may claim any repository. No
17// registry design fixes this, and one that implies otherwise is worse than
18// none.
19// 2. "the bytes live at path P equal the addpkg payload of directory D in
20// repository R at commit C". Mechanically provable, by hashing both sides.
21// It is NOT provable here: a realm cannot clone a repository. It is
22// provable off chain by anything that can, and gnopm already does exactly
23// this against a local tree (`gnopm verify -deployed`).
24//
25// So this package stores (1), labelled as the claim it is, in the form (2)
26// needs to be checkable. A Claim is testimony under a signature. It becomes
27// evidence only once something outside the chain has gone and looked.
28//
29// # What a signature does buy
30//
31// The chain knows who signed a claim, and that is not nothing. A claim whose
32// claimant owns the package path's namespace comes from the party that controls
33// the path, which is the closest thing to a promise available without a
34// chain-level feature. OwnedBy reports that relationship; it is deliberately
35// computed on demand from a caller-supplied resolver and never stored, because
36// a name can be transferred and a stored answer would be a claim of its own.
37//
38// Anyone may still claim any path. That is the "open but tagged" choice, and it
39// is made on purpose: gating registration on namespace ownership would mean
40// that on day one, when almost nothing is registered by its own deployer, the
41// registry is empty and teaches nobody anything. The defence against a
42// misleading claim is that it renders as a stranger's claim, ranked below, and
43// never as a fact.
44package gnopm
45
46import (
47"strings"
48
49"gno.land/p/nt/avl/v0"
50)
51
52// Registry maps a package path to the claims made about its source.
53//
54// One path may carry several claims, at most one per claimant. That is not a
55// flaw to be resolved: a fork is a legitimate second answer, and so is a third
56// party filling in the map for a package whose author never will.
57type Registry struct {
58 packages *avl.Tree // package path -> *Package
59 claims int
60}
61
62// New returns an empty registry.
63func New() *Registry {
64return &Registry{packages: avl.NewTree()}
65}
66
67// Package is every claim made about one package path.