Skip to content
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
5 changes: 2 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ jobs:
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- uses: auguwu/clippy-action@1.4.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Clippy
run: cargo clippy --all-targets --workspace -- -Dclippy::all

format:
name: Format
Expand Down
4 changes: 2 additions & 2 deletions api/src/methods/block_number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mod tests {
std::sync::Arc,
umi_app::{Application, CommandActor, HybridBlockHashCache, TestDependencies},
umi_blockchain::{
block::{Eip1559GasFee, InMemoryBlockQueries, InMemoryBlockRepository, UmiBlockHash},
block::{InMemoryBlockQueries, InMemoryBlockRepository, JovianGasFee, UmiBlockHash},
in_memory::shared_memory,
payload::{InMemoryPayloadQueries, InProgressPayloads},
receipt::{InMemoryReceiptQueries, InMemoryReceiptRepository, receipt_memory},
Expand Down Expand Up @@ -77,7 +77,7 @@ mod tests {
mem_pool: Default::default(),
resolver_cache: Default::default(),
genesis_config,
gas_fee: Eip1559GasFee::default(),
gas_fee: JovianGasFee::default(),
base_token: UmiBaseTokenAccounts::new(AccountAddress::ONE),
l1_fee: U256::ZERO,
l2_fee: U256::ZERO,
Expand Down
7 changes: 6 additions & 1 deletion api/src/methods/forkchoice_updated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ pub(super) mod tests {
"prevRandao": "0xbde07f5d381bb84700433fe6c0ae077aa40eaad3a5de7abd298f0e3e27e6e4c9",
"suggestedFeeRecipient": "0x4200000000000000000000000000000000000011",
"timestamp": "0x6660737b",
"eip1559Params": "0x0000000000000000",
"minBaseFee": 0,
"transactions": [
"0x7ef8f8a0de86bef815fc910df65a9459ccb2b9a35fa8596dfcfed1ff01bbf28891d86d5e94deaddeaddeaddeaddeaddeaddeaddeaddead00019442000000000000000000000000000000000000158080830f424080b8a4440a5e2000000558000c5fc50000000000000000000000006660735b00000000000001a9000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000017ae3f74f0134521a7d62a387ac75a5153bcd1aab1c7e003e9b9e15a5d8846363000000000000000000000000e25583099ba105d9ec0a67f5ae86d90e50036425",
"0x7ef858a000000000000000000000000000000000000000000000000000000000000000009488f9b82462f6c4bf4a0fb15e5c3971559a316e7f9488f9b82462f6c4bf4a0fb15e5c3971559a316e7f7b7b88ffffffffffffffff8080"
Expand Down Expand Up @@ -229,6 +231,8 @@ pub(super) mod tests {
"prevRandao": "0xbde07f5d381bb84700433fe6c0ae077aa40eaad3a5de7abd298f0e3e27e6e4c9",
"suggestedFeeRecipient": "0x4200000000000000000000000000000000000011",
"timestamp": "0x6660737b",
"eip1559Params": "0x0000000000000000",
"minBaseFee": 0,
"transactions": [
"0x7ef8f8a0de86bef815fc910df65a9459ccb2b9a35fa8596dfcfed1ff01bbf28891d86d5e94deaddeaddeaddeaddeaddeaddeaddeaddead00019442000000000000000000000000000000000000158080830f424080b8a4440a5e2000000558000c5fc50000000000000000000000006660735b00000000000001a9000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000017ae3f74f0134521a7d62a387ac75a5153bcd1aab1c7e003e9b9e15a5d8846363000000000000000000000000e25583099ba105d9ec0a67f5ae86d90e50036425"
],
Expand Down Expand Up @@ -269,7 +273,8 @@ pub(super) mod tests {
))],
gas_limit: U64::from_be_slice(&hex!("01c9c380")),
no_tx_pool: None,
eip1559_params: None
eip1559_params: Default::default(),
min_base_fee: Default::default(),
}).try_into().unwrap()),
);

