Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
281 changes: 168 additions & 113 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ serde = { version = "1.0.219", default-features = false, features = ["derive"] }
serde_json = { version = "1.0.140", default-features = false }

# Kona
kona-client = { git="https://github.com/op-rs/kona", rev= "kona-node/v1.2.2", default-features = false }
kona-host = { git="https://github.com/op-rs/kona", rev= "kona-node/v1.2.2", default-features = false }
kona-proof = { git="https://github.com/op-rs/kona", rev= "kona-node/v1.2.2", default-features = false }
kona-preimage = {git="https://github.com/op-rs/kona", rev= "kona-node/v1.2.2", default-features = false }
kona-genesis = { git="https://github.com/op-rs/kona", rev= "kona-node/v1.2.2", default-features = false }
kona-registry = { git="https://github.com/op-rs/kona", rev= "kona-node/v1.2.2", default-features = false }
kona-client = { git="https://github.com/yoshidan/kona", rev= "kona-node/v1.2.4-patch", default-features = false }
kona-host = { git="https://github.com/yoshidan/kona", rev= "kona-node/v1.2.4-patch", default-features = false }
kona-proof = { git="https://github.com/yoshidan/kona", rev= "kona-node/v1.2.4-patch", default-features = false }
kona-preimage = {git="https://github.com/yoshidan/kona", rev= "kona-node/v1.2.4-patch", default-features = false }
kona-genesis = { git="https://github.com/yoshidan/kona", rev= "kona-node/v1.2.4-patch", default-features = false }
kona-registry = { git="https://github.com/yoshidan/kona", rev= "kona-node/v1.2.4-patch", default-features = false }

# Alloy
alloy-primitives = { version = "1.4.1", default-features = false }
Expand Down
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SED = $(shell which gsed 2>/dev/null || echo sed)

.PHONY: chain
chain:
git clone --depth 1 -b v1.16.1 https://github.com/ethereum-optimism/optimism ./chain
git clone --depth 1 -b v1.16.2 https://github.com/ethereum-optimism/optimism ./chain
# override devnet config
cp kurtosis/kurtosis.yaml ./chain/kurtosis-devnet/optimism-package-trampoline/kurtosis.yml
cp kurtosis/main.star ./chain/kurtosis-devnet/optimism-package-trampoline/main.star
Expand All @@ -22,6 +22,10 @@ set-port:
scripts/port.sh
scripts/get_l1_config.sh

.PHONY: set-port-fixed
set-port-fixed:
echo "{\"l1BeaconPort\": 9596, \"l1GethPort\": 8545, \"l2RollupPort\": 9545, \"l2GethPort\": 8546}" | jq > hostPort.json

.PHONY: status
status:
@PORT=$$(jq -r '.l2RollupPort' hostPort.json);\
Expand Down Expand Up @@ -51,6 +55,12 @@ test:
L2_GETH_PORT=$$(jq -r '.l2GethPort' hostPort.json);\
L2_ROLLUP_PORT=$$L2_ROLLUP_PORT L2_GETH_PORT=$$L2_GETH_PORT cargo test --manifest-path=./server/Cargo.toml

.PHONY: test-ignored
test-ignored:
@L2_ROLLUP_PORT=$$(jq -r '.l2RollupPort' hostPort.json);\
L2_GETH_PORT=$$(jq -r '.l2GethPort' hostPort.json);\
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

.PHONY: devnet-down
devnet-down:
@ENCLAVE=$$(kurtosis enclave ls | awk 'NR==2 {print $$1}'); kurtosis enclave rm -f $$ENCLAVE
Expand Down
2 changes: 1 addition & 1 deletion kurtosis/kurtosis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: github.com/ethereum-optimism/optimism/kurtosis-devnet/optimism-package-tra
description: |-
A trampoline package for optimism-package. This one is reproducible, due to the replace directives below.
replace:
github.com/yoshidan/optimism-package: github.com/yoshidan/optimism-package@ca2ca4fab42446c1a9ddc596f1b8036db4766194
github.com/yoshidan/optimism-package: github.com/yoshidan/optimism-package@b2579b9892819391aeae8d822ec341c48cab14f7
github.com/ethpandaops/ethereum-package: github.com/ethpandaops/ethereum-package@e964e305a19d56b798800e84d264f97b87952c55
github.com/kurtosis-tech/prometheus-package: github.com/kurtosis-tech/prometheus-package@637c9dea933be18e47f96cadc0d9bb0e3a5aa9d6 # v1.0.0
github.com/kurtosis-tech/postgres-package: github.com/kurtosis-tech/postgres-package@9cbdde2c55e8d1656deb87821465a2ad244d8b33 # v1.0.0
2 changes: 1 addition & 1 deletion kurtosis/simple.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ optimism_package:
node0:
el:
type: op-geth
image: "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-geth:v1.101603.4"
image: "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-geth:v1.101603.5"
log_level: ""
extra_env_vars: {}
extra_labels: {}
Expand Down
2 changes: 1 addition & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ kona-registry = { workspace = true }
alloy-primitives = { workspace = true, features = ["map", "serde"] }

