Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add check if the covenant is the covenant committee #91

Merged
merged 14 commits into from
Jan 13, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: add godoc to funcs
RafilxTenfen committed Jan 10, 2025
commit b377b05efb51ce767a3bbe723da7855d51c737ce
9 changes: 6 additions & 3 deletions covenant/covenant.go
Original file line number Diff line number Diff line change
@@ -452,7 +452,8 @@ func RemoveNotInCommittee(paramCache ParamsGetter, covenantSerializedPk []byte,
return sanitized
}

// IsKeyInCommittee verifies
// IsKeyInCommittee returns true if the covenant serialized public key is in the covenant committee of the
// parameter in which the BTC delegation was included.
func IsKeyInCommittee(paramCache ParamsGetter, covenantSerializedPk []byte, del *types.Delegation) bool {
stkParams, err := paramCache.Get(del.ParamsVersion)
if err != nil {
@@ -470,6 +471,8 @@ func IsKeyInCommittee(paramCache ParamsGetter, covenantSerializedPk []byte, del
return false
}

// RemoveAlreadySigned remove the delegations in which the serialized covenant public key
// alredy signed.
func RemoveAlreadySigned(covenantSerializedPk []byte, dels []*types.Delegation) []*types.Delegation {
sanitized := make([]*types.Delegation, 0, len(dels))

@@ -534,10 +537,10 @@ func (ce *CovenantEmulator) covenantSigSubmissionLoop() {
ce.logger.Debug("no pending delegations are found")
}
// 2. Remove delegations that do not need the covenant's signature
sanitized := ce.sanitizeDelegations(dels)
sanitizedDels := ce.sanitizeDelegations(dels)

// 3. Split delegations into batches for submission
batches := ce.delegationsToBatches(sanitized)
batches := ce.delegationsToBatches(sanitizedDels)
for _, delBatch := range batches {
_, err := ce.AddCovenantSignatures(delBatch)
if err != nil {