diff --git a/.github/workflows/e2e-op-historical-proof.yml b/.github/workflows/e2e-op-historical-proof.yml index 599adf41acc..4a43032a909 100644 --- a/.github/workflows/e2e-op-historical-proof.yml +++ b/.github/workflows/e2e-op-historical-proof.yml @@ -8,9 +8,16 @@ on: jobs: op-reth-as-verifier: - name: op-reth as verifier e2e tests + name: op-reth-as-verifier-${{ matrix.go_pkg_name }} runs-on: ubuntu-latest timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + include: + - go_pkg_name: proofs/core + - go_pkg_name: proofs/reorg + - go_pkg_name: proofs/prune steps: - name: Checkout @@ -59,15 +66,10 @@ jobs: run: | make all DEVNET=opgeth-seq-opreth-val - - name: Run core e2e tests + - name: Run ${{ matrix.go_pkg_name }} e2e tests working-directory: crates/optimism/tests run: | - make test-e2e-kurtosis GO_PKG_NAME=proofs/core DEVNET=opgeth-seq-opreth-val - - - name: Run reorg e2e tests - working-directory: crates/optimism/tests - run: | - make test-e2e-kurtosis GO_PKG_NAME=proofs/reorg DEVNET=opgeth-seq-opreth-val + make test-e2e-kurtosis GO_PKG_NAME=${{ matrix.go_pkg_name }} DEVNET=opgeth-seq-opreth-val # disable coverage for now # - name: Flush coverage data @@ -112,9 +114,16 @@ jobs: # verbose: true op-reth-as-sequencer: - name: op-reth as sequencer e2e tests + name: op-reth-as-sequencer-${{ matrix.go_pkg_name }} runs-on: ubuntu-latest timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + include: + - go_pkg_name: proofs/core + - go_pkg_name: proofs/reorg + - go_pkg_name: proofs/prune steps: - name: Checkout @@ -157,15 +166,10 @@ jobs: run: | make all DEVNET=opreth-seq-opgeth-val - - name: Run core e2e tests - working-directory: crates/optimism/tests - run: | - make test-e2e-kurtosis GO_PKG_NAME=proofs/core DEVNET=opreth-seq-opgeth-val - - - name: Run reorg e2e tests + - name: Run ${{ matrix.go_pkg_name }} e2e tests working-directory: crates/optimism/tests run: | - make test-e2e-kurtosis GO_PKG_NAME=proofs/reorg DEVNET=opreth-seq-opgeth-val + make test-e2e-kurtosis GO_PKG_NAME=${{ matrix.go_pkg_name }} DEVNET=opreth-seq-opgeth-val e2e-op-historical-proof-success: name: e2e-op-historical-proof-success diff --git a/crates/optimism/tests/devnets/opgeth-seq-opreth-val.yaml b/crates/optimism/tests/devnets/opgeth-seq-opreth-val.yaml index efe1e4c4758..65aaa2f3203 100644 --- a/crates/optimism/tests/devnets/opgeth-seq-opreth-val.yaml +++ b/crates/optimism/tests/devnets/opgeth-seq-opreth-val.yaml @@ -36,7 +36,7 @@ optimism_package: image: op-reth:local extra_params: [ --proofs-history, - --proofs-history.window=10000, + --proofs-history.window=200, --proofs-history.prune-interval=1m, --proofs-history.storage-path=/data/proofs-history ] diff --git a/crates/optimism/tests/devnets/opreth-seq-opgeth-val.yaml b/crates/optimism/tests/devnets/opreth-seq-opgeth-val.yaml index 47a16212c6a..2b43aa72d17 100644 --- a/crates/optimism/tests/devnets/opreth-seq-opgeth-val.yaml +++ b/crates/optimism/tests/devnets/opreth-seq-opgeth-val.yaml @@ -27,7 +27,7 @@ optimism_package: image: op-reth:local extra_params: [ --proofs-history, - --proofs-history.window=10000, + --proofs-history.window=200, --proofs-history.prune-interval=1m, --proofs-history.storage-path=/data/proofs-history ] diff --git a/crates/optimism/tests/proofs/prune/init_test.go b/crates/optimism/tests/proofs/prune/init_test.go new file mode 100644 index 00000000000..7581ceb775b --- /dev/null +++ b/crates/optimism/tests/proofs/prune/init_test.go @@ -0,0 +1,13 @@ +package prune + +import ( + "testing" + + "github.com/ethereum-optimism/optimism/op-devstack/presets" +) + +// TestMain creates the test-setups against the shared backend +func TestMain(m *testing.M) { + // Other setups may be added here, hydrated from the same orchestrator + presets.DoMain(m, presets.WithSingleChainMultiNode()) +} diff --git a/crates/optimism/tests/proofs/prune/prune_test.go b/crates/optimism/tests/proofs/prune/prune_test.go new file mode 100644 index 00000000000..8df5088fcb9 --- /dev/null +++ b/crates/optimism/tests/proofs/prune/prune_test.go @@ -0,0 +1,66 @@ +package prune + +import ( + "testing" + "time" + + "github.com/ethereum-optimism/optimism/op-devstack/devtest" + "github.com/ethereum-optimism/optimism/op-devstack/presets" + "github.com/ethereum-optimism/optimism/op-service/apis" + "github.com/op-rs/op-geth/proofs/utils" + "github.com/stretchr/testify/require" +) + +func TestPruneProofStorage(gt *testing.T) { + t := devtest.SerialT(gt) + sys := presets.NewSingleChainMultiNode(t) + + var proofWindow = uint64(200) // Defined in the devnet yaml + var pruneDetectTimeout = time.Minute * 5 // An expected time within the prune should be detected. + opRethELNode, _ := utils.IdentifyELNodes(sys.L2EL, sys.L2ELB) + + syncStatus := getProofSyncStatus(t, opRethELNode.Escape().EthClient()) + t.Log("Initial sync status:", syncStatus) + distance := syncStatus.Latest - syncStatus.Earliest + + if distance < proofWindow { + // Wait till we reach proof window + t.Logf("Waiting for block %d", syncStatus.Earliest+proofWindow) + opRethELNode.WaitForBlockNumber(syncStatus.Earliest + proofWindow) + } + // Now we need to wait for pruner to execute pruning, which can be done anytime within 1 minute (pruner prune interval = 1 min) + startTime := time.Now() + var newSyncStatus proofSyncStatus + for { + // Get sync status each Second + if time.Since(startTime) > pruneDetectTimeout { + t.Error("Pruner did not prune proof storage within the interval") + return + } + newSyncStatus = getProofSyncStatus(t, opRethELNode.Escape().EthClient()) + if syncStatus.Earliest != newSyncStatus.Earliest { + break + } + t.Log("Waiting on earliest state to be changed: ", syncStatus.Earliest) + time.Sleep(time.Second * 5) + } + // Check how many has been pruned - we should have current proof window intake + currentProofWindow := newSyncStatus.Latest - newSyncStatus.Earliest + t.Log("Sync status:", syncStatus) + require.GreaterOrEqual(t, currentProofWindow, proofWindow, "Pruner has changed the proof window") + t.Logf("Successfully pruned proof storage. sync status: %v", syncStatus) +} + +type proofSyncStatus struct { + Earliest uint64 `json:"earliest"` + Latest uint64 `json:"latest"` +} + +func getProofSyncStatus(t devtest.T, client apis.EthClient) proofSyncStatus { + var result proofSyncStatus + err := client.RPC().CallContext(t.Ctx(), &result, "debug_proofsSyncStatus") + if err != nil { + t.Error(err) + } + return result +}