Skip to content

Commit

Permalink
Merge branch 'main' into feat/solidity-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
agostbiro committed Oct 21, 2024
2 parents eea9dc4 + 498d007 commit 3700823
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/edr_defaults/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edition.workspace = true

[dependencies]
alloy-primitives.workspace = true
ruint = "1.12.3"

[lints]
workspace = true
4 changes: 4 additions & 0 deletions crates/edr_defaults/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use alloy_primitives::{address, Address};
use ruint::aliases::U256;

/// The default secret keys from which the local accounts will be derived.
pub const SECRET_KEYS: [&str; 20] = [
Expand Down Expand Up @@ -53,3 +54,6 @@ pub const DEV_CHAIN_ID: u64 = 31337;
/// The first four bytes of the call data for a function call specifies the
/// function to be called.
pub const SELECTOR_LEN: usize = 4;

/// Terminal total difficulty for the Merge on main net
pub const TERMINAL_TOTAL_DIFFICULTY: U256 = ruint::uint!(58750000000000000000000_U256);
12 changes: 10 additions & 2 deletions crates/edr_evm/src/blockchain/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,13 @@ where
.get_block_by_hash_with_transaction_data(*hash)
.await?
{
// Geth has recently removed the total difficulty field from block RPC
// responses, so we fall back to the terminal total difficulty of main net to
// provide backwards compatibility.
// TODO https://github.com/NomicFoundation/edr/issues/696
let total_difficulty = *block
.total_difficulty()
.expect("Must be present as this is not a pending transaction");
.unwrap_or(&edr_defaults::TERMINAL_TOTAL_DIFFICULTY);

self.fetch_and_cache_block(cache, block).await?;

Expand All @@ -227,9 +231,13 @@ where
cache: RwLockUpgradableReadGuard<'_, SparseBlockchainStorage<BlockT, ChainSpecT>>,
block: ChainSpecT::RpcBlock<ChainSpecT::RpcTransaction>,
) -> Result<BlockT, ForkedBlockchainError> {
// Geth has recently removed the total difficulty field from block RPC
// responses, so we fall back to the terminal total difficulty of main net to
// provide backwards compatibility.
// TODO https://github.com/NomicFoundation/edr/issues/696
let total_difficulty = *block
.total_difficulty()
.expect("Must be present as this is not a pending block");
.unwrap_or(&edr_defaults::TERMINAL_TOTAL_DIFFICULTY);

let block: RemoteBlock<ChainSpecT> =
block.into_remote_block(self.client.clone(), self.runtime.clone())?;
Expand Down
6 changes: 6 additions & 0 deletions crates/edr_napi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @nomicfoundation/edr

## 0.6.4

### Patch Changes

- 14620c9: Fix panic due to remote nodes not returning total difficulty by adding fallback value

## 0.6.3

### Patch Changes
Expand Down

0 comments on commit 3700823

Please sign in to comment.