Expand Down
4 changes: 2 additions & 2 deletions api/src/methods/get_block_by_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ mod tests {
"gasLimit": "0x0",
"gasUsed": "0x0",
"timestamp": "0x0",
"extraData": "0x000000000800000002",
"extraData": "0x0100000008000000020000000000000000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0x0000000000000000",
"size": "0x1f9",
"size": "0x201",
"uncles": [],
"transactions": [],
"withdrawals": []
Expand Down
4 changes: 2 additions & 2 deletions api/src/methods/get_block_by_number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ mod tests {
"gasLimit": "0x0",
"gasUsed": "0x0",
"timestamp": "0x0",
"extraData": "0x000000000800000002",
"extraData": "0x0100000008000000020000000000000000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0x0000000000000000",
"size": "0x1f9",
"size": "0x201",
"uncles": [],
"transactions": [],
"withdrawals": []
Expand Down
4 changes: 2 additions & 2 deletions api/src/methods/get_payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ mod tests {
"gasLimit": "0x1c9c380",
"gasUsed": "0x2554f",
"timestamp": "0x6660737b",
"extraData": "0x000000000800000002",
"extraData": "0x01000000fa000000060000000000000000",
"baseFeePerGas": "0x0",
"blockHash": "0x34ab64f26982c9b253c9297ac35ac6e9b0dba34248bb080b25bf7e7d7169820b",
"blockHash": "0xad21ca5fc03aa0b1db32bd02f5e9b2c50a3dacfbaf80f71a1411cf334c36faa7",
"transactions": [
"0x7ef8f8a0de86bef815fc910df65a9459ccb2b9a35fa8596dfcfed1ff01bbf28891d86d5e94deaddeaddeaddeaddeaddeaddeaddeaddead00019442000000000000000000000000000000000000158080830f424080b8a4440a5e2000000558000c5fc50000000000000000000000006660735b00000000000001a9000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000017ae3f74f0134521a7d62a387ac75a5153bcd1aab1c7e003e9b9e15a5d8846363000000000000000000000000e25583099ba105d9ec0a67f5ae86d90e50036425",
"0x7ef858a000000000000000000000000000000000000000000000000000000000000000009488f9b82462f6c4bf4a0fb15e5c3971559a316e7f9488f9b82462f6c4bf4a0fb15e5c3971559a316e7f7b7b88ffffffffffffffff8080"
Expand Down
8 changes: 4 additions & 4 deletions api/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ pub mod tests {
},
umi_blockchain::{
block::{
BaseGasFee, Block, BlockRepository, Eip1559GasFee, Header, InMemoryBlockQueries,
InMemoryBlockRepository, UmiBlockHash,
BaseGasFee, Block, BlockRepository, Header, InMemoryBlockQueries,
InMemoryBlockRepository, JovianGasFee, UmiBlockHash,
},
in_memory::shared_memory,
payload::{InMemoryPayloadQueries, InProgressPayloads},
Expand Down Expand Up @@ -85,7 +85,7 @@ pub mod tests {
.into_extended_with_hash(head_hash)
.with_value(U256::ZERO);

let gas_fee = Eip1559GasFee::default();
let gas_fee = JovianGasFee::default();
genesis_block.block.header.extra_data = gas_fee.encode_parameters_for_header();

let size = genesis_block.byte_length(Vec::new());
Expand Down Expand Up @@ -303,7 +303,7 @@ pub mod tests {
Application::<TestDependencies<MockStateQueries>> {
genesis_config: GenesisConfig::default(),
mem_pool: Default::default(),
gas_fee: Eip1559GasFee::default(),
gas_fee: JovianGasFee::default(),
base_token: UmiBaseTokenAccounts::new(AccountAddress::ONE),
l1_fee: U256::ZERO,
l2_fee: U256::ZERO,
Expand Down
10 changes: 6 additions & 4 deletions api/src/methods/new_payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ mod tests {
umi_app::{Application, CommandActor, HybridBlockHashCache, TestDependencies},
umi_blockchain::{
block::{
Block, BlockRepository, Eip1559GasFee, ForkchoiceState, InMemoryBlockQueries,
InMemoryBlockRepository, UmiBlockHash,
Block, BlockRepository, ForkchoiceState, InMemoryBlockQueries,
InMemoryBlockRepository, JovianGasFee, UmiBlockHash,
},
in_memory::{SharedMemoryReader, shared_memory},
payload::{InMemoryPayloadQueries, InProgressPayloads},
Expand Down Expand Up @@ -439,7 +439,7 @@ mod tests {
let mut app = Application::<TestDependencies<_, _, _, _>> {
mem_pool: Default::default(),
genesis_config: genesis_config.clone(),
gas_fee: Eip1559GasFee::default(),
gas_fee: JovianGasFee::default(),
base_token: (),
l1_fee: U256::ZERO,
l2_fee: U256::ZERO,
Expand Down Expand Up @@ -489,7 +489,7 @@ mod tests {
_,
_,
InMemoryTransactionRepository,
Eip1559GasFee,
JovianGasFee,
U256,
U256,
>,
Expand Down Expand Up @@ -530,6 +530,8 @@ mod tests {
"transactions": [
"0x7ef8f8a0d449f5de7f558fa593dce80637d3a3f52cfaaee2913167371dd6ffd9014e431d94deaddeaddeaddeaddeaddeaddeaddeaddead00019442000000000000000000000000000000000000158080830f424080b8a4440a5e20000f424000000000000000000000000100000000666c9d8b0000000000000028000000000000000000000000000000000000000000000000000000000049165f0000000000000000000000000000000000000000000000000000000000000001d05450763214e6060d285b39ef5fe51ef9526395e5cef6ecb27ba06f9598f27d000000000000000000000000e25583099ba105d9ec0a67f5ae86d90e50036425"
],
"eip1559Params": "0x0000000000000000",
"minBaseFee": 0,
"gasLimit": "0x1c9c380"
}
]
Expand Down
8 changes: 7 additions & 1 deletion api/src/schema/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,13 @@ pub struct PayloadAttributesV3 {
pub parent_beacon_block_root: B256,
pub transactions: Vec<Bytes>,
pub gas_limit: U64,
pub eip1559_params: Option<U64>,
// Note: post-Holocene upgrade this is a required field.
// See https://specs.optimism.io/protocol/holocene/exec-engine.html
pub eip1559_params: U64,
pub no_tx_pool: Option<bool>,
// Note: post-Jovian upgrade this is a required field.
// See https://specs.optimism.io/protocol/jovian/exec-engine.html
pub min_base_fee: U64,
}

#[derive(Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
Expand Down Expand Up @@ -283,6 +288,7 @@ impl From<PayloadAttributesV3> for Payload {
gas_limit: value.gas_limit,
eip1559_params: value.eip1559_params,
no_tx_pool: value.no_tx_pool,
min_base_fee: value.min_base_fee.saturating_to(),
}
}
}
11 changes: 2 additions & 9 deletions app/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,8 @@ impl<'app, D: Dependencies<'app>> Application<'app, D> {
UnrecoverableAppFailure
})?;

if let Some(params) = &attributes.eip1559_params {
self.gas_fee.set_parameters_from_attrs(params);
} else {
self.gas_fee
.set_parameters_from_extra_data(parent.block.header.extra_data).map_err(|e| {
tracing::error!("Failure during `start_block_build`. Post-Isthmus parent block `extra_data` had wrong format: {e:?}");
UnrecoverableAppFailure
})?;
}
self.gas_fee
.set_parameters_from_attrs(&attributes.base_fee_params);
let base_fee = self.gas_fee.base_fee_per_gas(
parent.block.header.gas_limit,
parent.block.header.gas_used,
Expand Down
2 changes: 1 addition & 1 deletion app/src/dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ mod test_doubles {
ST = umi_evm_ext::state::InMemoryStorageTrieRepository,
TQ = umi_blockchain::transaction::InMemoryTransactionQueries,
TR = umi_blockchain::transaction::InMemoryTransactionRepository,
BF = umi_blockchain::block::Eip1559GasFee,
BF = umi_blockchain::block::JovianGasFee,
F1 = U256,
F2 = U256,
>(
Expand Down
28 changes: 13 additions & 15 deletions app/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use {
alloy::{primitives::Bloom, rlp::Decodable, rpc::types::engine::ForkchoiceState},
op_alloy::consensus::OpTxEnvelope,
umi_blockchain::{
block::{BaseFeeParameters, Header},
block::{BaseFeeParameters, EIP1559FeeParameters, Header},
payload::{NewPayloadIdInput, PayloadId},
},
umi_execution::transaction::{NormalizedEthTransaction, NormalizedExtendedTxEnvelope},
Expand All @@ -18,8 +18,9 @@ pub struct Payload {
pub parent_beacon_block_root: B256,
pub transactions: Vec<Bytes>,
pub gas_limit: U64,
pub eip1559_params: Option<U64>,
pub eip1559_params: U64,
pub no_tx_pool: Option<bool>,
pub min_base_fee: u64,
}

/// Internal representation of [`Payload`] that has its `transactions`
Expand All @@ -33,8 +34,8 @@ pub struct PayloadForExecution {
pub parent_beacon_block_root: B256,
pub transactions: Vec<NormalizedExtendedTxEnvelope>,
pub gas_limit: U64,
pub eip1559_params: Option<umi_blockchain::block::BaseFeeParameters>,
pub no_tx_pool: Option<bool>,
pub base_fee_params: umi_blockchain::block::BaseFeeParameters,
}

impl TryFrom<Payload> for PayloadForExecution {
Expand All @@ -49,10 +50,11 @@ impl TryFrom<Payload> for PayloadForExecution {
transactions.push(op_tx.try_into()?);
}

let parsed_params = value
.eip1559_params
.map(BaseFeeParameters::decode)
.transpose()?;
let eip1559_params = EIP1559FeeParameters::decode(value.eip1559_params)?;
let base_fee_params = BaseFeeParameters {
min_base_fee: value.min_base_fee,
eip1559_params,
};

Ok(Self {
timestamp: value.timestamp,
Expand All @@ -62,8 +64,8 @@ impl TryFrom<Payload> for PayloadForExecution {
parent_beacon_block_root: value.parent_beacon_block_root,
transactions,
gas_limit: value.gas_limit,
eip1559_params: parsed_params,
no_tx_pool: value.no_tx_pool,
base_fee_params,
})
}
}
Expand Down Expand Up @@ -129,7 +131,7 @@ pub trait ToPayloadIdInput<'a> {

impl<'a> ToPayloadIdInput<'a> for PayloadForExecution {
fn to_payload_id_input(&'a self, head: &'a B256) -> NewPayloadIdInput<'a> {
let mut input = NewPayloadIdInput::new_v3(
NewPayloadIdInput::new_v3(
head,
self.timestamp.into_limbs()[0],
&self.prev_randao,
Expand All @@ -143,12 +145,8 @@ impl<'a> ToPayloadIdInput<'a> for PayloadForExecution {
.map(ToWithdrawal::to_withdrawal)
.collect::<Vec<_>>(),
)
.with_transaction_hashes(self.transactions.iter().map(|tx| tx.tx_hash()));
if let Some(eip1559_params) = &self.eip1559_params {
input = input.with_eip1559_params(eip1559_params);
}

input
.with_transaction_hashes(self.transactions.iter().map(|tx| tx.tx_hash()))
.with_eip1559_params(&self.base_fee_params.eip1559_params)
}
}

Expand Down
11 changes: 2 additions & 9 deletions app/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ use {
},
move_table_extension::TableHandle,
umi_blockchain::{
block::{
BaseGasFee, BlockQueries, BlockResponse,
DEFAULT_EIP1559_BASE_FEE_MAX_CHANGE_DENOMINATOR, DEFAULT_EIP1559_ELASTICITY_MULTIPLIER,
Eip1559GasFee, ForkchoiceState,
},
block::{BaseGasFee, BlockQueries, BlockResponse, ForkchoiceState, JovianGasFee},
payload::{MaybePayloadResponse, PayloadId, PayloadQueries, PayloadResponse},
receipt::{ReceiptQueries, TransactionReceipt},
state::{
Expand Down Expand Up @@ -536,10 +532,7 @@ impl<'app, D: Dependencies<'app>> ApplicationReader<'app, D> {
// so that we also account for the range ending with the latest block. This comes before
// the remaining calculation as we're iterating in reverse
if matches!(block_id, FeeHistoryBlockId::RangeEnd(_)) {
let mut gas_fee = Eip1559GasFee::new(
DEFAULT_EIP1559_ELASTICITY_MULTIPLIER,
DEFAULT_EIP1559_BASE_FEE_MAX_CHANGE_DENOMINATOR,
);
let mut gas_fee = JovianGasFee::default();
gas_fee.set_parameters_from_extra_data(extra_data)?;
let next_block_base_fee = gas_fee.base_fee_per_gas(
gas_limit,
Expand Down
11 changes: 6 additions & 5 deletions app/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ use {
test_case::test_case,
umi_blockchain::{
block::{
BaseGasFee, Block, BlockHash, BlockRepository, Eip1559GasFee, ForkchoiceState, Header,
InMemoryBlockQueries, InMemoryBlockRepository, UmiBlockHash,
BaseGasFee, Block, BlockHash, BlockRepository, ForkchoiceState, Header,
InMemoryBlockQueries, InMemoryBlockRepository, JovianGasFee, UmiBlockHash,
},
in_memory::shared_memory,
payload::{InMemoryPayloadQueries, InProgressPayloads, MaybePayloadResponse},
Expand Down Expand Up @@ -162,7 +162,7 @@ fn create_app_with_given_queries<SQ: StateQueries + Clone + Send + Sync + 'stati
evm_storage,
transaction_queries: InMemoryTransactionQueries::new(),
transaction_repository: InMemoryTransactionRepository::new(),
gas_fee: Eip1559GasFee::default(),
gas_fee: JovianGasFee::default(),
l1_fee: U256::ZERO,
l2_fee: U256::ZERO,
resolver_cache: Default::default(),
Expand Down Expand Up @@ -224,7 +224,7 @@ fn create_app_with_fake_queries(
.with_value(U256::ZERO);
genesis_block.block.header.base_fee_per_gas = Some(base_fee);

let gas_fee = Eip1559GasFee::default();
let gas_fee = JovianGasFee::default();
genesis_block.block.header.extra_data = gas_fee.encode_parameters_for_header();

let (memory_reader, mut memory) = shared_memory::new();
Expand Down Expand Up @@ -343,8 +343,9 @@ fn test_build_block_hash() {
parent_beacon_block_root: Default::default(),
transactions: Vec::new(),
gas_limit: U64::from(0x1c9c380),
eip1559_params: Some(U64::from_be_slice(&hex!("000000fa00000006"))),
eip1559_params: U64::from_be_slice(&hex!("000000fa00000006")),
no_tx_pool: None,
min_base_fee: 0,
};

let execution_outcome = ExecutionOutcome {
Expand Down
6 changes: 3 additions & 3 deletions app/src/uninit.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use {
crate::{Application, Dependencies},
std::{collections::HashMap, sync::Arc},
umi_blockchain::{block::Eip1559GasFee, state::EthTrieStateQueries},
umi_blockchain::{block::JovianGasFee, state::EthTrieStateQueries},
umi_evm_ext::state::InMemoryDb,
umi_execution::U256,
umi_genesis::config::GenesisConfig,
Expand Down Expand Up @@ -34,7 +34,7 @@ impl<'app> Dependencies<'app> for Uninitialized {
type StorageTrieRepository = ();
type TransactionQueries = ();
type TransactionRepository = ();
type BaseGasFee = Eip1559GasFee;
type BaseGasFee = JovianGasFee;
type CreateL1GasFee = U256;
type CreateL2GasFee = U256;

Expand Down Expand Up @@ -99,7 +99,7 @@ impl<'app> Dependencies<'app> for Uninitialized {
fn transaction_repository() -> Self::TransactionRepository {}

fn base_gas_fee() -> Self::BaseGasFee {
Eip1559GasFee::default()
JovianGasFee::default()
}

fn create_l1_gas_fee() -> Self::CreateL1GasFee {
Expand Down
Loading