Skip to content

Commit 6590100

Browse files
author
Naohiro Yoshida
committed
patch kona
Signed-off-by: Naohiro Yoshida <naohiro.yoshida@datachain.jp>
1 parent 6bcd7ca commit 6590100

File tree

7 files changed

+109
-36
lines changed

7 files changed

+109
-36
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ serde = { version = "1.0.219", default-features = false, features = ["derive"] }
1111
serde_json = { version = "1.0.140", default-features = false }
1212

1313
# Kona
14-
kona-client = { git="https://github.com/op-rs/kona", rev= "kona-node/v1.2.4", default-features = false }
15-
kona-host = { git="https://github.com/op-rs/kona", rev= "kona-node/v1.2.4", default-features = false }
16-
kona-proof = { git="https://github.com/op-rs/kona", rev= "kona-node/v1.2.4", default-features = false }
17-
kona-preimage = {git="https://github.com/op-rs/kona", rev= "kona-node/v1.2.4", default-features = false }
18-
kona-genesis = { git="https://github.com/op-rs/kona", rev= "kona-node/v1.2.4", default-features = false }
19-
kona-registry = { git="https://github.com/op-rs/kona", rev= "kona-node/v1.2.4", default-features = false }
14+
kona-client = { git="https://github.com/yoshidan/kona", rev= "kona-node/v1.2.4-patch", default-features = false }
15+
kona-host = { git="https://github.com/yoshidan/kona", rev= "kona-node/v1.2.4-patch", default-features = false }
16+
kona-proof = { git="https://github.com/yoshidan/kona", rev= "kona-node/v1.2.4-patch", default-features = false }
17+
kona-preimage = {git="https://github.com/yoshidan/kona", rev= "kona-node/v1.2.4-patch", default-features = false }
18+
kona-genesis = { git="https://github.com/yoshidan/kona", rev= "kona-node/v1.2.4-patch", default-features = false }
19+
kona-registry = { git="https://github.com/yoshidan/kona", rev= "kona-node/v1.2.4-patch", default-features = false }
2020

2121
# Alloy
2222
alloy-primitives = { version = "1.4.1", default-features = false }

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ set-port:
2222
scripts/port.sh
2323
scripts/get_l1_config.sh
2424

25+
.PHONY: set-port-fixed
26+
set-port-fixed:
27+
echo "{\"l1BeaconPort\": 9596, \"l1GethPort\": 8545, \"l2RollupPort\": 9545, \"l2GethPort\": 8546}" | jq > hostPort.json
28+
2529
.PHONY: status
2630
status:
2731
@PORT=$$(jq -r '.l2RollupPort' hostPort.json);\
@@ -51,6 +55,12 @@ test:
5155
L2_GETH_PORT=$$(jq -r '.l2GethPort' hostPort.json);\
5256
L2_ROLLUP_PORT=$$L2_ROLLUP_PORT L2_GETH_PORT=$$L2_GETH_PORT cargo test --manifest-path=./server/Cargo.toml
5357

58+
.PHONY: test-ignored
59+
test-ignored:
60+
@L2_ROLLUP_PORT=$$(jq -r '.l2RollupPort' hostPort.json);\
61+
L2_GETH_PORT=$$(jq -r '.l2GethPort' hostPort.json);\
62+
REQUEST_PATH=$(CURDIR)/tool/body.json L2_ROLLUP_PORT=$$L2_ROLLUP_PORT L2_GETH_PORT=$$L2_GETH_PORT cargo test --manifest-path=./server/Cargo.toml -- --ignored
63+
5464
.PHONY: devnet-down
5565
devnet-down:
5666
@ENCLAVE=$$(kurtosis enclave ls | awk 'NR==2 {print $$1}'); kurtosis enclave rm -f $$ENCLAVE

server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ kona-registry = { workspace = true }
2828
alloy-primitives = { workspace = true, features = ["map", "serde"] }
2929

3030
# optimism derivation
31-
optimism-derivation = { git = "https://github.com/datachainlab/optimism-elc", rev = "0b972aac9afec9bc97aa9fa90a9bfb468df85ddd", default-features = false }
31+
optimism-derivation = { git = "https://github.com/datachainlab/optimism-elc", rev = "b6a4e78e0b0a8f279fef68ea8346f05ebd579ef3", default-features = false }
3232
base64 = "0.22.1"
3333

3434
[dev-dependencies]

server/tests/e2e.rs

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use alloy_primitives::ChainId;
12
use optimism_derivation::derivation::Derivation;
23
use optimism_derivation::oracle::MemoryOracleClient;
34
use optimism_derivation::types::Preimages;
@@ -57,13 +58,7 @@ async fn get_latest_derivation(l2_client: &L2Client) -> Request {
5758
}
5859
}
5960

