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

Post deploy blocks #16

Closed
wants to merge 6 commits into from
Closed
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
506 changes: 249 additions & 257 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ reth-transaction-pool = { path = "crates/transaction-pool" }
reth-trie = { path = "crates/trie" }

# revm
revm = { git = "https://github.com/telosnetwork/telos-revm", branch = "telos-main", features = ["std", "secp256k1", "telos"], default-features = false }
revm-primitives = { git = "https://github.com/telosnetwork/telos-revm", branch = "telos-main", features = ["std", "telos"], default-features = false }
revm = { git = "https://github.com/telosnetwork/telos-revm", branch = "telos-main", features = ["std", "secp256k1"], default-features = false }
revm-primitives = { git = "https://github.com/telosnetwork/telos-revm", branch = "telos-main", features = ["std"], default-features = false }
revm-inspectors = { git = "https://github.com/telosnetwork/telos-evm-inspectors", branch = "telos-main" }

# eth
Expand Down
10 changes: 10 additions & 0 deletions bin/reth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ telos = [
"reth-provider/telos",
"reth-consensus-common/telos",
"reth-stages/telos",
"reth-node-api/telos",
"reth-payload-builder/telos",
"reth-node-ethereum/telos",
"reth-basic-payload-builder/telos",
"reth-ethereum-payload-builder/telos",
"reth-optimism-payload-builder/telos",
"reth-revm/telos",
"reth-transaction-pool/telos",
"reth-trie/telos",
"reth-rpc-types-compat/telos"
]

