Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] v1.0.0 rc.2 taiko #6

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ccb9141
test raiko integration
Brechtpd May 14, 2024
7509ce5
small changes to allow raiko to use reth for proving
Brechtpd May 22, 2024
fbd1411
basic taiko support
Brechtpd May 31, 2024
33fa264
better invalid tx support
Brechtpd Jun 9, 2024
527c342
added full verification of taiko blocks
Brechtpd Jun 14, 2024
8f4da6b
Merge branch 'v1.0.0-rc.2' into raiko-integration
Brechtpd Jun 24, 2024
8f96ef5
disable problematic packages for zkVM
Brechtpd Jun 24, 2024
7d4b05e
disable mdbx by default (specifically requires clang)
Brechtpd Jun 24, 2024
3e6a095
actually disable mdbx correctly
Brechtpd Jun 24, 2024
5248ce8
cleanup diff
Brechtpd Jun 25, 2024
d20c700
undo useless enr package import change
Brechtpd Jun 25, 2024
c73555d
reexport some more packages
Brechtpd Jun 30, 2024
3043c66
support block validation for raiko
Brechtpd Jul 2, 2024
2f655b7
add taiko_dev chain spec
smtmfft Jul 21, 2024
6cc82cf
Merge pull request #25 from taikoxyz/dev-chain-spec
smtmfft Jul 22, 2024
80f3c0b
prepare for ontake upgrade
smtmfft Jul 25, 2024
bf329f4
config fork & add new anchor logic
smtmfft Jul 31, 2024
2535a5d
update anchor def
smtmfft Aug 6, 2024
70c1bab
sync with protocol change
smtmfft Aug 8, 2024
d2598b8
minor refine
smtmfft Aug 9, 2024
2039f41
update cargo lock
smtmfft Aug 10, 2024
919aaf5
Update crates/ethereum-forks/src/hardfork.rs
smtmfft Aug 14, 2024
eaf942a
revert pure fmt change
smtmfft Aug 15, 2024
ba41ea6
switch back to v36-taiko revm
smtmfft Aug 15, 2024
018d2a6
keep reverting fmt changes
smtmfft Aug 16, 2024
910b6f1
Merge pull request #27 from taikoxyz/v1.0.0-rc.2-taiko-ontake
smtmfft Aug 16, 2024
dc49a94
sync anchorV2 structure with taiko-mono
smtmfft Aug 31, 2024
7677f83
Merge pull request #38 from taikoxyz/v1.0.0-rc.2-taiko-ontake
smtmfft Sep 5, 2024
83e3f6a
feat(chainspec): read ontake fork height from env
petarvujovic98 Sep 6, 2024
2808a0e
feat(chainspec): read ontake fork height for all taiko chains
petarvujovic98 Sep 6, 2024
9018d3b
fix(chainspec): revert formatting
petarvujovic98 Sep 9, 2024
17645de
Update crates/chainspec/src/spec.rs
smtmfft Sep 9, 2024
df7e2e6
Update crates/chainspec/src/spec.rs
smtmfft Sep 9, 2024
d967f74
Merge pull request #40 from taikoxyz/ontake-fork-from-env-raiko
smtmfft Sep 9, 2024
a0761f6
fix hekla ontake fork height
smtmfft Sep 11, 2024
d1165aa
Merge pull request #41 from taikoxyz/v1.0.0-rc.2-taiko-ontake
smtmfft Sep 11, 2024
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
23 changes: 19 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ revm = { version = "9.0.0", features = [
revm-primitives = { version = "4.0.0", features = [
"std",
], default-features = false }
revm-precompile = { version = "7.0.0", features = [
"std",
], default-features = false }
revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors", rev = "4fe17f0" }

# eth
Expand Down Expand Up @@ -425,6 +428,7 @@ sha2 = { version = "0.10", default-features = false }
paste = "1.0"
url = "2.3"
backon = "0.4"
lazy_static = "1.4.0"

# metrics
metrics = "0.22.0"
Expand Down Expand Up @@ -499,8 +503,19 @@ serial_test = "3"
similar-asserts = "1.5.0"
test-fuzz = "5"

# raiko
raiko-core = { git = "https://github.com/taikoxyz/raiko.git", branch = "reth-wip" }
raiko-lib = { git = "https://github.com/taikoxyz/raiko.git", branch = "reth-wip" }
anyhow = "1.0"

[patch.crates-io]
revm = { git = "https://github.com/bluealloy/revm.git", rev = "41e2f7f" }
revm-interpreter = { git = "https://github.com/bluealloy/revm.git", rev = "41e2f7f" }
revm-precompile = { git = "https://github.com/bluealloy/revm.git", rev = "41e2f7f" }
revm-primitives = { git = "https://github.com/bluealloy/revm.git", rev = "41e2f7f" }
revm = { git = "https://github.com/taikoxyz/revm.git", branch = "v36-taiko", default-features = false, features = [
"std",
"serde",
"taiko",
]}
revm-interpreter = { git = "https://github.com/taikoxyz/revm.git", branch = "v36-taiko" }
revm-precompile = { git = "https://github.com/taikoxyz/revm.git", branch = "v36-taiko" }
revm-primitives = { git = "https://github.com/taikoxyz/revm.git", branch = "v36-taiko"}
c-kzg = { git = "https://github.com/brechtpd/c-kzg-4844", branch = "for-alpha7" }
secp256k1 = { git = "https://github.com/CeciliaZ030/rust-secp256k1", branch = "sp1-patch" }
5 changes: 2 additions & 3 deletions crates/chainspec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ workspace = true
[dependencies]
# reth
reth-ethereum-forks.workspace = true
reth-network-peers.workspace = true
reth-network-peers = { workspace = true, optional = true }
reth-trie-common.workspace = true
reth-primitives-traits.workspace = true

Expand Down Expand Up @@ -49,5 +49,4 @@ std = []
arbitrary = [
"alloy-chains/arbitrary"
]


network = ["reth-network-peers"]
3 changes: 2 additions & 1 deletion crates/chainspec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub use alloy_chains::{Chain, ChainKind, NamedChain};
pub use info::ChainInfo;
pub use spec::{
AllGenesisFormats, BaseFeeParams, BaseFeeParamsKind, ChainSpec, ChainSpecBuilder,
DepositContract, ForkBaseFeeParams, DEV, GOERLI, HOLESKY, MAINNET, SEPOLIA,
DepositContract, ForkBaseFeeParams, DEV, GOERLI, HOLESKY, MAINNET, SEPOLIA, TAIKO_A7, TAIKO_MAINNET,
};
#[cfg(feature = "optimism")]
pub use spec::{BASE_MAINNET, BASE_SEPOLIA, OP_MAINNET, OP_SEPOLIA};
Expand All @@ -22,6 +22,7 @@ pub use spec::{BASE_MAINNET, BASE_SEPOLIA, OP_MAINNET, OP_SEPOLIA};
/// The chain info module.
mod info;

#[cfg(feature = "network")]
/// Network related constants
pub mod net;

Expand Down
74 changes: 74 additions & 0 deletions crates/chainspec/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use once_cell::sync::Lazy;
use reth_ethereum_forks::{
DisplayHardforks, ForkCondition, ForkFilter, ForkFilterKey, ForkHash, ForkId, Hardfork, Head,
};
#[cfg(feature = "network")]
use reth_network_peers::NodeRecord;
use reth_primitives_traits::{
constants::{
Expand All @@ -38,6 +39,7 @@ pub use alloy_eips::eip1559::BaseFeeParams;

#[cfg(feature = "optimism")]
use crate::net::{base_nodes, base_testnet_nodes, op_nodes, op_testnet_nodes};
#[cfg(feature = "network")]
use crate::net::{goerli_nodes, holesky_nodes, mainnet_nodes, sepolia_nodes};

/// The Ethereum mainnet spec
Expand Down Expand Up @@ -91,6 +93,70 @@ pub static MAINNET: Lazy<Arc<ChainSpec>> = Lazy::new(|| {
.into()
});

/// The Taiko A7 spec
pub static TAIKO_A7: Lazy<Arc<ChainSpec>> = Lazy::new(|| {
ChainSpec {
chain: 167009.into(),
genesis: serde_json::from_str(include_str!("../res/genesis/mainnet.json"))
.expect("Can't deserialize Mainnet genesis json"),
genesis_hash: None,
paris_block_and_final_difficulty: None,
hardforks: BTreeMap::from([
(Hardfork::Frontier, ForkCondition::Block(0)),
(Hardfork::Homestead, ForkCondition::Block(0)),
(Hardfork::Dao, ForkCondition::Block(0)),
(Hardfork::Tangerine, ForkCondition::Block(0)),
(Hardfork::SpuriousDragon, ForkCondition::Block(0)),
(Hardfork::Byzantium, ForkCondition::Block(0)),
(Hardfork::Constantinople, ForkCondition::Block(0)),
(Hardfork::Petersburg, ForkCondition::Block(0)),
(Hardfork::Istanbul, ForkCondition::Block(1561651)),
(Hardfork::Berlin, ForkCondition::Block(4460644)),
(Hardfork::London, ForkCondition::Block(5062605)),
(
Hardfork::Paris,
ForkCondition::TTD { fork_block: None, total_difficulty: U256::from(0) },
),
(Hardfork::Shanghai, ForkCondition::Timestamp(0)),
]),
deposit_contract: None,
..Default::default()
}
.into()
});

/// The Taiko Mainnet spec
pub static TAIKO_MAINNET: Lazy<Arc<ChainSpec>> = Lazy::new(|| {
ChainSpec {
chain: 167000.into(),
genesis: serde_json::from_str(include_str!("../res/genesis/mainnet.json"))
.expect("Can't deserialize Mainnet genesis json"),
genesis_hash: None,
paris_block_and_final_difficulty: None,
hardforks: BTreeMap::from([
(Hardfork::Frontier, ForkCondition::Block(0)),
(Hardfork::Homestead, ForkCondition::Block(0)),
(Hardfork::Dao, ForkCondition::Block(0)),
(Hardfork::Tangerine, ForkCondition::Block(0)),
(Hardfork::SpuriousDragon, ForkCondition::Block(0)),
(Hardfork::Byzantium, ForkCondition::Block(0)),
(Hardfork::Constantinople, ForkCondition::Block(0)),
(Hardfork::Petersburg, ForkCondition::Block(0)),
(Hardfork::Istanbul, ForkCondition::Block(1561651)),
(Hardfork::Berlin, ForkCondition::Block(4460644)),
(Hardfork::London, ForkCondition::Block(5062605)),
(
Hardfork::Paris,
ForkCondition::TTD { fork_block: None, total_difficulty: U256::from(0) },
),
(Hardfork::Shanghai, ForkCondition::Timestamp(0)),
]),
deposit_contract: None,
..Default::default()
}
.into()
});

/// The Goerli spec
pub static GOERLI: Lazy<Arc<ChainSpec>> = Lazy::new(|| {
ChainSpec {
Expand Down Expand Up @@ -594,6 +660,13 @@ impl ChainSpec {
self.chain.is_optimism()
}

/// Returns `true` if this is a Taiko chain.
#[inline]
pub fn is_taiko(&self) -> bool {
let id = self.chain.id();
id >= 167000 && id <= 168000
}

/// Returns `true` if this chain is Optimism mainnet.
#[inline]
pub fn is_optimism_mainnet(&self) -> bool {
Expand Down Expand Up @@ -990,6 +1063,7 @@ impl ChainSpec {
ChainSpecBuilder::default()
}

#[cfg(feature = "network")]
/// Returns the known bootnode records for the given chain.
pub fn bootnodes(&self) -> Option<Vec<NodeRecord>> {
use NamedChain as C;
Expand Down
15 changes: 15 additions & 0 deletions crates/consensus/common/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,21 @@ pub fn validate_against_parent_timestamp(
Ok(())
}

/// Validates the timestamp against the parent to make sure it is in the past or present.
#[inline]
pub fn validate_against_parent_timestamp_inclusive(
header: &SealedHeader,
parent: &SealedHeader,
) -> Result<(), ConsensusError> {
if header.is_timestamp_in_past_inclusive(parent.timestamp) {
return Err(ConsensusError::TimestampIsInPast {
parent_timestamp: parent.timestamp,
timestamp: header.timestamp,
})
}
Ok(())
}

/// Validates that the EIP-4844 header fields are correct with respect to the parent block. This
/// ensures that the `blob_gas_used` and `excess_blob_gas` fields exist in the child header, and
/// that the `excess_blob_gas` field matches the expected `excess_blob_gas` calculated from the
Expand Down
18 changes: 11 additions & 7 deletions crates/ethereum/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use reth_consensus::{Consensus, ConsensusError, PostExecutionInput};
use reth_consensus_common::validation::{
validate_4844_header_standalone, validate_against_parent_4844,
validate_against_parent_eip1559_base_fee, validate_against_parent_hash_number,
validate_against_parent_timestamp, validate_block_pre_execution, validate_header_base_fee,
validate_header_extradata, validate_header_gas,
validate_against_parent_timestamp, validate_against_parent_timestamp_inclusive,
validate_block_pre_execution, validate_header_base_fee, validate_header_extradata, validate_header_gas
};
use reth_primitives::{
constants::MINIMUM_GAS_LIMIT, BlockWithSenders, Header, SealedBlock, SealedHeader,
Expand Down Expand Up @@ -130,13 +130,17 @@ impl Consensus for EthBeaconConsensus {
) -> Result<(), ConsensusError> {
validate_against_parent_hash_number(header, parent)?;

validate_against_parent_timestamp(header, parent)?;
if self.chain_spec.is_taiko() {
validate_against_parent_timestamp_inclusive(header, parent)?;
} else {
validate_against_parent_timestamp(header, parent)?;

// TODO Check difficulty increment between parent and self
// Ace age did increment it by some formula that we need to follow.
self.validate_against_parent_gas_limit(header, parent)?;
// TODO Check difficulty increment between parent and self
// Ace age did increment it by some formula that we need to follow.
self.validate_against_parent_gas_limit(header, parent)?;

validate_against_parent_eip1559_base_fee(header, parent, &self.chain_spec)?;
validate_against_parent_eip1559_base_fee(header, parent, &self.chain_spec)?;
}

// ensure that the blob gas fields for this block
if self.chain_spec.is_cancun_active_at_timestamp(header.timestamp) {
Expand Down
6 changes: 5 additions & 1 deletion crates/ethereum/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ reth-chainspec.workspace = true
reth-evm.workspace = true
reth-primitives.workspace = true
reth-revm.workspace = true
reth-consensus.workspace = true
reth-ethereum-consensus.workspace = true
reth-prune-types.workspace = true
reth-execution-types.workspace = true
Expand All @@ -27,9 +28,12 @@ revm-primitives.workspace = true
alloy-eips.workspace = true
alloy-sol-types.workspace = true

# Misc
lazy_static.workspace = true
anyhow.workspace = true

[dev-dependencies]
reth-testing-utils.workspace = true
reth-revm = { workspace = true, features = ["test-utils"] }
secp256k1.workspace = true
serde_json.workspace = true

Loading
Loading