Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

silkworm: use silkworm-go bindings #8829

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }}
strategy:
matrix:
os: [ ubuntu-20.04, macos-11 ] # list of os: https://github.com/actions/virtual-environments
os: [ ubuntu-22.04, macos-13-xlarge ] # list of os: https://github.com/actions/virtual-environments
runs-on: ${{ matrix.os }}

steps:
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
docker-build-check:
# don't run this on devel - the PR must have run it to be merged and it misleads that this pushes the docker image
if: (${{ github.event_name == 'push' || !github.event.pull_request.draft }}) && ${{ github.ref != 'refs/heads/devel' }}
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: AutoModality/action-clean@v1
- uses: actions/checkout@v3
Expand All @@ -125,7 +125,7 @@ jobs:

# automated-tests:
# runs-on:
# ubuntu-20.04
# ubuntu-22.04
# if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }}
# steps:
# - uses: actions/checkout@v3
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test-integration-caplin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ jobs:
strategy:
matrix:
# disable macos-11 until https://github.com/ledgerwatch/erigon/issues/8789
# os: [ ubuntu-20.04, macos-11 ] # list of os: https://github.com/actions/virtual-environments
os: [ ubuntu-20.04 ] # list of os: https://github.com/actions/virtual-environments
os: [ ubuntu-22.04 ] # list of os: https://github.com/actions/virtual-environments
runs-on: ${{ matrix.os }}

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
tests:
strategy:
matrix:
os: [ ubuntu-20.04, macos-11 ] # list of os: https://github.com/actions/virtual-environments
os: [ ubuntu-22.04, macos-13-xlarge ] # list of os: https://github.com/actions/virtual-environments
runs-on: ${{ matrix.os }}

steps:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ADD . .
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/tmp/go-build \
--mount=type=cache,target=/go/pkg/mod \
make all
make BUILD_TAGS=nosqlite,noboltdb,nosilkworm all


FROM docker.io/library/golang:1.20-alpine3.17 AS tools-builder
Expand Down
11 changes: 2 additions & 9 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,11 +852,6 @@ var (
Usage: "Comma separated list of support session ids to connect to",
}

