Skip to content

Commit 85b8072

Browse files
committed
tapdb: use AssetLeafKey for new burn tree
This ensures that we avoid collision issues when an output has multiple assets that have the same script key and same group key. The asset ID will now be the tie breaker here.
1 parent 14e0093 commit 85b8072

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

tapdb/burn_tree.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,16 @@ func decodeAndBuildAuthBurnLeaf(dbLeaf UniverseLeaf) (
229229
}
230230
scriptKey := asset.NewScriptKey(scriptPub)
231231

232-
leafKey := universe.BaseLeafKey{
233-
OutPoint: burnProof.OutPoint(),
234-
ScriptKey: &scriptKey,
232+
leafKey := universe.AssetLeafKey{
233+
BaseLeafKey: universe.BaseLeafKey{
234+
OutPoint: burnProof.OutPoint(),
235+
ScriptKey: &scriptKey,
236+
},
237+
AssetID: burnProof.Asset.ID(),
235238
}
236239

237240
burnLeaf := &universe.BurnLeaf{
238-
UniverseKey: leafKey,
241+
UniverseKey: &leafKey,
239242
BurnProof: &burnProof,
240243
}
241244

tapdb/burn_tree_test.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,12 @@ func createBurnLeaf(t *testing.T) *universe.BurnLeaf {
4242
scriptKey := asset.RandScriptKey(t)
4343

4444
return &universe.BurnLeaf{
45-
UniverseKey: universe.BaseLeafKey{
46-
OutPoint: burnProof.OutPoint(),
47-
ScriptKey: &scriptKey,
45+
UniverseKey: universe.AssetLeafKey{
46+
BaseLeafKey: universe.BaseLeafKey{
47+
OutPoint: burnProof.OutPoint(),
48+
ScriptKey: &scriptKey,
49+
},
50+
AssetID: burnProof.Asset.ID(),
4851
},
4952
BurnProof: burnProof,
5053
}
@@ -189,9 +192,12 @@ func TestBurnUniverseTreeInsertBurns(t *testing.T) {
189192
}
190193

191194
nonBurnLeaf := &universe.BurnLeaf{
192-
UniverseKey: universe.BaseLeafKey{
193-
OutPoint: op,
194-
ScriptKey: &a.ScriptKey,
195+
UniverseKey: universe.AssetLeafKey{
196+
BaseLeafKey: universe.BaseLeafKey{
197+
OutPoint: op,
198+
ScriptKey: &a.ScriptKey,
199+
},
200+
AssetID: a.ID(),
195201
},
196202
BurnProof: nonBurnProof,
197203
}

universe/interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,7 @@ type IgnoreTree interface {
13201320
// BurnLeaf is a type that represents a burn leaf within the universe tree.
13211321
type BurnLeaf struct {
13221322
// UniverseKey is the key that the burn leaf is stored at.
1323-
UniverseKey LeafKey
1323+
UniverseKey UniqueLeafKey
13241324

13251325
// BurnProof is the burn proof that is stored within the burn leaf.
13261326
BurnProof *proof.Proof

0 commit comments

Comments
 (0)