Skip to content

Commit c7656dd

Browse files
committed
supplyverifier: add check for minimum pre-commit count in verifier
Each issuance event should have a corresponding pre-commitment output. This relationship is used to enforce a lower bound on the number of pre-commitments.
1 parent 21f385d commit c7656dd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

universe/supplyverifier/verifier.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,15 @@ func (v *Verifier) VerifyCommit(ctx context.Context,
813813
"group when verifying supply commitment: %w", err)
814814
}
815815

816+
// Verify that we have at least as many supply pre-commitments as
817+
// new issuance leaves. Each issuance leaf must correspond to a
818+
// pre-commitment output created at the time of asset issuance.
819+
if len(unspentPreCommits) < len(leaves.IssuanceLeafEntries) {
820+
return fmt.Errorf("not enough unspent supply pre-commitment "+
821+
"outputs for issuance leaves: have %d, need %d",
822+
len(unspentPreCommits), len(leaves.IssuanceLeafEntries))
823+
}
824+
816825
// Perform validation of the provided supply leaves.
817826
err = v.verifySupplyLeaves(ctx, assetSpec, delegationKey, leaves)
818827
if err != nil {

0 commit comments

Comments
 (0)