Skip to content

Commit

Permalink
db for mock el
Browse files Browse the repository at this point in the history
  • Loading branch information
Giulio2002 committed Mar 14, 2023
1 parent cecb846 commit 7fbda52
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion cmd/erigon-el-mock/main.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
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"

"github.com/ledgerwatch/log/v3"
)

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 {
Expand All @@ -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)
Expand Down

0 comments on commit 7fbda52

Please sign in to comment.