Skip to content

Commit

Permalink
backport todo! removal on evm query (#750)
Browse files Browse the repository at this point in the history
* exclude system transactions from tip cap calc. (#674)

* exclude system transactions from tip cap calc.

* ci runs on prs to main

* Update package details in cargo.toml files (#678)

* Update package details in cargo.toml files

* Add devnet readme (#681)

---------

Co-authored-by: Ömer Talip Akalın <[email protected]>

* Add build-release (#706)

* remove todo! in block_number_for_id in evm query (#724)

* Merge branch 'nightly' into esad/fix-backport-merge-conflicts-1

* lint

---------

Co-authored-by: Erce Can Bektüre <[email protected]>
Co-authored-by: Ömer Talip Akalın <[email protected]>
  • Loading branch information
3 people authored Jun 14, 2024
1 parent 2230af4 commit 1e0e925
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 30 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ help: ## Display this help message
build: ## Build the the project
@cargo build

build-release: ## Build the project in release mode
@cargo build --release

clean: ## Cleans compiled
@cargo clean

Expand Down
1 change: 1 addition & 0 deletions bin/citrea/tests/test_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ impl TestClient {
#[serde(rename_all = "camelCase")]
// ethers version of FeeHistory doesn't accept None reward
pub struct FeeHistory {
#[allow(dead_code)]
pub base_fee_per_gas: Vec<ethers::types::U256>,
pub gas_used_ratio: Vec<f64>,
pub oldest_block: ethers::types::U256,
Expand Down
1 change: 1 addition & 0 deletions crates/ethereum-rpc/src/gas_price/fee_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ pub struct FeeHistoryEntry {
pub gas_used: u64,
/// Gas limit by this block.
pub gas_limit: u64,
#[allow(dead_code)]
/// Hash of the block.
pub header_hash: B256,
/// Approximated rewards for the configured percentiles.
Expand Down
7 changes: 2 additions & 5 deletions crates/ethereum-rpc/src/gas_price/gas_oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,9 @@ impl<C: sov_modules_api::Context> GasPriceOracle<C> {
block_count = max_fee_history
}

let Some(end_block) = self
let end_block = self
.provider
.block_number_for_id(&newest_block, working_set)
else {
return Err(EthApiError::UnknownBlockNumber);
};
.block_number_for_id(&newest_block, working_set)?;

// need to add 1 to the end block to get the correct (inclusive) range
let end_block_plus = end_block + 1;
Expand Down
3 changes: 1 addition & 2 deletions crates/ethereum-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ fn register_rpc_methods<C: sov_modules_api::Context, Da: DaService>(
reward_percentiles,
&mut working_set,
)
.await
.unwrap()
.await?
};

Ok::<FeeHistory, ErrorObjectOwned>(fee_history)
Expand Down
10 changes: 5 additions & 5 deletions crates/evm/src/evm/error/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ pub enum SignError {
NoChainId,
}

impl From<SignError> for ErrorObject<'static> {
fn from(error: SignError) -> Self {
error.into()
}
}
// impl From<SignError> for ErrorObject<'static> {
// fn from(error: SignError) -> Self {
// error.into()
// }
// }

/// We have to implement these functions because they are private to the reth_rpc crate
pub trait RpcInvalidTransactionErrorExt {
Expand Down
34 changes: 18 additions & 16 deletions crates/evm/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ impl<C: sov_modules_api::Context> Evm<C> {
}
_ => {
return Err(EthApiError::InvalidParams(
"Please provide a number or earliest/latest/pending tag".to_string(),
"Please provide a number or earliest/latest tag".to_string(),
)
.into())
}
Expand Down Expand Up @@ -366,7 +366,7 @@ impl<C: sov_modules_api::Context> Evm<C> {
}
_ => {
return Err(EthApiError::InvalidParams(
"Please provide a number or earliest/latest/pending tag".to_string(),
"Please provide a number or earliest/latest tag".to_string(),
)
.into())
}
Expand Down Expand Up @@ -413,7 +413,7 @@ impl<C: sov_modules_api::Context> Evm<C> {
}
_ => {
return Err(EthApiError::InvalidParams(
"Please provide a number or earliest/latest/pending tag".to_string(),
"Please provide a number or earliest/latest tag".to_string(),
)
.into())
}
Expand Down Expand Up @@ -461,7 +461,7 @@ impl<C: sov_modules_api::Context> Evm<C> {
// Note that reth works for all types of BlockNumberOrTag
_ => {
return Err(EthApiError::InvalidParams(
"Please provide a number or earliest/latest/pending tag".to_string(),
"Please provide a number or earliest/latest tag".to_string(),
)
.into())
}
Expand Down Expand Up @@ -537,8 +537,9 @@ impl<C: sov_modules_api::Context> Evm<C> {
debug!("evm module: eth_getTransactionByBlockNumberAndIndex");

let block_number = match self.block_number_for_id(&block_number, working_set) {
Some(block_number) => block_number,
None => return Ok(None),
Ok(block_number) => block_number,
Err(EthApiError::UnknownBlockNumber) => return Ok(None),
Err(err) => return Err(err.into()),
};

let block = self
Expand Down Expand Up @@ -1565,23 +1566,24 @@ impl<C: sov_modules_api::Context> Evm<C> {
&self,
block_id: &BlockNumberOrTag,
working_set: &mut WorkingSet<C>,
) -> Option<u64> {
) -> Result<u64, EthApiError> {
match block_id {
BlockNumberOrTag::Earliest => Some(0),
BlockNumberOrTag::Latest => self
BlockNumberOrTag::Earliest => Ok(0),
BlockNumberOrTag::Latest => Ok(self
.blocks
.last(&mut working_set.accessory_state())
.map(|block| block.header.number),
.map(|block| block.header.number)
.expect("Head block must be set")),
BlockNumberOrTag::Number(block_number) => {
if *block_number < self.blocks.len(&mut working_set.accessory_state()) as u64 {
Some(*block_number)
Ok(*block_number)
} else {
None
Err(EthApiError::UnknownBlockNumber)
}
}
_ => {
todo!();
}
_ => Err(EthApiError::InvalidParams(
"Please provide a number or earliest/latest tag".to_string(),
)),
}
}

Expand Down Expand Up @@ -1613,7 +1615,7 @@ impl<C: sov_modules_api::Context> Evm<C> {
.expect("Head block must be set"),
)),
_ => Err(EthApiError::InvalidParams(
"pending block not supported".to_string(),
"pending/safe/finalized block not supported".to_string(),
)),
}
}
Expand Down
1 change: 0 additions & 1 deletion crates/sovereign-sdk/examples/demo-simple-stf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ use sov_mock_da::{MockAddress, MockBlob, MockBlock, MockValidityCond};
use sov_mock_zkvm::MockZkvm;
use sov_rollup_interface::stf::StateTransitionFunction;

#[test]
fn test_stf() {
let address = MockAddress { addr: [1; 32] };
let preimage = vec![0; 32];
Expand Down
1 change: 0 additions & 1 deletion crates/sovereign-sdk/full-node/sov-stf-runner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#[cfg(feature = "native")]
mod config;
#[cfg(feature = "mock")]
/// Testing utilities.
#[cfg(feature = "mock")]
pub mod mock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ use crate::manifest::Manifest;
pub struct PartialItemConst {
pub attrs: Vec<Attribute>,
pub vis: Visibility,
#[allow(dead_code)]
pub const_token: Token![const],
#[allow(dead_code)]
pub ident: Ident,
#[allow(dead_code)]
pub colon_token: Token![:],
#[allow(dead_code)]
pub ty: Type,
#[allow(dead_code)]
pub semi_token: Token![;],
}

Expand Down

0 comments on commit 1e0e925

Please sign in to comment.