60-
#[serial]
61-
#[tokio::test(flavor = "multi_thread")]
62-
async fn test_make_preimages_success() {
63-
init();
64-
let l2_client = get_l2_client();
65-
66-
let request = get_latest_derivation(&l2_client).await;
61+
async fn success_derivation(request: Request, chain_id: ChainId) {
6762
tracing::info!("request: {:?}", request);
6863

6964
let client = reqwest::Client::new();
@@ -83,7 +78,6 @@ async fn test_make_preimages_success() {
8378
request.l2_block_number,
8479
);
8580

86-
let chain_id = l2_client.chain_id().await.unwrap();
8781
let result = derivation.verify(chain_id, oracle);
8882
match result {
8983
Ok(h) => tracing::info!("Derivation verified successfully {:? }", h),
@@ -94,6 +88,30 @@ async fn test_make_preimages_success() {
9488
}
9589
}
9690

91+
#[serial]
92+
#[tokio::test(flavor = "multi_thread")]
93+
async fn test_make_preimages_success() {
94+
init();
95+
let l2_client = get_l2_client();
96+
let chain_id = l2_client.chain_id().await.unwrap();
97+
let request = get_latest_derivation(&l2_client).await;
98+
success_derivation(request, chain_id).await;
99+
}
100+
101+
#[serial]
102+
#[tokio::test(flavor = "multi_thread")]
103+
#[ignore]
104+
async fn test_make_preimages_success_from_file() {
105+
init();
106+
let path = env::var("REQUEST_PATH").unwrap();
107+
tracing::info!("reading request from file: {path}");
108+
let request = std::fs::read_to_string(path).unwrap();
109+
let request = serde_json::from_str::<Request>(&request).unwrap();
110+
let l2_client = get_l2_client();
111+
let chain_id = l2_client.chain_id().await.unwrap();
112+
success_derivation(request, chain_id).await;
113+
}
114+
97115
#[serial]
98116
#[tokio::test(flavor = "multi_thread")]
99117
async fn test_make_preimages_error() {

tool/derive.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
curl -X POST http://localhost:10080/derivation -H "Content-Type: application/json" -d @body.json

tool/output.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
agreed=$1
2+
claimed=$2
3+
agreed_hex=$(printf "0x%x" "$agreed")
4+
claimed_hex=$(printf "0x%x" "$claimed")
5+
6+
# agreed
7+
AGREED=$(curl -s -X POST http://localhost:9545 \
8+
-H "Content-Type: application/json" \
9+
-d "{
10+
\"jsonrpc\":\"2.0\",
11+
\"method\":\"optimism_outputAtBlock\",
12+
\"params\":[\"$agreed_hex\"],
13+
\"id\":2
14+
}")
15+
AGREED_L2_HASH=$(echo $AGREED | jq .result.blockRef.hash)
16+
echo "agreed l2 hash: $AGREED_L2_HASH"
17+
AGREED_L2_OUTPUT=$(echo $AGREED | jq .result.outputRoot)
18+
echo "agreed l2 output root: $AGREED_L2_OUTPUT"
19+
20+
# claimed
21+
CLAIMED=$(curl -s -X POST http://localhost:9545 \
22+
-H "Content-Type: application/json" \
23+
-d "{
24+
\"jsonrpc\":\"2.0\",
25+
\"method\":\"optimism_outputAtBlock\",
26+
\"params\":[\"$claimed_hex\"],
27+
\"id\":2
28+
}")
29+
CLAIMED_L2_OUTPUT=$(echo $CLAIMED | jq .result.outputRoot)
30+
echo "claimed l2 output root: $CLAIMED_L2_OUTPUT"
31+
32+
CLAIMED_L1_ORIGIN=$(echo $CLAIMED | jq .result.blockRef.l1origin.number)
33+
L1_HEAD_NUMBER=$((CLAIMED_L1_ORIGIN+30))
34+
echo "l1 head number: ${L1_HEAD_NUMBER}"
35+
l1_head_num_hex=$(printf "0x%x" "$L1_HEAD_NUMBER")
36+
37+
L1_HEAD_HASH=$(curl -s -X POST localhost:8545 -d "{\"method\":\"eth_getBlockByNumber\", \"jsonrpc\": \"2.0\", \"id\":1, \"params\":[\"${l1_head_num_hex}\",false]}" -H "Content-Type: application/json" | jq .result.hash)
38+
echo "l1_head_hash: ${L1_HEAD_HASH}"
39+
40+
echo "{ \"l1_head_hash\": ${L1_HEAD_HASH}, " > body.json
41+
echo " \"agreed_l2_head_hash\": ${AGREED_L2_HASH}, " >> body.json
42+
echo " \"agreed_l2_output_root\": ${AGREED_L2_OUTPUT}, " >> body.json
43+
echo " \"l2_output_root\": ${CLAIMED_L2_OUTPUT}, " >> body.json
44+
echo " \"l2_block_number\": ${claimed}} " >> body.json

0 commit comments

Comments
 (0)