[[bin]]
Expand Down
1 change: 1 addition & 0 deletions crates/blockchain-tree/src/blockchain_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,7 @@ impl<DB: Database, EVM: ExecutorFactory> BlockchainTree<DB, EVM> {
hash: *block_hash,
}),
)?;
#[cfg(not(feature = "telos"))]
if !self
.externals
.provider_factory
Expand Down
4 changes: 4 additions & 0 deletions crates/consensus/common/src/calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ pub fn base_block_reward(
block_difficulty: U256,
total_difficulty: U256,
) -> Option<u128> {
#[cfg(feature = "telos")]
if chain_spec.chain == Chain::from_id(40) || chain_spec.chain == Chain::from_id(41) {
return None
}
if chain_spec.chain == Chain::goerli() ||
chain_spec.fork(Hardfork::Paris).active_at_ttd(total_difficulty, block_difficulty)
{
Expand Down
6 changes: 6 additions & 0 deletions crates/node-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ revm.workspace = true

# io
serde.workspace = true

[features]
telos = [
"revm/telos",
"revm-primitives/telos",
]
12 changes: 10 additions & 2 deletions crates/node-core/src/args/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use reth_primitives::{BASE_MAINNET, BASE_SEPOLIA};
use reth_primitives::{DEV, GOERLI, HOLESKY, MAINNET, SEPOLIA};

#[cfg(feature = "telos")]
use reth_primitives::{TEVMMAINNET, TEVMTESTNET};
use reth_primitives::{TEVMMAINNET, TEVMTESTNET, TEVMMAINNET_BASE, TEVMTESTNET_BASE};

#[cfg(not(feature = "telos"))]
#[cfg(feature = "optimism")]
Expand All @@ -28,7 +28,7 @@ pub const SUPPORTED_CHAINS: &[&str] = &["base", "base-sepolia"];
pub const SUPPORTED_CHAINS: &[&str] = &["mainnet", "sepolia", "goerli", "holesky", "dev"];
#[cfg(feature = "telos")]
/// Chains supported by telos-reth
pub const SUPPORTED_CHAINS: &[&str] = &["tevmmainnet", "tevmtestnet"];
pub const SUPPORTED_CHAINS: &[&str] = &["tevmmainnet", "tevmtestnet", "tevmmainnet-base", "tevmtestnet-base"];

/// Helper to parse a [Duration] from seconds
pub fn parse_duration_from_secs(arg: &str) -> eyre::Result<Duration, std::num::ParseIntError> {
Expand All @@ -50,6 +50,10 @@ pub fn chain_spec_value_parser(s: &str) -> eyre::Result<Arc<ChainSpec>, eyre::Er
"tevmmainnet" => TEVMMAINNET.clone(),
#[cfg(feature = "telos")]
"tevmtestnet" => TEVMTESTNET.clone(),
#[cfg(feature = "telos")]
"tevmmainnet-base" => TEVMMAINNET_BASE.clone(),
#[cfg(feature = "telos")]
"tevmtestnet-base" => TEVMTESTNET_BASE.clone(),
#[cfg(not(feature = "optimism"))]
"holesky" => HOLESKY.clone(),
#[cfg(not(feature = "optimism"))]
Expand Down Expand Up @@ -87,6 +91,10 @@ pub fn genesis_value_parser(s: &str) -> eyre::Result<Arc<ChainSpec>, eyre::Error
"tevmmainnet" => TEVMMAINNET.clone(),
#[cfg(feature = "telos")]
"tevmtestnet" => TEVMTESTNET.clone(),
#[cfg(feature = "telos")]
"tevmmainnet-base" => TEVMMAINNET_BASE.clone(),
#[cfg(feature = "telos")]
"tevmtestnet-base" => TEVMTESTNET_BASE.clone(),
#[cfg(not(feature = "optimism"))]
"holesky" => HOLESKY.clone(),
#[cfg(not(feature = "optimism"))]
Expand Down
12 changes: 12 additions & 0 deletions crates/node-core/src/dirs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,5 +392,17 @@ mod tests {
let path = path.unwrap_or_chain_default(Chain::from_id(41));
assert!(path.as_ref().ends_with("reth/tevmtestnet"), "{:?}", path);
}

#[cfg(feature = "telos")] {
let path = MaybePlatformPath::<DataDirPath>::default();
let path = path.unwrap_or_chain_default(Chain::from_id(40));
assert!(path.as_ref().ends_with("reth/tevmmainnet-base"), "{:?}", path);
}

#[cfg(feature = "telos")] {
let path = MaybePlatformPath::<DataDirPath>::default();
let path = path.unwrap_or_chain_default(Chain::from_id(41));
assert!(path.as_ref().ends_with("reth/tevmtestnet-base"), "{:?}", path);
}
}
}
35 changes: 34 additions & 1 deletion crates/node-core/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ pub fn init_genesis<DB: Database>(

// insert sync stage
for stage in StageId::ALL.iter() {
#[cfg(feature = "telos")]
tx.put::<tables::SyncStage>(stage.to_string(), reth_primitives::stage::StageCheckpoint::new(genesis.number.unwrap_or_default()))?;
#[cfg(not(feature = "telos"))]
tx.put::<tables::SyncStage>(stage.to_string(), Default::default())?;
}

Expand Down Expand Up @@ -212,11 +215,20 @@ pub fn insert_genesis_header<DB: Database>(
) -> ProviderResult<()> {
let (header, block_hash) = chain.sealed_genesis_header().split();

#[cfg(feature = "telos")] {
tx.put::<tables::CanonicalHeaders>(header.number, block_hash)?;
tx.put::<tables::HeaderNumbers>(block_hash, header.number)?;
tx.put::<tables::BlockBodyIndices>(header.number, Default::default())?;
tx.put::<tables::HeaderTD>(header.number, header.difficulty.into())?;
tx.put::<tables::Headers>(header.number, header)?;
}
#[cfg(not(feature = "telos"))] {
tx.put::<tables::CanonicalHeaders>(0, block_hash)?;
tx.put::<tables::HeaderNumbers>(block_hash, 0)?;
tx.put::<tables::BlockBodyIndices>(0, Default::default())?;
tx.put::<tables::HeaderTD>(0, header.difficulty.into())?;
tx.put::<tables::Headers>(0, header)?;
}

Ok(())
}
Expand All @@ -237,7 +249,7 @@ mod tests {
};
#[cfg(feature = "telos")]
use reth_primitives::{
TEVMMAINNET, TEVMMAINNET_GENESIS_HASH, TEVMTESTNET, TEVMTESTNET_GENESIS_HASH
TEVMMAINNET, TEVMMAINNET_GENESIS_HASH, TEVMTESTNET, TEVMTESTNET_GENESIS_HASH, TEVMMAINNET_BASE, TEVMMAINNET_BASE_GENESIS_HASH, TEVMTESTNET_BASE, TEVMTESTNET_BASE_GENESIS_HASH
};

