-
Notifications
You must be signed in to change notification settings - Fork 11
Introduce native tracer support #81
Introduce native tracer support #81
Conversation
I have tested this over the block range of 19240650 - 19240850 and 199 blocks completed successfully with one failure. This yields a 99.5% success rate. |
What was the failure? Which block and do you know why? |
It's block 19240734. The error is:
I have not had a chance to investigate the root cause of this but @Nashtare and I had concluded that the success rate was sufficiently high to merge as is and then leave this investigation / fix for a follow up issue / PR. |
4bbad04
to
5234bc9
Compare
tools/prove_blocks.sh
Outdated
@@ -5,6 +5,7 @@ | |||
# 2 --> End block index (inclusive) | |||
# 3 --> Rpc endpoint:port (eg. http://35.246.1.96:8545) | |||
# 4 --> Ignore previous proofs (boolean) | |||
# 5 --> Rpc type (eg. jerigon / native) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be set before Ignore previous proofs
? So that it goes in pair with the RPC endpoint, and we can keep the boolean as optional with default value. Not really blocking though
rpc/src/rpc/native/mod.rs
Outdated
debug!("Got block result: {:?}", rpc_block_metadata.block_by_number); | ||
debug!("Got trace result: {:?}", block_trace); | ||
debug!("Got chain_id: {:?}", rpc_block_metadata.chain_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe remove? Not sure this brings much
rpc/src/rpc/native/txn.rs
Outdated
) -> Result<Vec<TxnInfo>> { | ||
let mut futures_ordered = FuturesOrdered::new(); | ||
|
||
for tx_hash in &block.transactions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last time we tested blocks, I recall we needed to reverse the order here. Has this been tested since @frisitano?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I tested this on 200 blocks with a 99.5% success rate. The change was made below on line 30 in which we push_back
instead of the prior push_front
, see ref.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks!
The failure being due to the branch collapsing bug mentioned in the related issue I presume?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No that issue has been fixed (hacked) by fetching proofs after block execution and inserting short nodes (extension and leafs) into the trie builder.
This failure is due to an error when trying to fetch a proof for an account - see #81 (comment). I haven't had an opportunity to look into it.
rpc/src/rpc/native/trie.rs
Outdated
pub const EMPTY_TRIE_HASH: H256 = H256([ | ||
0x56, 0xe8, 0x1f, 0x17, 0x1b, 0xcc, 0x55, 0xa6, 0xff, 0x83, 0x45, 0xe6, 0x92, 0xc0, 0xf8, 0x6e, | ||
0x5b, 0x48, 0xe0, 0x1b, 0x99, 0x6c, 0xad, 0xc0, 0x01, 0x62, 0x2f, 0xb5, 0xe3, 0x63, 0xb4, 0x21, | ||
]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non-blocking, as not exposed (yet) but we should try to group all these common constants somewhere (probably somewhere under zk_evm
crates) and reuse/re-exports them instead of always redefining them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, I will add a TODO. I was also wondering if this module would be better positioned in the zk_evm/mpt_trie
crate for reuse?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think inside mpt_trie
probably makes the most sense.
I've opened a PR in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The most important change is keeping with alloy
from now on.
I'd like to re-review after markups
.gitignore
Outdated
@@ -13,3 +13,6 @@ proofs/ | |||
# Serialized generated prover & verifier state used by plonky2 | |||
prover_state_* | |||
verifier_state_* | |||
|
|||
# System files | |||
.DS_Store |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: newline
rpc/src/rpc/native/mod.rs
Outdated
|
||
/// A static retry policy that always retries. | ||
#[derive(Debug, Default)] | ||
pub struct StaticRetryPolicy; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Library code should never care about this - that's why we should be abstract over Provider
rpc/src/rpc/native/state.rs
Outdated
) -> Result< | ||
( | ||
Vec<(H160, EIP1186ProofResponse)>, | ||
Vec<(H160, EIP1186ProofResponse)>, | ||
), | ||
anyhow::Error, | ||
> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
) -> Result< | |
( | |
Vec<(H160, EIP1186ProofResponse)>, | |
Vec<(H160, EIP1186ProofResponse)>, | |
), | |
anyhow::Error, | |
> { | |
) -> anyhow::Result<[Vec<(H160, EIP1186ProofResponse)>; 2]> { |
rpc/src/rpc/native/state.rs
Outdated
keys.into_iter().collect(), | ||
Some((block_number - 1).into()), | ||
) | ||
.map_err(|e| anyhow!("Failed to get proof for account: {:?}", e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use anyhow::Context as __;
.map_err(|e| anyhow!("Failed to get proof for account: {:?}", e)) | |
.context("Failed to get proof for account") |
Anyhow will preserve the source error in it's cause chain. This is the whole point of using anyhow
rpc/src/rpc/native/txn.rs
Outdated
futures::try_join!(tx_fut, tx_receipt_fut, pre_trace_fut, diff_trace_fut,)?; | ||
|
||
Ok(( | ||
tx.ok_or_else(|| anyhow!("Transaction not found."))?, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use anyhow::Context as _;
tx.ok_or_else(|| anyhow!("Transaction not found."))?, | |
tx.context("Transaction not found.")?, |
Also works on Option
s
tools/debug_blocks.sh
Outdated
current_a=$((initial_a + i)) | ||
echo "Running debug block script with block=$current_a rpc=$b" | ||
"$script_dir/debug_block.sh" $current_a $b $rpc_type | ||
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: NL
I've been trying to migrate to alloy but I'm running into an issue when trying to rlp encode the let tx_receipt = provider.get_transaction_receipt(tx_hash).await?.unwrap();
let tx_receipt_rlp = tx_receipt.inner.encoded_2718(); If someone could take a look at this to assess what I may be doing wrong that would be appreciated. |
Does any of this help? /// There are two representations of domain objects in ethereum:
/// - RPC (JSON), in [`alloy::rpc`].
/// - RLP (binary), in [`alloy::consensus`].
///
/// This module provides best-effort [RLP encoding](alloy::rlp::Encodable) for
/// RPC types. |
It certainly looks like it could, thanks! |
I've implemented an initial migration to This PR still needs a hygiene sweep but I would like to address the retry issue first. |
73f310c
to
7cd3d62
Compare
This is ready for review along with 0xPolygonZero/zk_evm#258. |
8752d77
to
07cea87
Compare
I've completed the merge with |
EDIT: obligatory parameter to select @frisitano You can probably update |
Good catch! However, I don't think we will be able to make the rpc type optional as we can only have one optional argument (the last positional argument). Currently |
Tested |
I've updated the script. Let me know your thoughts. |
@frisitano Script is OK. Please fix also the docs and the CI. |
README updated. As discussed on slack, no changes required to CI. |
@frisitano We want to fix alloy version, so we will use recently released tag v0.1.1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@atanmarko Only did a synthetic review over the latest changes but I'm good to merge.
Regression tested latest develop with the native tracer. No regressions, working as expected. |
This PR introduces native tracer support such that blocks can be prover using standard rpc methods. This is a replacement for #51. This is currently blocked as alchemy is returning incorrect data for prestate tracer requests. I have opened a ticket with the support team and they are looking into it.
Merge steps:
zk_evm
dependencies in cargo to either the git repo or a new release.