From 217bd6fe8bf280ef4fd71094c8cfda7f03fd6e54 Mon Sep 17 00:00:00 2001 From: thedevbirb Date: Thu, 18 Jul 2024 09:21:18 +0200 Subject: [PATCH] testing --- bolt-sidecar/src/builder/mod.rs | 8 +++++--- builder/builder/utils.go | 4 ++++ mev-boost/server/service.go | 3 +++ mev-boost/server/utils.go | 7 ++++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/bolt-sidecar/src/builder/mod.rs b/bolt-sidecar/src/builder/mod.rs index c49a69dfb..e18241711 100644 --- a/bolt-sidecar/src/builder/mod.rs +++ b/bolt-sidecar/src/builder/mod.rs @@ -1,7 +1,7 @@ use alloy_primitives::U256; use blst::min_pk::SecretKey; use ethereum_consensus::{ - crypto::PublicKey, + crypto::{KzgCommitment, PublicKey}, deneb::mainnet::ExecutionPayloadHeader, ssz::prelude::{List, MerkleizationError}, }; @@ -102,6 +102,7 @@ impl LocalBuilder { ) -> Result<(), BuilderError> { let transactions = template.as_signed_transactions(); let blobs_bundle = template.as_blobs_bundle(); + let kzg_commitments = blobs_bundle.commitments.clone(); // 1. build a fallback payload with the given transactions, on top of // the current head of the chain @@ -132,7 +133,7 @@ impl LocalBuilder { ); // 3. sign the bid with the local builder's BLS key - let signed_bid = self.create_signed_builder_bid(value, eth_header)?; + let signed_bid = self.create_signed_builder_bid(value, eth_header, kzg_commitments)?; // 4. prepare a get_payload response for when the beacon node will ask for it let Some(get_payload_res) = @@ -165,6 +166,7 @@ impl LocalBuilder { &self, value: U256, header: ExecutionPayloadHeader, + blob_kzg_commitments: Vec, ) -> Result { // compat: convert from blst to ethereum consensus types let pubkey = self.secret_key.sk_to_pk().to_bytes(); @@ -172,7 +174,7 @@ impl LocalBuilder { let message = BuilderBid { header, - blob_kzg_commitments: List::default(), + blob_kzg_commitments: List::try_from(blob_kzg_commitments).unwrap(), public_key: consensus_pubkey, value, }; diff --git a/builder/builder/utils.go b/builder/builder/utils.go index 753e21778..3ed501133 100644 --- a/builder/builder/utils.go +++ b/builder/builder/utils.go @@ -167,6 +167,8 @@ func CalculateMerkleMultiProofs( continue } rawTxs[i] = bellatrix.Transaction(raw) + + log.Info(fmt.Sprintf("[BOLT]: Generated raw transaction for merkle tree %x", raw)) } log.Info(fmt.Sprintf("[BOLT]: Generated %d raw transactions for merkle tree", len(rawTxs))) @@ -181,6 +183,8 @@ func CalculateMerkleMultiProofs( // to output the leaf correctly. This is also never documented in fastssz. -__- rootNode.Hash() + log.Info(fmt.Sprintf("[BOLT]: Generated merkle tree with root %x", rootNode.Hash())) + // using our gen index formula: 2 * 2^21 + preconfIndex baseGeneralizedIndex := int(math.Pow(float64(2), float64(21))) generalizedIndexes := make([]int, len(constraints)) diff --git a/mev-boost/server/service.go b/mev-boost/server/service.go index d7cde2164..94fa0f1f1 100644 --- a/mev-boost/server/service.go +++ b/mev-boost/server/service.go @@ -393,6 +393,9 @@ func (m *BoostService) verifyInclusionProof(responsePayload *BidWithInclusionPro } currentTime := time.Now() + + log.Infof("[BOLT]: Verifying merkle multiproofs with transactions root %x", transactionsRoot[:]) + ok, err := fastSsz.VerifyMultiproof(transactionsRoot[:], hashes, leaves, indexes) elapsed := time.Since(currentTime) if err != nil { diff --git a/mev-boost/server/utils.go b/mev-boost/server/utils.go index a7ec11cef..854e22be4 100644 --- a/mev-boost/server/utils.go +++ b/mev-boost/server/utils.go @@ -305,7 +305,8 @@ func JSONStringify(obj any) string { func CalculateMerkleMultiProofs(rootNode *fastssz.Node, constraints []struct { tx Transaction hash phase0.Hash32 -}) (inclusionProof *InclusionProof, err error) { +}, +) (inclusionProof *InclusionProof, err error) { // using our gen index formula: 2 * 2^21 + preconfIndex baseGeneralizedIndex := int(math.Pow(float64(2), float64(21))) generalizedIndexes := make([]int, len(constraints)) @@ -335,5 +336,9 @@ func CalculateMerkleMultiProofs(rootNode *fastssz.Node, constraints []struct { inclusionProof = InclusionProofFromMultiProof(multiProof) inclusionProof.TransactionHashes = transactionHashes + if ok, err := fastssz.VerifyMultiproof(rootNode.Hash(), multiProof.Hashes, multiProof.Leaves, generalizedIndexes); !ok { + log.Error(fmt.Sprintf("[BOLT] - SANITY CHECK: could not verify just created merkle multiproof for %d preconf %s", len(constraints), err)) + } + return inclusionProof, nil }