diff --git a/op-devstack/sysgo/l2_el.go b/op-devstack/sysgo/l2_el.go index 8efb7d390aaa9..07881e06b6226 100644 --- a/op-devstack/sysgo/l2_el.go +++ b/op-devstack/sysgo/l2_el.go @@ -22,6 +22,7 @@ type L2ELConfig struct { P2PNodeKeyHex string StaticPeers []string TrustedPeers []string + ProofHistory bool } func L2ELWithSupervisor(supervisorID stack.SupervisorID) L2ELOption { @@ -30,6 +31,12 @@ func L2ELWithSupervisor(supervisorID stack.SupervisorID) L2ELOption { }) } +func L2ELWithProofHistory(enable bool) L2ELOption { + return L2ELOptionFn(func(p devtest.P, id stack.L2ELNodeID, cfg *L2ELConfig) { + cfg.ProofHistory = enable + }) +} + // L2ELWithP2PConfig sets deterministic P2P identity and static peers for the L2 EL. func L2ELWithP2PConfig(addr string, port int, nodeKeyHex string, staticPeers, trustedPeers []string) L2ELOption { return L2ELOptionFn(func(p devtest.P, id stack.L2ELNodeID, cfg *L2ELConfig) { @@ -49,6 +56,7 @@ func DefaultL2ELConfig() *L2ELConfig { P2PNodeKeyHex: "", StaticPeers: nil, TrustedPeers: nil, + ProofHistory: false, } } diff --git a/op-devstack/sysgo/l2_el_opreth.go b/op-devstack/sysgo/l2_el_opreth.go index 21496befcf454..e11aa3eaf9e92 100644 --- a/op-devstack/sysgo/l2_el_opreth.go +++ b/op-devstack/sysgo/l2_el_opreth.go @@ -5,6 +5,7 @@ import ( "fmt" "net/url" "os" + "os/exec" "path/filepath" "strings" "sync" @@ -99,8 +100,8 @@ func (n *OpReth) Start() { }) n.userRPC = "ws://" + n.userProxy.Addr() } - logOut := logpipe.ToLogger(n.p.Logger().New("component", "op-reth", "src", "stdout")) - logErr := logpipe.ToLogger(n.p.Logger().New("component", "op-reth", "src", "stderr")) + logOut := logpipe.ToLogger(n.p.Logger().New("component", "op-reth", "src", "stdout", "id", n.id.String())) + logErr := logpipe.ToLogger(n.p.Logger().New("component", "op-reth", "src", "stderr", "id", n.id.String())) authRPCChan := make(chan string, 1) defer close(authRPCChan) @@ -273,6 +274,39 @@ func WithOpReth(id stack.L2ELNodeID, opts ...L2ELOption) stack.Option[*Orchestra args = append(args, "--rollup.supervisor-http="+supervisorRPC) } + // initialise op-reth + initArgs := []string{ + "init", + "--datadir=" + dataDirPath, + "--chain=" + chainConfigPath, + } + err = exec.Command(execPath, initArgs...).Run() + p.Require().NoError(err, "must init op-reth node") + + if cfg.ProofHistory { + proofHistoryDir := filepath.Join(tempDir, "proof-history") + + // initialise proof history + initProofsArgs := []string{ + "proofs", + "init", + "--datadir=" + dataDirPath, + "--chain=" + chainConfigPath, + "--proofs-history.storage-path=" + proofHistoryDir, + } + err = exec.Command(execPath, initProofsArgs...).Run() + p.Require().NoError(err, "must init op-reth proof history") + + args = append( + args, + "--proofs-history", + // todo: make these configurable via env-vars (ethereum-optimism/optimism#18908) + "--proofs-history.window=200", + "--proofs-history.prune-interval=1m", + "--proofs-history.storage-path="+proofHistoryDir, + ) + } + l2EL := &OpReth{ id: id, jwtPath: jwtPath,