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

fix(constraints-api): delegations #1

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
2 changes: 1 addition & 1 deletion builder/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func (r *RemoteRelay) GetDelegationsForSlot(nextSlot uint64) (types.SignedDelega
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()

log.Info("getting delegations for slot", nextSlot, "endpoint", endpoint)
var dst types.SignedDelegations
code, err := SendHTTPRequest(ctx, *http.DefaultClient, http.MethodGet, endpoint, nil, &dst)
if err != nil {
Expand All @@ -152,7 +153,6 @@ func (r *RemoteRelay) GetDelegationsForSlot(nextSlot uint64) (types.SignedDelega
}

return dst, nil

}

func (r *RemoteRelay) Start() error {
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
Loading