Skip to content

Commit 2f2602a

Browse files
authored
Shasta e2e test (#765)
* wait for bach adopted to shasta, fixed test_propose_batch_to_l1_after_reaching_max_blocks_per_batch test * taiko inbox bindings used from the taiko-client-rs * Revert "taiko inbox bindings used from the taiko-client-rs" This reverts commit af631d0. * verification of proposal payload parameters * fixed test_forced_inclusion test for shasta * forced inclusion chain info works * Reapply "taiko inbox bindings used from the taiko-client-rs" This reverts commit d6da551. * Update to new taiko main branch * v1.23.28 * Update FI tests to new taiko bindings * protocol env variable for shasta * unneeded url conversion
1 parent 9525e3b commit 2f2602a

17 files changed

+292
-238
lines changed

Cargo.lock

Lines changed: 38 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ resolver = "2"
1212
default-members = ["node"]
1313

1414
[workspace.package]
15-
version = "1.23.27"
15+
version = "1.23.28"
1616
edition = "2024"
1717
repository = "https://github.com/NethermindEth/Catalyst"
1818
license = "MIT"
@@ -80,9 +80,9 @@ shasta = { path = "shasta" }
8080
strum = { version = "0.27", features = ["derive"] }
8181

8282
taiko_alethia_reth = { git = "https://github.com/taikoxyz/alethia-reth.git", rev = "e07c13fc011798adfa5436f24646b7305337cdf3", package = "alethia-reth-consensus" }
83-
taiko_bindings = { git = "https://github.com/taikoxyz/taiko-mono.git", rev = "4a495188afbdbddf41457d440762b89023b32d84", package = "bindings" }
84-
taiko_protocol = { git = "https://github.com/taikoxyz/taiko-mono.git", rev = "4a495188afbdbddf41457d440762b89023b32d84", package = "protocol" }
85-
taiko_rpc = { git = "https://github.com/taikoxyz/taiko-mono.git", rev = "4a495188afbdbddf41457d440762b89023b32d84", package = "rpc" }
83+
taiko_bindings = { git = "https://github.com/taikoxyz/taiko-mono.git", rev = "d8741f16b36db30c200b1592310c3d85b625a16c", package = "bindings" }
84+
taiko_protocol = { git = "https://github.com/taikoxyz/taiko-mono.git", rev = "d8741f16b36db30c200b1592310c3d85b625a16c", package = "protocol" }
85+
taiko_rpc = { git = "https://github.com/taikoxyz/taiko-mono.git", rev = "d8741f16b36db30c200b1592310c3d85b625a16c", package = "rpc" }
8686
tiny-keccak = { version = "2.0", default-features = false }
8787
tokio = { version = "1.45", default-features = false, features = ["full"] }
8888
tokio-util = { version = "0.7", default-features = false }

e2e_tests/.env.example

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ L2_PRIVATE_KEY=53321db7c1e331d93a11a41d16f004d7ff63972ec8ec7c25db329728ceeb1710
2525
FORCED_INCLUSION_STORE_ADDRESS=0xc5092f6c1f30C8970dc835F0F754057f79b89CC6
2626

2727
MAX_BLOCKS_PER_BATCH=10
28-
PRECONF_HEARTBEAT_MS=2000
28+
PRECONF_HEARTBEAT_MS=2000
29+
30+
PROTOCOL=pacaya

e2e_tests/chain_info.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ class ChainInfo:
1313
block_hash: HexBytes
1414

1515
@classmethod
16-
def from_chain(cls, fi_account_address, l2_client_node1, l1_client, taiko_inbox_address, beacon_client, verbose: bool = True):
16+
def from_chain(cls, fi_account_address, l2_client_node1, l1_client, env_vars, beacon_client, verbose: bool = True):
1717
"""Create ChainInfo instance from current chain state"""
1818
fi_sender_nonce = l2_client_node1.eth.get_transaction_count(fi_account_address)
19-
batch_id = get_last_batch_id(l1_client, taiko_inbox_address)
19+
batch_id = get_last_batch_id(l1_client, env_vars)
2020
block_number = l2_client_node1.eth.block_number
2121
block_hash = l2_client_node1.eth.get_block(block_number).hash
2222

e2e_tests/conftest.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
from eth_account import Account
55
import os
66
from dotenv import load_dotenv
7-
from utils import ensure_catalyst_node_running, spam_n_blocks
8-
from forced_inclusion_store import forced_inclusion_store_is_empty, check_empty_forced_inclusion_store
7+
from utils import ensure_catalyst_node_running, spam_n_blocks, forced_inclusion_store_is_empty, check_empty_forced_inclusion_store
98
from dataclasses import dataclass
109
from taiko_inbox import get_last_block_id
1110

@@ -23,6 +22,7 @@ class EnvVars:
2322
preconf_heartbeat_ms: int
2423
l2_private_key: str
2524
max_blocks_per_batch: int
25+
protocol: str
2626

2727
@classmethod
2828
def from_env(cls):
@@ -64,6 +64,10 @@ def from_env(cls):
6464
if not max_blocks_per_batch:
6565
raise Exception("Environment variable MAX_BLOCKS_PER_BATCH not set")
6666

67+
protocol = os.getenv("PROTOCOL")
68+
if not protocol:
69+
raise Exception("Environment variable PROTOCOL not set")
70+
6771
return cls(
6872
l2_prefunded_priv_key=l2_prefunded_priv_key,
6973
l2_prefunded_priv_key_2=l2_prefunded_priv_key_2,
@@ -74,8 +78,15 @@ def from_env(cls):
7478
preconf_heartbeat_ms=preconf_heartbeat_ms,
7579
l2_private_key=l2_private_key,
7680
max_blocks_per_batch=max_blocks_per_batch,
81+
protocol=protocol,
7782
)
7883

84+
def is_shasta(self):
85+
return self.protocol == "shasta"
86+
87+
def is_pacaya(self):
88+
return self.protocol == "pacaya"
89+
7990
@pytest.fixture(scope="session")
8091
def env_vars():
8192
"""Centralized environment variables fixture"""
@@ -124,13 +135,18 @@ def forced_inclusion_teardown(l1_client, l2_client_node1, env_vars):
124135
"""Fixture to ensure forced inclusion store is empty after test"""
125136
yield None
126137
print("Test teardown: ensuring forced inclusion store is empty")
127-
if not forced_inclusion_store_is_empty(l1_client, env_vars.forced_inclusion_store_address):
138+
if not forced_inclusion_store_is_empty(l1_client, env_vars):
128139
print("Spamming blocks to ensure forced inclusion store is empty")
129140
spam_n_blocks(l2_client_node1, env_vars.l2_prefunded_priv_key, env_vars.max_blocks_per_batch, env_vars.preconf_min_txs)
130141

131142
@pytest.fixture(scope="session", autouse=True)
132143
def global_setup(l1_client, l2_client_node1, l2_client_node2, env_vars):
133144
"""Run once before all tests"""
145+
146+
if env_vars.protocol == "shasta":
147+
yield
148+
return
149+
134150
print("Wait for Geth sync with TaikoInbox")
135151
block_number_contract = get_last_block_id(l1_client, env_vars.taiko_inbox_address)
136152

e2e_tests/forced_inclusion_store.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
from web3 import Web3
2-
import json
3-
4-
abi = [
1+
pacaya_fi_abi = [
52
{
63
"inputs": [],
74
"name": "head",
@@ -29,18 +26,3 @@
2926
"type": "function"
3027
}
3128
]
32-
33-
def get_forced_inclusion_store_head(l1_client, forced_inclusion_address):
34-
contract = l1_client.eth.contract(address=forced_inclusion_address, abi=abi)
35-
head = contract.functions.head().call()
36-
return int(head)
37-
38-
def forced_inclusion_store_is_empty(l1_client, forced_inclusion_address):
39-
contract = l1_client.eth.contract(address=forced_inclusion_address, abi=abi)
40-
head = contract.functions.head().call()
41-
tail = contract.functions.tail().call()
42-
print("Forced Inclusion head:", head, "tail: ", tail)
43-
return head == tail
44-
45-
def check_empty_forced_inclusion_store(l1_client, env_vars):
46-
assert forced_inclusion_store_is_empty(l1_client, env_vars.forced_inclusion_store_address), "Forced inclusion store should be empty"

e2e_tests/taiko_inbox.py

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,36 @@
11
from web3 import Web3
22
import json
3+
from utils import get_shasta_inbox_abi
34

45
with open("../pacaya/src/l1/abi/ITaikoInbox.json") as f:
5-
abi = json.load(f)
6+
pacaya_abi = json.load(f)
67

7-
def get_last_batch_id(l1_client, taiko_inbox_address):
8-
contract = l1_client.eth.contract(address=taiko_inbox_address, abi=abi)
9-
result = contract.functions.getStats2().call()
10-
last_batch_id = result[0]
11-
return last_batch_id
8+
def get_last_batch_id(l1_client, env_vars):
9+
if env_vars.is_pacaya():
10+
contract = l1_client.eth.contract(address=env_vars.taiko_inbox_address, abi=pacaya_abi)
11+
result = contract.functions.getStats2().call()
12+
last_batch_id = result[0]
13+
return last_batch_id
14+
else:
15+
core_state = get_core_state(l1_client, env_vars)
16+
last_batch_id = core_state[0] - 1
17+
return last_batch_id
1218

13-
def get_last_block_id(l1_client, taiko_inbox_address):
14-
batch_id = int(get_last_batch_id(l1_client, taiko_inbox_address)) - 1
15-
contract = l1_client.eth.contract(address=taiko_inbox_address, abi=abi)
16-
result = contract.functions.getBatch(batch_id).call()
17-
last_block_id = result[1]
18-
return last_block_id
19+
def get_last_block_id(l1_client, env_vars):
20+
if env_vars.is_pacaya():
21+
batch_id = int(get_last_batch_id(l1_client, env_vars)) - 1
22+
contract = l1_client.eth.contract(address=env_vars.taiko_inbox_address, abi=pacaya_abi)
23+
result = contract.functions.getBatch(batch_id).call()
24+
last_block_id = result[1]
25+
return last_block_id
26+
else:
27+
core_state = get_core_state(l1_client, env_vars)
28+
last_block_id = core_state[1]
29+
#print(f"Last L2 block id from core state: {last_block_id}, next proposal id: {core_state[0]}")
30+
return last_block_id
31+
32+
def get_core_state(l1_client, env_vars):
33+
shasta_abi = get_shasta_inbox_abi()
34+
contract = l1_client.eth.contract(address=env_vars.taiko_inbox_address, abi=shasta_abi)
35+
result = contract.functions.getCoreState().call()
36+
return result

0 commit comments

Comments
 (0)