# optimism derivation
optimism-derivation = { git = "https://github.com/datachainlab/optimism-elc", rev = "v0.1.8", default-features = false }
optimism-derivation = { git = "https://github.com/datachainlab/optimism-elc", rev = "b6a4e78e0b0a8f279fef68ea8346f05ebd579ef3", default-features = false }
base64 = "0.22.1"

[dev-dependencies]
Expand Down
34 changes: 26 additions & 8 deletions server/tests/e2e.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use alloy_primitives::ChainId;
use optimism_derivation::derivation::Derivation;
use optimism_derivation::oracle::MemoryOracleClient;
use optimism_derivation::types::Preimages;
Expand Down Expand Up @@ -57,13 +58,7 @@ async fn get_latest_derivation(l2_client: &L2Client) -> Request {
}
}

#[serial]
#[tokio::test(flavor = "multi_thread")]
async fn test_make_preimages_success() {
init();
let l2_client = get_l2_client();

let request = get_latest_derivation(&l2_client).await;
async fn success_derivation(request: Request, chain_id: ChainId) {
tracing::info!("request: {:?}", request);

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

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

#[serial]
#[tokio::test(flavor = "multi_thread")]
async fn test_make_preimages_success() {
init();
let l2_client = get_l2_client();
let chain_id = l2_client.chain_id().await.unwrap();
let request = get_latest_derivation(&l2_client).await;
success_derivation(request, chain_id).await;
}

#[serial]
#[tokio::test(flavor = "multi_thread")]
#[ignore]
async fn test_make_preimages_success_from_file() {
init();
let path = env::var("REQUEST_PATH").unwrap();
tracing::info!("reading request from file: {path}");
let request = std::fs::read_to_string(path).unwrap();
let request = serde_json::from_str::<Request>(&request).unwrap();
let l2_client = get_l2_client();
let chain_id = l2_client.chain_id().await.unwrap();
success_derivation(request, chain_id).await;
}

#[serial]
#[tokio::test(flavor = "multi_thread")]
async fn test_make_preimages_error() {
Expand Down
1 change: 1 addition & 0 deletions tool/derive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
curl -X POST http://localhost:10080/derivation -H "Content-Type: application/json" -d @body.json
44 changes: 44 additions & 0 deletions tool/output.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
agreed=$1
claimed=$2
agreed_hex=$(printf "0x%x" "$agreed")
claimed_hex=$(printf "0x%x" "$claimed")

# agreed
AGREED=$(curl -s -X POST http://localhost:9545 \
-H "Content-Type: application/json" \
-d "{
\"jsonrpc\":\"2.0\",
\"method\":\"optimism_outputAtBlock\",
\"params\":[\"$agreed_hex\"],
\"id\":2
}")
AGREED_L2_HASH=$(echo $AGREED | jq .result.blockRef.hash)
echo "agreed l2 hash: $AGREED_L2_HASH"
AGREED_L2_OUTPUT=$(echo $AGREED | jq .result.outputRoot)
echo "agreed l2 output root: $AGREED_L2_OUTPUT"

# claimed
CLAIMED=$(curl -s -X POST http://localhost:9545 \
-H "Content-Type: application/json" \
-d "{
\"jsonrpc\":\"2.0\",
\"method\":\"optimism_outputAtBlock\",
\"params\":[\"$claimed_hex\"],
\"id\":2
}")
CLAIMED_L2_OUTPUT=$(echo $CLAIMED | jq .result.outputRoot)
echo "claimed l2 output root: $CLAIMED_L2_OUTPUT"

CLAIMED_L1_ORIGIN=$(echo $CLAIMED | jq .result.blockRef.l1origin.number)
L1_HEAD_NUMBER=$((CLAIMED_L1_ORIGIN+30))
echo "l1 head number: ${L1_HEAD_NUMBER}"
l1_head_num_hex=$(printf "0x%x" "$L1_HEAD_NUMBER")

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)
echo "l1_head_hash: ${L1_HEAD_HASH}"

echo "{ \"l1_head_hash\": ${L1_HEAD_HASH}, " > body.json
echo " \"agreed_l2_head_hash\": ${AGREED_L2_HASH}, " >> body.json
echo " \"agreed_l2_output_root\": ${AGREED_L2_OUTPUT}, " >> body.json
echo " \"l2_output_root\": ${CLAIMED_L2_OUTPUT}, " >> body.json
echo " \"l2_block_number\": ${claimed}} " >> body.json