Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
thedevbirb committed Jul 18, 2024
1 parent 487d06a commit 217bd6f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
8 changes: 5 additions & 3 deletions bolt-sidecar/src/builder/mod.rs
Original file line number Diff line number Diff line change
@@ -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},
};
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) =
Expand Down Expand Up @@ -165,14 +166,15 @@ impl LocalBuilder {
&self,
value: U256,
header: ExecutionPayloadHeader,
blob_kzg_commitments: Vec<KzgCommitment>,
) -> Result<SignedBuilderBid, BuilderError> {
// compat: convert from blst to ethereum consensus types
let pubkey = self.secret_key.sk_to_pk().to_bytes();
let consensus_pubkey = PublicKey::try_from(pubkey.as_slice()).expect("valid pubkey bytes");

let message = BuilderBid {
header,
blob_kzg_commitments: List::default(),
blob_kzg_commitments: List::try_from(blob_kzg_commitments).unwrap(),
public_key: consensus_pubkey,
value,
};
Expand Down
4 changes: 4 additions & 0 deletions builder/builder/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -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))
Expand Down
3 changes: 3 additions & 0 deletions mev-boost/server/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 6 additions & 1 deletion mev-boost/server/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
}

0 comments on commit 217bd6f

Please sign in to comment.