From d1a9417f16bdde2e118821a90778dc7702f396d7 Mon Sep 17 00:00:00 2001 From: ffranr Date: Fri, 8 Sep 2023 13:45:45 +0100 Subject: [PATCH 1/6] tapdb: rename BaseMultiverse to MultiverseStore --- config.go | 2 +- tapdb/multiverse.go | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/config.go b/config.go index fbc38e568..49c7f91ee 100644 --- a/config.go +++ b/config.go @@ -69,7 +69,7 @@ type DatabaseConfig struct { TapAddrBook *tapdb.TapAddressBook - Multiverse *tapdb.BaseMultiverse + Multiverse *tapdb.MultiverseStore FederationDB *tapdb.UniverseFederationDB } diff --git a/tapdb/multiverse.go b/tapdb/multiverse.go index d6505770f..0981eb865 100644 --- a/tapdb/multiverse.go +++ b/tapdb/multiverse.go @@ -52,10 +52,10 @@ type BatchedMultiverse interface { BatchedTx[BaseMultiverseStore] } -// BaseMultiverse implements the persistent storage for a multiverse. +// MultiverseStore implements the persistent storage for a multiverse. // // NOTE: This implements the universe.BaseMultiverse interface. -type BaseMultiverse struct { +type MultiverseStore struct { db BatchedMultiverse // TODO(roasbeef): actually the start of multiverse? @@ -64,15 +64,15 @@ type BaseMultiverse struct { } // NewBaseMultiverse creates a new base multiverse. -func NewBaseMultiverse(db BatchedMultiverse) *BaseMultiverse { - return &BaseMultiverse{ +func NewBaseMultiverse(db BatchedMultiverse) *MultiverseStore { + return &MultiverseStore{ db: db, } } // RootNodes returns the complete set of known base universe root nodes for the // set of base universes tracked in the multiverse. -func (b *BaseMultiverse) RootNodes( +func (b *MultiverseStore) RootNodes( ctx context.Context) ([]universe.BaseRoot, error) { var ( @@ -156,7 +156,7 @@ func (b *BaseMultiverse) RootNodes( // doesn't have a script key specified, then all the proofs for the minting // outpoint will be returned. If neither are specified, then proofs for all the // inserted leaves will be returned. -func (b *BaseMultiverse) FetchIssuanceProof(ctx context.Context, +func (b *MultiverseStore) FetchIssuanceProof(ctx context.Context, id universe.Identifier, universeKey universe.BaseKey) ([]*universe.IssuanceProof, error) { @@ -215,7 +215,7 @@ func (b *BaseMultiverse) FetchIssuanceProof(ctx context.Context, // RegisterIssuance inserts a new minting leaf within the multiverse tree and // the universe tree that corresponds to the given base key. -func (b *BaseMultiverse) RegisterIssuance(ctx context.Context, +func (b *MultiverseStore) RegisterIssuance(ctx context.Context, id universe.Identifier, key universe.BaseKey, leaf *universe.MintingLeaf, metaReveal *proof.MetaReveal) (*universe.IssuanceProof, error) { @@ -297,7 +297,7 @@ func (b *BaseMultiverse) RegisterIssuance(ctx context.Context, // RegisterBatchIssuance inserts a new minting leaf batch within the multiverse // tree and the universe tree that corresponds to the given base key(s). -func (b *BaseMultiverse) RegisterBatchIssuance(ctx context.Context, +func (b *MultiverseStore) RegisterBatchIssuance(ctx context.Context, items []*universe.IssuanceItem) error { insertProof := func(item *universe.IssuanceItem, From fde2331c384d31275c0612741bdb7e475daf345e Mon Sep 17 00:00:00 2001 From: ffranr Date: Fri, 8 Sep 2023 13:46:49 +0100 Subject: [PATCH 2/6] tapdb: rename NewBaseMultiverse to NewMultiverseStore --- tapcfg/server.go | 2 +- tapdb/multiverse.go | 4 ++-- tapdb/universe_test.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tapcfg/server.go b/tapcfg/server.go index de993e31d..d85c72b90 100644 --- a/tapcfg/server.go +++ b/tapcfg/server.go @@ -115,7 +115,7 @@ func genServerConfig(cfg *Config, cfgLogger btclog.Logger, return db.WithTx(tx) }, ) - multiverse := tapdb.NewBaseMultiverse(multiverseDB) + multiverse := tapdb.NewMultiverseStore(multiverseDB) uniStatsDB := tapdb.NewTransactionExecutor( db, func(tx *sql.Tx) tapdb.UniverseStatsStore { diff --git a/tapdb/multiverse.go b/tapdb/multiverse.go index 0981eb865..19abacafa 100644 --- a/tapdb/multiverse.go +++ b/tapdb/multiverse.go @@ -63,8 +63,8 @@ type MultiverseStore struct { // * drop base in front? } -// NewBaseMultiverse creates a new base multiverse. -func NewBaseMultiverse(db BatchedMultiverse) *MultiverseStore { +// NewMultiverseStore creates a new multiverse DB store handle. +func NewMultiverseStore(db BatchedMultiverse) *MultiverseStore { return &MultiverseStore{ db: db, } diff --git a/tapdb/universe_test.go b/tapdb/universe_test.go index e9e484d51..4ae13658c 100644 --- a/tapdb/universe_test.go +++ b/tapdb/universe_test.go @@ -400,7 +400,7 @@ func TestUniverseTreeIsolation(t *testing.T) { return db.WithTx(tx) }, ) - multiverse := NewBaseMultiverse(multiverseDB) + multiverse := NewMultiverseStore(multiverseDB) rootNodes, err := multiverse.RootNodes(ctx) require.NoError(t, err) From a51e79c71e4332ab23f36d2452b13102eb0270d6 Mon Sep 17 00:00:00 2001 From: ffranr Date: Fri, 8 Sep 2023 15:02:03 +0100 Subject: [PATCH 3/6] tapdb: rename multiverse store RegisterIssuance to UpsertProofLeaf --- tapdb/multiverse.go | 6 +++--- universe/base.go | 2 +- universe/interface.go | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tapdb/multiverse.go b/tapdb/multiverse.go index 19abacafa..914ea5fe8 100644 --- a/tapdb/multiverse.go +++ b/tapdb/multiverse.go @@ -213,9 +213,9 @@ func (b *MultiverseStore) FetchIssuanceProof(ctx context.Context, return proofs, nil } -// RegisterIssuance inserts a new minting leaf within the multiverse tree and -// the universe tree that corresponds to the given base key. -func (b *MultiverseStore) RegisterIssuance(ctx context.Context, +// UpsertProofLeaf upserts a proof leaf within the multiverse tree and the +// universe tree that corresponds to the given key. +func (b *MultiverseStore) UpsertProofLeaf(ctx context.Context, id universe.Identifier, key universe.BaseKey, leaf *universe.MintingLeaf, metaReveal *proof.MetaReveal) (*universe.IssuanceProof, error) { diff --git a/universe/base.go b/universe/base.go index adc97415d..75c74e233 100644 --- a/universe/base.go +++ b/universe/base.go @@ -193,7 +193,7 @@ func (a *MintingArchive) RegisterIssuance(ctx context.Context, id Identifier, // Now that we know the proof is valid, we'll insert it into the base // multiverse backend, and return the new issuance proof. - issuanceProof, err := a.cfg.Multiverse.RegisterIssuance( + issuanceProof, err := a.cfg.Multiverse.UpsertProofLeaf( ctx, id, key, leaf, assetSnapshot.MetaReveal, ) if err != nil { diff --git a/universe/interface.go b/universe/interface.go index c521706a5..a82ed6010 100644 --- a/universe/interface.go +++ b/universe/interface.go @@ -243,9 +243,9 @@ type BaseMultiverse interface { // of assets tracked in the base Universe. RootNodes(ctx context.Context) ([]BaseRoot, error) - // RegisterIssuance inserts a new minting (issuance) leaf within the - // multiverse tree, stored at the given base key. - RegisterIssuance(ctx context.Context, id Identifier, key BaseKey, + // UpsertProofLeaf upserts a proof leaf within the multiverse tree and + // the universe tree that corresponds to the given key. + UpsertProofLeaf(ctx context.Context, id Identifier, key BaseKey, leaf *MintingLeaf, metaReveal *proof.MetaReveal) (*IssuanceProof, error) From e42ed50637c1c2fae2bec1cc727f3aa4536718ce Mon Sep 17 00:00:00 2001 From: ffranr Date: Fri, 8 Sep 2023 15:14:18 +0100 Subject: [PATCH 4/6] universe: rename interface BaseMultiverse to MultiverseArchive --- tapdb/multiverse.go | 2 +- universe/base.go | 2 +- universe/interface.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tapdb/multiverse.go b/tapdb/multiverse.go index 914ea5fe8..44a252a14 100644 --- a/tapdb/multiverse.go +++ b/tapdb/multiverse.go @@ -54,7 +54,7 @@ type BatchedMultiverse interface { // MultiverseStore implements the persistent storage for a multiverse. // -// NOTE: This implements the universe.BaseMultiverse interface. +// NOTE: This implements the universe.MultiverseArchive interface. type MultiverseStore struct { db BatchedMultiverse diff --git a/universe/base.go b/universe/base.go index 75c74e233..f7d0225a6 100644 --- a/universe/base.go +++ b/universe/base.go @@ -30,7 +30,7 @@ type MintingArchiveConfig struct { // Multiverse is used to interact with the set of known base // universe trees, and also obtain associated metadata and statistics. - Multiverse BaseMultiverse + Multiverse MultiverseArchive // UniverseStats is used to export statistics related to the set of // external/internal queries to the base universe instance. diff --git a/universe/interface.go b/universe/interface.go index a82ed6010..7a5e4349a 100644 --- a/universe/interface.go +++ b/universe/interface.go @@ -234,11 +234,11 @@ type BaseRoot struct { GroupedAssets map[asset.ID]uint64 } -// BaseMultiverse is an interface used to keep track of the set of base universe +// MultiverseArchive is an interface used to keep track of the set of universe // roots that we know of. The BaseBackend interface is used to interact with a // particular base universe, while this is used to obtain aggregate information // about the universes. -type BaseMultiverse interface { +type MultiverseArchive interface { // RootNodes returns the complete set of known root nodes for the set // of assets tracked in the base Universe. RootNodes(ctx context.Context) ([]BaseRoot, error) From e7beb2f9e9922f46f683d9a760d4b17de5b4eca9 Mon Sep 17 00:00:00 2001 From: ffranr Date: Fri, 8 Sep 2023 15:34:21 +0100 Subject: [PATCH 5/6] tapdb: rename multiverse store FetchIssuanceProof to FetchProofLeaf --- tapdb/multiverse.go | 10 +++++----- universe/base.go | 6 +++--- universe/interface.go | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tapdb/multiverse.go b/tapdb/multiverse.go index 44a252a14..e403c25dd 100644 --- a/tapdb/multiverse.go +++ b/tapdb/multiverse.go @@ -152,11 +152,11 @@ func (b *MultiverseStore) RootNodes( return uniRoots, nil } -// FetchIssuanceProof returns an issuance proof for the target key. If the key -// doesn't have a script key specified, then all the proofs for the minting -// outpoint will be returned. If neither are specified, then proofs for all the -// inserted leaves will be returned. -func (b *MultiverseStore) FetchIssuanceProof(ctx context.Context, +// FetchProofLeaf returns a proof leaf for the target key. If the key +// doesn't have a script key specified, then all the proof leafs for the minting +// outpoint will be returned. If neither are specified, then all inserted proof +// leafs will be returned. +func (b *MultiverseStore) FetchProofLeaf(ctx context.Context, id universe.Identifier, universeKey universe.BaseKey) ([]*universe.IssuanceProof, error) { diff --git a/universe/base.go b/universe/base.go index f7d0225a6..cc3211892 100644 --- a/universe/base.go +++ b/universe/base.go @@ -145,7 +145,7 @@ func (a *MintingArchive) RegisterIssuance(ctx context.Context, id Identifier, // We'll first check to see if we already know of this leaf within the // multiverse. If so, then we'll return the existing issuance proof. - issuanceProofs, err := a.cfg.Multiverse.FetchIssuanceProof(ctx, id, key) + issuanceProofs, err := a.cfg.Multiverse.FetchProofLeaf(ctx, id, key) switch { case err == nil && len(issuanceProofs) > 0: issuanceProof := issuanceProofs[0] @@ -347,7 +347,7 @@ func (a *MintingArchive) getPrevAssetSnapshot(ctx context.Context, ScriptKey: &prevScriptKey, } - prevProofs, err := a.cfg.Multiverse.FetchIssuanceProof( + prevProofs, err := a.cfg.Multiverse.FetchProofLeaf( ctx, uniID, prevBaseKey, ) if err != nil { @@ -390,7 +390,7 @@ func (a *MintingArchive) FetchIssuanceProof(ctx context.Context, id Identifier, }() }() - return a.cfg.Multiverse.FetchIssuanceProof(ctx, id, key) + return a.cfg.Multiverse.FetchProofLeaf(ctx, id, key) } // MintingKeys returns the set of minting keys known for the specified base diff --git a/universe/interface.go b/universe/interface.go index 7a5e4349a..f7278cfee 100644 --- a/universe/interface.go +++ b/universe/interface.go @@ -254,11 +254,11 @@ type MultiverseArchive interface { // base key(s). RegisterBatchIssuance(ctx context.Context, items []*IssuanceItem) error - // FetchIssuanceProof returns an issuance proof for the target key. If - // the key doesn't have a script key specified, then all the proofs for - // the minting outpoint will be returned. If neither are specified, then - // proofs for all the inserted leaves will be returned. - FetchIssuanceProof(ctx context.Context, id Identifier, + // FetchProofLeaf returns a proof leaf for the target key. If the key + // doesn't have a script key specified, then all the proof leafs for the + // minting outpoint will be returned. If neither are specified, then all + // inserted proof leafs will be returned. + FetchProofLeaf(ctx context.Context, id Identifier, key BaseKey) ([]*IssuanceProof, error) // TODO(roasbeef): other stats stuff here, like total number of assets, etc From 1c07193d23870b60692811c75ef17ff89e8b28df Mon Sep 17 00:00:00 2001 From: ffranr Date: Fri, 22 Sep 2023 17:34:32 +0100 Subject: [PATCH 6/6] itest: increase proof transfer receiver ack timout from 5s to 15s --- itest/tapd_harness.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/itest/tapd_harness.go b/itest/tapd_harness.go index a7606c1b7..98635544d 100644 --- a/itest/tapd_harness.go +++ b/itest/tapd_harness.go @@ -49,7 +49,7 @@ const ( // defaultProofTransferReceiverAckTimeout is the default itest specific // timeout we'll use for waiting for a receiver to acknowledge a proof // transfer. - defaultProofTransferReceiverAckTimeout = 5 * time.Second + defaultProofTransferReceiverAckTimeout = 15 * time.Second ) // tapdHarness is a test harness that holds everything that is needed to