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: tests in kona-mpt #738

Merged
merged 1 commit into from
Oct 28, 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 crates/mpt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ alloy-primitives = { workspace = true, features = ["rlp"] }

[dev-dependencies]
# Alloy
alloy-provider.workspace = true
alloy-provider = { workspace = true, features = ["reqwest"] }
alloy-consensus.workspace = true
alloy-transport-http.workspace = true
alloy-rpc-types = { workspace = true, features = ["eth"] }
Expand Down
23 changes: 13 additions & 10 deletions crates/mpt/src/test_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ pub(crate) async fn get_live_derivable_receipts_list(
let block = provider
.get_block(block_number.into(), BlockTransactionsKind::Full)
.await
.map_err(|e| anyhow!(e))?
.ok_or(anyhow!("Missing block"))?;
.map_err(anyhow::Error::from)?
.ok_or_else(|| anyhow!("Missing block"))?;
let receipts = provider
.get_block_receipts(block_number.into())
.await
.map_err(|e| anyhow!(e))?
.ok_or(anyhow!("Missing receipts"))?;
.map_err(anyhow::Error::from)?
.ok_or_else(|| anyhow!("Missing receipts"))?;

let consensus_receipts = receipts
.into_iter()
Expand Down Expand Up @@ -59,7 +59,9 @@ pub(crate) async fn get_live_derivable_receipts_list(

// Compute the derivable list
let mut list =
ordered_trie_with_encoder(consensus_receipts.as_ref(), |rlp, buf| rlp.encode_2718(buf));
ordered_trie_with_encoder(consensus_receipts.as_ref(), |rlp: &ReceiptEnvelope, buf| {
rlp.encode_2718(buf)
});
let root = list.root();

// Sanity check receipts root is correct
Expand Down Expand Up @@ -87,20 +89,21 @@ pub(crate) async fn get_live_derivable_transactions_list(
let block = provider
.get_block(block_number.into(), BlockTransactionsKind::Full)
.await
.map_err(|e| anyhow!(e))?
.ok_or(anyhow!("Missing block"))?;
.map_err(anyhow::Error::from)?
.ok_or_else(|| anyhow!("Missing block"))?;

let BlockTransactions::Full(txs) = block.transactions else {
anyhow::bail!("Did not fetch full block");
};
let consensus_txs = txs
.into_iter()
.map(|tx| TxEnvelope::try_from(tx).map_err(|e| anyhow!(e)))
.map(|tx| TxEnvelope::try_from(tx).map_err(anyhow::Error::from))
.collect::<Result<Vec<_>>>()?;

// Compute the derivable list
let mut list =
ordered_trie_with_encoder(consensus_txs.as_ref(), |rlp, buf| rlp.encode_2718(buf));
let mut list = ordered_trie_with_encoder(consensus_txs.as_ref(), |rlp: &TxEnvelope, buf| {
rlp.encode_2718(buf)
});
let root = list.root();

// Sanity check transaction root is correct
Expand Down