fn collect_table_entries<DB, T>(
Expand Down Expand Up @@ -297,6 +309,27 @@ mod tests {
assert_eq!(genesis_hash, TEVMTESTNET_GENESIS_HASH);
}


#[test]
#[cfg(feature = "telos")]
fn success_init_genesis_tevmmainnet_base() {
let db = create_test_rw_db();
let genesis_hash = init_genesis(db, TEVMMAINNET_BASE.clone()).unwrap();

// actual, expected
assert_eq!(genesis_hash, TEVMMAINNET_BASE_GENESIS_HASH);
}

#[test]
#[cfg(feature = "telos")]
fn success_init_genesis_tevmtestnet_base() {
let db = create_test_rw_db();
let genesis_hash = init_genesis(db, TEVMTESTNET_BASE.clone()).unwrap();

// actual, expected
assert_eq!(genesis_hash, TEVMTESTNET_BASE_GENESIS_HASH);
}

#[test]
fn fail_init_inconsistent_db() {
let db = create_test_rw_db();
Expand Down
5 changes: 4 additions & 1 deletion crates/node-ethereum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ reth-db.workspace = true
[features]
# This is a workaround for reth-cli crate to allow this as mandatory dependency without breaking the build even if unused.
# This makes managing features and testing workspace easier because clippy always builds all members if --workspace is provided
optimism = []
optimism = []
telos = [
"revm/telos",
]
7 changes: 6 additions & 1 deletion crates/payload/basic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ reth-metrics.workspace = true
metrics.workspace = true

# misc
tracing.workspace = true
tracing.workspace = true

[features]
telos = [
"revm/telos",
]
4 changes: 4 additions & 0 deletions crates/payload/builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,7 @@ optimism = [
"reth-interfaces/optimism",
"reth-transaction-pool/optimism",
]
telos = [
"revm/telos",
"revm-primitives/telos",
]
3 changes: 3 additions & 0 deletions crates/payload/ethereum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ tracing.workspace = true
# This is a workaround for reth-cli crate to allow this as mandatory dependency without breaking the build even if unused.
# This makes managing features and testing workspace easier because clippy always builds all members if --workspace is provided
optimism = []
telos = [
"revm/telos",
]
3 changes: 3 additions & 0 deletions crates/payload/optimism/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ optimism = [
"reth-provider/optimism",
"reth-payload-builder/optimism",
]
telos = [
"revm/telos",
]
5 changes: 4 additions & 1 deletion crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ optimism = [
"reth-ethereum-forks/optimism",
"revm/optimism",
]
telos = []
telos = [
"revm/telos",
"revm-primitives/telos",
]
test-utils = ["dep:plain_hasher", "dep:hash-db", "dep:ethers-core"]

[[bench]]
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/res/genesis/tevmmainnet.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"nonce": "0x00",
"nonce": "0x0",
"timestamp": "0x5c114972",
"extraData": "0x00000024796a9998ec49fb788de51614c57276dc6151bd2328305dba5d018897",
"gasLimit": "0x7fffffff",
Expand Down
13 changes: 13 additions & 0 deletions crates/primitives/res/genesis/tevmmainnet_base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"nonce": "0x0",
"timestamp": "0x61782354",
"extraData": "0x0ac53eebcfa1cf139272bf58540d6dc53f0d22785f9e3d74cb9bc333b597e1bf",
"gasLimit": "0x7fffffff",
"difficulty": "0x0",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"stateRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"number": "0xac53ec7",
"gasUsed": "0x0",
"parentHash": "0x87bb009caefe5447b3c4beafb6cc168d031a73eb9c6bb0718b5b5972448908c2"
}
2 changes: 1 addition & 1 deletion crates/primitives/res/genesis/tevmtestnet.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"nonce": "0x00",
"nonce": "0x0",
"timestamp": "0x5d55db93",
"extraData": "0x000000397128c497668c241b27d1521c764156cea50bcac87892fc8916e23b24",
"gasLimit": "0x7fffffff",
Expand Down
13 changes: 13 additions & 0 deletions crates/primitives/res/genesis/tevmtestnet_base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"nonce": "0x0",
"timestamp": "0x6170fef7",
"extraData": "0x0821345567cd66541778157d3936896f62a5b3fa134bb34d9708aa52f0c8c713",
"gasLimit": "0x7fffffff",
"difficulty": "0x0",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"stateRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"number": "0x821341c",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
2 changes: 1 addition & 1 deletion crates/primitives/src/chain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub use spec::{
MAINNET, SEPOLIA,
};
#[cfg(feature = "telos")]
pub use spec::{TEVMMAINNET, TEVMTESTNET};
pub use spec::{TEVMMAINNET, TEVMTESTNET, TEVMMAINNET_BASE, TEVMTESTNET_BASE};
#[cfg(feature = "optimism")]
pub use spec::{BASE_MAINNET, BASE_SEPOLIA};

Expand Down
Loading
Loading