From 7fbda52b7dcfb0c5bde6bf55b876ee08efb55062 Mon Sep 17 00:00:00 2001 From: Giulio Rebuffo Date: Tue, 14 Mar 2023 11:01:03 +0100 Subject: [PATCH] db for mock el --- cmd/erigon-el-mock/main.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cmd/erigon-el-mock/main.go b/cmd/erigon-el-mock/main.go index 57f29dad968..abc2f387e14 100644 --- a/cmd/erigon-el-mock/main.go +++ b/cmd/erigon-el-mock/main.go @@ -1,10 +1,13 @@ package main import ( + "flag" "net" "github.com/c2h5oh/datasize" "github.com/ledgerwatch/erigon-lib/gointerfaces/execution" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/mdbx" "github.com/ledgerwatch/erigon-lib/kv/memdb" "google.golang.org/grpc" @@ -12,6 +15,9 @@ import ( ) func main() { + + datadir := flag.String("datadir", "", "non in-memory db for EL simulation") + flag.Parse() log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler)) lis, err := net.Listen("tcp", "127.0.0.1:8989") if err != nil { @@ -20,7 +26,17 @@ func main() { maxReceiveSize := 500 * datasize.MB s := grpc.NewServer(grpc.MaxRecvMsgSize(int(maxReceiveSize))) - execution.RegisterExecutionServer(s, NewEth1Execution(memdb.New("" /* tmpDir */))) + var db kv.RwDB + if *datadir == "" { + db = memdb.New("") + } else { + db, err = mdbx.Open(*datadir, log.Root(), false) + if err != nil { + log.Error("Could not open database", "err", err) + return + } + } + execution.RegisterExecutionServer(s, NewEth1Execution(db)) log.Info("Serving mock Execution layer.") if err := s.Serve(lis); err != nil { log.Error("failed to serve", "err", err)