SilkwormLibraryPathFlag = cli.StringFlag{
Name: "silkworm.libpath",
Usage: "Path to the Silkworm library",
Value: "",
}
SilkwormExecutionFlag = cli.BoolFlag{
Name: "silkworm.exec",
Usage: "Enable Silkworm block execution",
Expand All @@ -869,6 +864,7 @@ var (
Name: "silkworm.sentry",
Usage: "Enable embedded Silkworm Sentry service",
}

BeaconAPIFlag = cli.BoolFlag{
Name: "beacon.api",
Usage: "Enable beacon API",
Expand Down Expand Up @@ -1554,10 +1550,7 @@ func setCaplin(ctx *cli.Context, cfg *ethconfig.Config) {
}

func setSilkworm(ctx *cli.Context, cfg *ethconfig.Config) {
cfg.SilkwormLibraryPath = ctx.String(SilkwormLibraryPathFlag.Name)
if ctx.IsSet(SilkwormExecutionFlag.Name) {
cfg.SilkwormExecution = ctx.Bool(SilkwormExecutionFlag.Name)
}
cfg.SilkwormExecution = ctx.Bool(SilkwormExecutionFlag.Name)
cfg.SilkwormRpcDaemon = ctx.Bool(SilkwormRpcDaemonFlag.Name)
cfg.SilkwormSentry = ctx.Bool(SilkwormSentryFlag.Name)
}
Expand Down
12 changes: 7 additions & 5 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ func New(ctx context.Context, stack *node.Node, config *ethconfig.Config, logger

backend.gasPrice, _ = uint256.FromBig(config.Miner.GasPrice)

if config.SilkwormLibraryPath != "" {
backend.silkworm, err = silkworm.New(config.SilkwormLibraryPath, config.Dirs.DataDir)
if config.SilkwormExecution || config.SilkwormRpcDaemon || config.SilkwormSentry {
backend.silkworm, err = silkworm.New(config.Dirs.DataDir)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -386,7 +386,7 @@ func New(ctx context.Context, stack *node.Node, config *ethconfig.Config, logger
MaxPeers: p2pConfig.MaxPeers,
}

silkwormSentryService := backend.silkworm.NewSentryService(settings)
silkwormSentryService := silkworm.NewSentryService(backend.silkworm, settings)
backend.silkwormSentryService = &silkwormSentryService

sentryClient, err := sentry_multi_client.GrpcClient(backend.sentryCtx, apiAddr)
Expand Down Expand Up @@ -915,7 +915,7 @@ func (s *Ethereum) Init(stack *node.Node, config *ethconfig.Config) error {
s.apiList = jsonrpc.APIList(chainKv, ethRpcClient, txPoolRpcClient, miningRpcClient, ff, stateCache, blockReader, s.agg, &httpRpcCfg, s.engine, s.logger)

if config.SilkwormRpcDaemon && httpRpcCfg.Enabled {
silkwormRPCDaemonService := s.silkworm.NewRpcDaemonService(chainKv)
silkwormRPCDaemonService := silkworm.NewRpcDaemonService(s.silkworm, chainKv)
s.silkwormRPCDaemonService = &silkwormRPCDaemonService
} else {
go func() {
Expand Down Expand Up @@ -1387,7 +1387,9 @@ func (s *Ethereum) Stop() error {
}
}
if s.silkworm != nil {
s.silkworm.Close()
if err := s.silkworm.Close(); err != nil {
s.logger.Error("silkworm.Close error", "err", err)
}
}

return nil
Expand Down
10 changes: 3 additions & 7 deletions eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ var Defaults = Config{
KeepBlocks: false,
Produce: true,
},

// applies if SilkwormLibraryPath is set
SilkwormExecution: true,
}

func init() {
Expand Down Expand Up @@ -256,10 +253,9 @@ type Config struct {
ForcePartialCommit bool

// Embedded Silkworm support
SilkwormLibraryPath string
SilkwormExecution bool
SilkwormRpcDaemon bool
SilkwormSentry bool
SilkwormExecution bool
SilkwormRpcDaemon bool
SilkwormSentry bool

DisableTxPoolGossip bool
}
Expand Down
2 changes: 1 addition & 1 deletion eth/stagedsync/stage_execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ Loop:

_, isMemoryMutation := tx.(*membatchwithdb.MemoryMutation)
if cfg.silkworm != nil && !isMemoryMutation {
blockNum, err = cfg.silkworm.ExecuteBlocks(tx, cfg.chainConfig.ChainID, blockNum, to, uint64(cfg.batchSize), writeChangeSets, writeReceipts, writeCallTraces)
blockNum, err = silkworm.ExecuteBlocks(cfg.silkworm, tx, cfg.chainConfig.ChainID, blockNum, to, uint64(cfg.batchSize), writeChangeSets, writeReceipts, writeCallTraces)
} else {
err = executeBlock(block, tx, batch, cfg, *cfg.vmConfig, writeChangeSets, writeReceipts, writeCallTraces, initialCycle, stateStream, logger)
}
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.20

require (
github.com/erigontech/mdbx-go v0.27.21
github.com/erigontech/silkworm-go v0.6.0
github.com/ledgerwatch/erigon-lib v1.0.0
github.com/ledgerwatch/log/v3 v3.9.0
github.com/ledgerwatch/secp256k1 v1.0.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/erigontech/mdbx-go v0.27.21 h1:Pv47QIiRXR8Nv+nltZteLm4xkRwuvqmOCjzZj9X0s1A=
github.com/erigontech/mdbx-go v0.27.21/go.mod h1:FAMxbOgqOnRDx51j8HjuJZIgznbDwjX7LItd+/UWyA4=
github.com/erigontech/silkworm-go v0.6.0 h1:fEGifV+kb6slayhmNowLjVTerWMycQaBNaYea3O4KEI=
github.com/erigontech/silkworm-go v0.6.0/go.mod h1:O50ux0apICEVEGyRWiE488K8qz8lc3PA/SXbQQAc8SU=
github.com/fjl/gencodec v0.0.0-20220412091415-8bb9e558978c h1:CndMRAH4JIwxbW8KYq6Q+cGWcGHz0FjGR3QqcInWcW0=
github.com/fjl/gencodec v0.0.0-20220412091415-8bb9e558978c/go.mod h1:AzA8Lj6YtixmJWL+wkKoBGsLWy9gFrAzi4g+5bCKwpY=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
Expand Down
1 change: 0 additions & 1 deletion turbo/cli/default_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ var DefaultFlags = []cli.Flag{

&utils.OtsSearchMaxCapFlag,

&utils.SilkwormLibraryPathFlag,
&utils.SilkwormExecutionFlag,
&utils.SilkwormRpcDaemonFlag,
&utils.SilkwormSentryFlag,
Expand Down
37 changes: 0 additions & 37 deletions turbo/silkworm/load_unix.go

This file was deleted.

16 changes: 0 additions & 16 deletions turbo/silkworm/load_windows.go

This file was deleted.

Loading
Loading