Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
15ff007
feat: deposit tx
rkrasiuk Feb 26, 2023
28bfaaa
chainspec and forks
rkrasiuk Feb 26, 2023
c760918
feat: payload attributes op fields
rkrasiuk Feb 26, 2023
15be115
small fixes
refcell Feb 27, 2023
b761db0
Small changes to the deposit tx primitive
clabby Feb 27, 2023
968c2bf
more small fixes
refcell Feb 27, 2023
1c17ad8
compiles
refcell Feb 27, 2023
74cee5d
Move feature flags below comments
clabby Feb 27, 2023
bd71db3
Doc auto link
clabby Feb 27, 2023
ce41d79
WIP: OP Goerli genesis
clabby Mar 5, 2023
e803e07
Signature fix
clabby Mar 5, 2023
e53eb20
TEMP: Expose some CLI items
clabby Mar 19, 2023
98c173c
Resolve conflicts
clabby Mar 19, 2023
1bf2b08
Allow gaslimit to be set by the EngineAPI caller on OP
clabby Mar 19, 2023
8105ddd
Add Optimism EIP1559 elasticity multiplier / max base fee change deno…
clabby Mar 19, 2023
c99732f
feat: executor deposits
merklefruit Jun 11, 2023
6266b9f
feat: receipts, l1 cost wip
merklefruit Jun 11, 2023
0d793f8
chore: small fixes
merklefruit Jun 11, 2023
5b1b620
wip: transact() optimism changes
merklefruit Jun 12, 2023
2adfe43
chore: minor changes related to optimism execution
merklefruit Jun 12, 2023
891b841
wip: removed receipts changes + improved gas handling
merklefruit Jun 17, 2023
64df5ee
chore: cleanup
merklefruit Jun 18, 2023
f6d77a7
chore: system_tx and is_success method
merklefruit Jun 19, 2023
2cf460e
feat: refactoring: separated optimism feature + added routing fees to…
merklefruit Jun 20, 2023
3e2082c
fix: fee vault calc
merklefruit Jun 20, 2023
4960aaa
fix: increment balance via executor function
merklefruit Jun 20, 2023
db6d315
chore: minor fixes
merklefruit Jun 21, 2023
f9b1aa2
feat: parse l1 block info from l2 block
merklefruit Jun 28, 2023
49e54fb
chore: removed default trait
merklefruit Jun 28, 2023
759be83
chore: set deposit gas to 0 always
merklefruit Jun 29, 2023
5c93e35
Start resolving conflicts
clabby Jul 8, 2023
cb1c654
More conflict resolution / updates
clabby Jul 9, 2023
c4d38de
Reimplement @merklefruit's changes
clabby Jul 9, 2023
d701355
:broom:
clabby Jul 9, 2023
171b13b
chore: removed useless import
merklefruit Jul 9, 2023
59e9deb
fix build failures with optimism feature
roberto-bayardo Jul 19, 2023
2e56cbc
Fix feature flag
clabby Jul 19, 2023
d0670bf
Use TTD(0) fork condition for OP_GOERLI Paris hardfork
BrianBland Jul 17, 2023
f02996e
Merge pull request #17 from refcell/brianbland/fix-op-goerli-paris-fo…
clabby Jul 19, 2023
b615600
use the parameters from the optimism config in 1559 base fee computation
roberto-bayardo Jul 19, 2023
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ target/
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# Generated by VSCode
.vscode


# Generated by Intellij-based IDEs.
.idea
Expand Down
10 changes: 10 additions & 0 deletions bin/reth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ min-warn-logs = ["tracing/release_max_level_warn"]
min-info-logs = ["tracing/release_max_level_info"]
min-debug-logs = ["tracing/release_max_level_debug"]
min-trace-logs = ["tracing/release_max_level_trace"]
optimism = [
"reth-primitives/optimism",
"reth-revm/optimism",
"reth-interfaces/optimism",
"reth-rpc-engine-api/optimism",
"reth-transaction-pool/optimism",
"reth-provider/optimism",
"reth-beacon-consensus/optimism",
"reth-basic-payload-builder/optimism",
]

[build-dependencies]
vergen = { version = "8.0.0", features = ["build", "cargo", "git", "gitcl"] }
1 change: 1 addition & 0 deletions bin/reth/src/args/rpc_server_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ impl RpcServerArgs {
) -> Result<AuthServerHandle, RpcError>
where
Provider: BlockReaderIdExt
+ ChainSpecProvider
+ HeaderProvider
+ StateProviderFactory
+ EvmEnvProvider
Expand Down
2 changes: 2 additions & 0 deletions bin/reth/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ mod tests {
fork_timestamps: ForkTimestamps { shanghai: None },
genesis_hash: None,
paris_block_and_final_difficulty: None,
#[cfg(feature = "optimism")]
optimism: None,
});

let db = create_test_rw_db();
Expand Down
11 changes: 7 additions & 4 deletions crates/consensus/auto-seal/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,13 @@ where
let mut storage = storage.write().await;

