From e25e609076f039d61e44fb1182492a39ecf0b0e9 Mon Sep 17 00:00:00 2001 From: thedevbirb Date: Wed, 25 Sep 2024 17:44:14 +0200 Subject: [PATCH] fix(builder): types now follow latest spec --- builder/builder/utils_test.go | 12 ++++++------ builder/common/types.go | 35 ++++++++++++----------------------- builder/miner/worker_test.go | 4 ++-- 3 files changed, 20 insertions(+), 31 deletions(-) diff --git a/builder/builder/utils_test.go b/builder/builder/utils_test.go index 76e6cfdf8..f4af130da 100644 --- a/builder/builder/utils_test.go +++ b/builder/builder/utils_test.go @@ -57,7 +57,7 @@ func TestGenerateMerkleMultiProofs(t *testing.T) { constraints := make(types.HashToConstraintDecoded) for _, tx := range chosenConstraintTransactions { - constraints[tx.Hash()] = &types.ConstraintDecoded{Tx: tx} + constraints[tx.Hash()] = tx } inclusionProof, root, err := CalculateMerkleMultiProofs(payloadTransactions, constraints) @@ -67,15 +67,15 @@ func TestGenerateMerkleMultiProofs(t *testing.T) { leaves := make([][]byte, len(constraints)) i := 0 - for _, constraint := range constraints { - if constraint == nil || constraint.Tx == nil { - t.Logf("nil constraint or transaction!") + for _, tx := range constraints { + if tx == nil { + t.Logf("nil constraint transaction!") } - // Compute the hash tree root for the raw preconfirmed transaction + // Compute the hash tree root for the raw committed transaction // and use it as "Leaf" in the proof to be verified against - withoutBlob, err := constraint.Tx.WithoutBlobTxSidecar().MarshalBinary() + withoutBlob, err := tx.WithoutBlobTxSidecar().MarshalBinary() if err != nil { t.Logf("error marshalling transaction without blob tx sidecar: %v", err) } diff --git a/builder/common/types.go b/builder/common/types.go index b07ac1987..b74259806 100644 --- a/builder/common/types.go +++ b/builder/common/types.go @@ -603,35 +603,24 @@ type SignedConstraintsList = []*SignedConstraints // Reference: https://chainbound.github.io/bolt-docs/api/builder type SignedConstraints struct { - Message ConstraintMessage `json:"message"` + Message ConstraintsMessage `json:"message"` Signature phase0.BLSSignature `json:"signature"` } // Reference: https://chainbound.github.io/bolt-docs/api/builder -type ConstraintMessage struct { - Constraints []*HexBytes `json:"constraints"` - ValidatorIndex uint64 `json:"validator_index"` - Slot uint64 `json:"slot"` - Top bool `json:"top"` +type ConstraintsMessage struct { + Pubkey uint64 `json:"pubkey"` + Slot uint64 `json:"slot"` + Top bool `json:"top"` + Transactions []*HexBytes `json:"transactions"` } -// Reference: https://chainbound.github.io/bolt-docs/api/builder-api -// type Constraint struct { -// Index *uint64 `json:"index"` -// Tx HexBytes `json:"tx"` -// } - -// ConstraintSubscriptionAuth is the struct the builder signs over to authenticate -// when subscribing to SSE constraint events from the relay -type ConstraintSubscriptionAuth struct { - PublicKey phase0.BLSPubKey `json:"publicKey"` - Slot uint64 `json:"slot"` +type SignedDelegation struct { + Message Delegation `json:"message"` + Signature phase0.BLSSignature `json:"signature"` } -func (c *ConstraintSubscriptionAuth) String() string { - buf, err := json.Marshal(c) - if err != nil { - return fmt.Sprintf("failed to marshal ConstraintSubscriptionAuth: %v", err) - } - return string(buf) +type Delegation struct { + ValidatorPubkey phase0.BLSPubKey `json:"validator_pubkey"` + DelegateePubkey phase0.BLSPubKey `json:"delegatee_pubkey"` } diff --git a/builder/miner/worker_test.go b/builder/miner/worker_test.go index 745a47618..bf5344876 100644 --- a/builder/miner/worker_test.go +++ b/builder/miner/worker_test.go @@ -122,8 +122,8 @@ func init() { } else { idx = nil } - constraints := make(map[common.Hash]*types.ConstraintDecoded) - constraints[tx1.Hash()] = &types.ConstraintDecoded{Index: idx, Tx: tx1} + constraints := make(map[common.Hash]*types.Transaction) + constraints[tx1.Hash()] = tx1 // FIXME: slot 0 is probably not correct for these tests testConstraintsCache.Put(0, constraints) }