Skip to content

Commit

Permalink
fix(builder): types now follow latest spec
Browse files Browse the repository at this point in the history
  • Loading branch information
thedevbirb committed Sep 25, 2024
1 parent 0cf6876 commit e25e609
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 31 deletions.
12 changes: 6 additions & 6 deletions builder/builder/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down
35 changes: 12 additions & 23 deletions builder/common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
4 changes: 2 additions & 2 deletions builder/miner/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit e25e609

Please sign in to comment.