Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into 1368_fee_test
Browse files Browse the repository at this point in the history
  • Loading branch information
fishseabowl authored Jun 4, 2024
2 parents f5d5188 + 280615b commit 583ff0f
Show file tree
Hide file tree
Showing 25 changed files with 523 additions and 172 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
## Next release

- dev: better estimate fee test
- test: Adding txv3 tests
- feat: L1 gas price/fix

## v0.8.0

- feat: add `TransactionFilter<TxType>` to pallet-starknet `Config`
- chore: remove `ignore` from
`storage_changes_should_revert_on_transaction_revert` test
- dev: Implement tests for new rpc method starknet_getTransactionStatus
- feat: actual estimate_fee added, brought back l1 messages and refactored
simulate tx
- dev: impl get_state_updates using get_transaction_re_execution_state_diff
Expand Down
48 changes: 24 additions & 24 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ incremental = true
authors = ["Abdelhamid Bakhta <@abdelhamidbakhta>"]
edition = "2021"
repository = "https://github.com/keep-starknet-strange/madara/"
version = "0.7.0"
version = "0.8.0"

[workspace.dependencies]
# Substrate frame dependencies
Expand Down
2 changes: 1 addition & 1 deletion crates/client/l1-gas-price/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct FeeHistory {
/// of the returned range, because this value can be derived from the newest block. Zeroes
/// are returned for pre-EIP-4844 blocks.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub base_fee_per_blob_gas: Vec<u128>,
pub base_fee_per_blob_gas: Vec<String>,
/// An array of block blob gas used ratios. These are calculated as the ratio of gasUsed and
/// gasLimit.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
Expand Down
12 changes: 8 additions & 4 deletions crates/client/l1-gas-price/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@ async fn update_gas_price(
// The RPC responds with 301 elements for some reason. It's also just safer to manually
// take the last 300. We choose 300 to get average gas caprice for last one hour (300 * 12 sec block
// time).
let (_, blob_fee_history_one_hour) =
fee_history.result.base_fee_per_blob_gas.split_at(fee_history.result.base_fee_per_blob_gas.len() - 300);

let avg_blob_base_fee = blob_fee_history_one_hour.iter().sum::<u128>() / blob_fee_history_one_hour.len() as u128;
let (_, blob_fee_history_one_hour) = fee_history
.result
.base_fee_per_blob_gas
.split_at(fee_history.result.base_fee_per_blob_gas.len().max(300) - 300);

let avg_blob_base_fee =
blob_fee_history_one_hour.iter().map(|hex_str| u128::from_str_radix(&hex_str[2..], 16).unwrap()).sum::<u128>()
/ blob_fee_history_one_hour.len() as u128;

let eth_gas_price = u128::from_str_radix(
fee_history
Expand Down
2 changes: 1 addition & 1 deletion crates/client/storage/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Storage overrides readers
//!
//! In order for the client to access on pallets chain data data it has to read from the storage.
//! In order for the client to access on pallets chain data it has to read from the storage.
//! This can be achieve either through the pallet runtime API or by indexing the storage directly.
//! The `OverrideHandle` make it possible to use the later, more efficient way, while keeping the
//! first one as a fallback.
Expand Down
32 changes: 20 additions & 12 deletions crates/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use mp_starknet_inherent::{
InherentDataProvider as StarknetInherentDataProvider, InherentError as StarknetInherentError, L1GasPrices,
StarknetInherentData, DEFAULT_SEQUENCER_ADDRESS, SEQ_ADDR_STORAGE_KEY,
};
use pallet_starknet_runtime_api::StarknetRuntimeApi;
use prometheus_endpoint::Registry;
use sc_basic_authorship::ProposerFactory;
use sc_client_api::{Backend, BlockBackend, BlockchainEvents, HeaderBackend};
Expand All @@ -33,7 +34,7 @@ use sc_telemetry::{Telemetry, TelemetryWorker};
use sc_transaction_pool::FullPool;
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_api::offchain::OffchainStorage;
use sp_api::ConstructRuntimeApi;
use sp_api::{ConstructRuntimeApi, ProvideRuntimeApi};
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
use sp_offchain::STORAGE_PREFIX;

Expand Down Expand Up @@ -346,18 +347,25 @@ pub fn new_full(
),
);

// Ensuring we've fetched the latest price before we start the node
futures::executor::block_on(mc_l1_gas_price::worker::run_worker(
ethereum_conf.clone(),
l1_gas_price.clone(),
false,
));
let fees_disabled = client
.runtime_api()
.is_transaction_fee_disabled(client.chain_info().best_hash)
.expect("Failed to get fee status");

task_manager.spawn_handle().spawn(
"l1-gas-prices-worker",
Some(MADARA_TASK_GROUP),
mc_l1_gas_price::worker::run_worker(ethereum_conf.clone(), l1_gas_price.clone(), true),
);
if !fees_disabled {
// Ensuring we've fetched the latest price before we start the node
futures::executor::block_on(mc_l1_gas_price::worker::run_worker(
ethereum_conf.clone(),
l1_gas_price.clone(),
false,
));

task_manager.spawn_handle().spawn(
"l1-gas-prices-worker",
Some(MADARA_TASK_GROUP),
mc_l1_gas_price::worker::run_worker(ethereum_conf.clone(), l1_gas_price.clone(), true),
);
}
}
}

Expand Down
Loading

0 comments on commit 583ff0f

Please sign in to comment.