// check previous block for base fee
let base_fee_per_gas = storage
.headers
.get(&storage.best_block)
.and_then(|parent| parent.next_block_base_fee());
let base_fee_per_gas =
storage.headers.get(&storage.best_block).and_then(|parent| {
parent.next_block_base_fee(
chain_spec.elasticity_multiplier(),
chain_spec.base_fee_change_denominator(),
)
});

let mut header = Header {
parent_hash: storage.best_hash,
Expand Down
9 changes: 9 additions & 0 deletions crates/consensus/beacon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,12 @@ reth-revm = { path = "../../revm" }
reth-downloaders = { path = "../../net/downloaders" }

assert_matches = "1.5"

[features]
optimism = [
"reth-consensus-common/optimism",
"reth-primitives/optimism",
"reth-interfaces/optimism",
"reth-provider/optimism",
"reth-rpc-types/optimism",
]
3 changes: 3 additions & 0 deletions crates/consensus/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ reth-interfaces = { workspace = true, features = ["test-utils"] }
reth-provider = { workspace = true, features = ["test-utils"] }
assert_matches = "1.5.0"
mockall = "0.11.3"

[features]
optimism = ["reth-primitives/optimism"]
47 changes: 31 additions & 16 deletions crates/consensus/common/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ use std::{
time::SystemTime,
};

#[cfg(feature = "optimism")]
use reth_primitives::TxDeposit;

/// Validate header standalone
pub fn validate_header_standalone(
header: &SealedHeader,
Expand Down Expand Up @@ -99,6 +102,8 @@ pub fn validate_transaction_regarding_header(

Some(*chain_id)
}
#[cfg(feature = "optimism")]
Transaction::Deposit(TxDeposit { .. }) => None,
};
if let Some(chain_id) = chain_id {
if chain_id != chain_spec.chain().id() {
Expand Down Expand Up @@ -265,27 +270,32 @@ pub fn validate_header_regarding_parent(
// TODO Check difficulty increment between parent and child
// Ace age did increment it by some formula that we need to follow.

let mut parent_gas_limit = parent.gas_limit;
// Check gas limit, max diff between child/parent gas_limit should be max_diff=parent_gas/1024
// On Optimism, the gas limit can adjust instantly, so we skip this check if the optimism
// feature flag is enabled.
#[cfg(not(feature = "optimism"))]
{
let mut parent_gas_limit = parent.gas_limit;

// By consensus, gas_limit is multiplied by elasticity (*2) on
// on exact block that hardfork happens.
if chain_spec.fork(Hardfork::London).transitions_at_block(child.number) {
parent_gas_limit = parent.gas_limit * constants::EIP1559_ELASTICITY_MULTIPLIER;
}
// By consensus, gas_limit is multiplied by elasticity (*2) on
// on exact block that hardfork happens.
if chain_spec.fork(Hardfork::London).transitions_at_block(child.number) {
parent_gas_limit = parent.gas_limit * constants::EIP1559_ELASTICITY_MULTIPLIER;
}

// Check gas limit, max diff between child/parent gas_limit should be max_diff=parent_gas/1024
if child.gas_limit > parent_gas_limit {
if child.gas_limit - parent_gas_limit >= parent_gas_limit / 1024 {
return Err(ConsensusError::GasLimitInvalidIncrease {
if child.gas_limit > parent_gas_limit {
if child.gas_limit - parent_gas_limit >= parent_gas_limit / 1024 {
return Err(ConsensusError::GasLimitInvalidIncrease {
parent_gas_limit,
child_gas_limit: child.gas_limit,
})
}
} else if parent_gas_limit - child.gas_limit >= parent_gas_limit / 1024 {
return Err(ConsensusError::GasLimitInvalidDecrease {
parent_gas_limit,
child_gas_limit: child.gas_limit,
})
}
} else if parent_gas_limit - child.gas_limit >= parent_gas_limit / 1024 {
return Err(ConsensusError::GasLimitInvalidDecrease {
parent_gas_limit,
child_gas_limit: child.gas_limit,
})
}

// EIP-1559 check base fee
Expand All @@ -297,7 +307,12 @@ pub fn validate_header_regarding_parent(
constants::EIP1559_INITIAL_BASE_FEE
} else {
// This BaseFeeMissing will not happen as previous blocks are checked to have them.
parent.next_block_base_fee().ok_or(ConsensusError::BaseFeeMissing)?
parent
.next_block_base_fee(
chain_spec.base_fee_change_denominator(),
chain_spec.elasticity_multiplier(),
)
.ok_or(ConsensusError::BaseFeeMissing)?
};
if expected_base_fee != base_fee {
return Err(ConsensusError::BaseFeeDiff { expected: expected_base_fee, got: base_fee })
Expand Down
3 changes: 2 additions & 1 deletion crates/interfaces/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ secp256k1 = { workspace = true, features = [

[features]
test-utils = ["tokio-stream/sync", "secp256k1", "rand/std_rng"]
cli = ["clap"]
cli = ["clap"]
optimism = ["reth-eth-wire/optimism"]
3 changes: 3 additions & 0 deletions crates/interfaces/src/blockchain_tree/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ impl InsertBlockErrorKind {
BlockExecutionError::BlockHashNotFoundInChain { .. } |
BlockExecutionError::AppendChainDoesntConnect { .. } |
BlockExecutionError::UnavailableForTest => false,
#[cfg(feature = "optimism")]
BlockExecutionError::L1BlockInfoError { .. } |
BlockExecutionError::InsufficientFundsForL1Cost { .. } => false,
}
}
InsertBlockErrorKind::Tree(err) => {
Expand Down
8 changes: 7 additions & 1 deletion crates/interfaces/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ pub enum BlockExecutionError {
CanonicalRevert { inner: String },
#[error("Transaction error on commit: {inner:?}")]
CanonicalCommit { inner: String },

// === tree errors ===
// TODO(mattsse): move this to tree error
#[error("Block hash {block_hash} not found in blockchain tree chain")]
Expand All @@ -57,6 +56,13 @@ pub enum BlockExecutionError {
/// Note: this is not feature gated for convenience.
#[error("Execution unavailable for tests")]
UnavailableForTest,

#[cfg(feature = "optimism")]
#[error("Could not get L1 block info from L2 block: {message:?}")]
L1BlockInfoError { message: String },
#[cfg(feature = "optimism")]
#[error("Insufficient funds to cover transaction L1 cost: want {want}, have {have}")]
InsufficientFundsForL1Cost { want: u64, have: u64 },
}

impl BlockExecutionError {
Expand Down
2 changes: 2 additions & 0 deletions crates/interfaces/src/test_utils/generators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ pub fn random_receipt<R: Rng>(
} else {
vec![]
},
#[cfg(feature = "optimism")]
deposit_nonce: None,
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/net/eth-wire/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ proptest-derive = "0.3"
default = ["serde"]
serde = ["dep:serde", "smol_str/serde"]
arbitrary = ["reth-primitives/arbitrary", "dep:arbitrary", "dep:proptest", "dep:proptest-derive"]
optimism = []

[[test]]
name = "fuzz_roundtrip"
Expand Down
22 changes: 14 additions & 8 deletions crates/net/eth-wire/src/types/receipts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ mod test {
success: false,
cumulative_gas_used: 0,
logs: vec![],
#[cfg(feature = "optimism")]
deposit_nonce: None,
},
bloom: Default::default(),
}]]);
Expand Down Expand Up @@ -102,10 +104,10 @@ mod test {
let mut data = vec![];
let request = RequestPair::<Receipts> {
request_id: 1111,
message: Receipts(vec![
vec![
ReceiptWithBloom {
receipt: Receipt {tx_type: TxType::Legacy,
message: Receipts(vec![vec![
ReceiptWithBloom {
receipt: Receipt {
tx_type: TxType::Legacy,
cumulative_gas_used: 0x1u64,
logs: vec![
Log {
Expand All @@ -118,10 +120,12 @@ mod test {
},
],
success: false,
},bloom: hex!("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").into(),
}
],
]),
#[cfg(feature = "optimism")]
deposit_nonce: None,
},
bloom: hex!("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").into(),
},
]]),
};
request.encode(&mut data);
assert_eq!(data, expected);
Expand Down Expand Up @@ -153,6 +157,8 @@ mod test {
},
],
success: false,
#[cfg(feature = "optimism")]
deposit_nonce: None,
},
bloom: hex!("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").into(),
},
Expand Down
8 changes: 8 additions & 0 deletions crates/payload/basic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ futures-util = { workspace = true }

## misc
tracing = { workspace = true }

[features]
optimism = [
"reth-primitives/optimism",
"reth-revm/optimism",
"reth-transaction-pool/optimism",
"reth-provider/optimism"
]
2 changes: 2 additions & 0 deletions crates/payload/basic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,8 @@ fn build_payload<Pool, Client>(
success: result.is_success(),
cumulative_gas_used,
logs: result.logs().into_iter().map(into_reth_log).collect(),
#[cfg(feature = "optimism")]
deposit_nonce: None,
},
);

Expand Down
6 changes: 6 additions & 0 deletions crates/payload/builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@ tracing = { workspace = true }

[features]
test-utils = []
optimism = [
"reth-primitives/optimism",
"reth-rpc-types/optimism",
"reth-interfaces/optimism",
"reth-revm-primitives/optimism",
]
9 changes: 8 additions & 1 deletion crates/payload/builder/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,14 @@ impl PayloadBuilderAttributes {
prevrandao: Some(self.prev_randao),
gas_limit: U256::from(parent.gas_limit),
// calculate basefee based on parent block's gas usage
basefee: U256::from(parent.next_block_base_fee().unwrap_or_default()),
basefee: U256::from(
parent
.next_block_base_fee(
chain_spec.base_fee_change_denominator(),
chain_spec.elasticity_multiplier(),
)
.unwrap_or_default(),
),
};

(cfg, block_env)
Expand Down
1 change: 1 addition & 0 deletions crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ pprof = { version = "0.12", features = ["flamegraph", "frame-pointer", "criterio
default = []
arbitrary = ["revm-primitives/arbitrary", "dep:arbitrary", "dep:proptest", "dep:proptest-derive"]
test-utils = []
optimism = []

[[bench]]
name = "recover_ecdsa_crit"
Expand Down
Loading