Skip to content

Commit

Permalink
fix(constraints-api): delegations type and signature digest
Browse files Browse the repository at this point in the history
  • Loading branch information
thedevbirb committed Nov 1, 2024
1 parent 433b7dd commit 740eb1c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ func (b *Builder) OnPayloadAttribute(attrs *types.BuilderPayloadAttributes) erro
// Verify signature against the public key
valid, err := delegation.VerifySignature(pubkey, b.GetConstraintsDomain())
if err != nil || !valid {
log.Error("could not verify signature", "err", err)
log.Error("could not verify delegation signature", "err", err, "valid", valid)
continue
}

Expand Down
9 changes: 4 additions & 5 deletions core/types/constraints.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ import (
"github.com/flashbots/go-boost-utils/bls"
)

var (
// ConstraintsDomainType is the expected signing domain mask for constraints-API related messages
ConstraintsDomainType = phase0.DomainType([4]byte{109, 109, 111, 67})
)
// ConstraintsDomainType is the expected signing domain mask for constraints-API related messages
var ConstraintsDomainType = phase0.DomainType([4]byte{109, 109, 111, 67})

// NOTE: given that it uses `common.Hash`, `Transaction` and it's used in both
// the builder package and the miner package, here it's a good place for now
Expand Down Expand Up @@ -252,7 +250,6 @@ func (c *SignedConstraints) Digest() []byte {

for _, tx := range c.Message.Transactions {
hasher.Write(tx.Hash().Bytes())

}

return hasher.Sum(nil)
Expand All @@ -279,6 +276,7 @@ type SignedDelegation struct {
}

type Delegation struct {
Action uint8 `json:"action"`
ValidatorPubkey phase0.BLSPubKey `json:"validator_pubkey"`
DelegateePubkey phase0.BLSPubKey `json:"delegatee_pubkey"`
}
Expand All @@ -287,6 +285,7 @@ type Delegation struct {
func (d *SignedDelegation) Digest() []byte {
hasher := sha256.New()
// NOTE: ignoring errors here
hasher.Write([]byte{d.Message.Action})
hasher.Write(d.Message.ValidatorPubkey[:])
hasher.Write(d.Message.DelegateePubkey[:])
return hasher.Sum(nil)
Expand Down

0 comments on commit 740eb1c

Please sign in to comment.