Skip to content

Commit

Permalink
rpcdaemon: Support remote bor_* RPC on Astrid (#11962)
Browse files Browse the repository at this point in the history
Fixes #11171
  • Loading branch information
shohamc1 authored Sep 12, 2024
1 parent c5d3284 commit b4ea75d
Show file tree
Hide file tree
Showing 12 changed files with 595 additions and 50 deletions.
28 changes: 22 additions & 6 deletions cmd/rpcdaemon/cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import (
"github.com/erigontech/erigon/node"
"github.com/erigontech/erigon/node/nodecfg"
"github.com/erigontech/erigon/polygon/bor"
"github.com/erigontech/erigon/polygon/bor/valset"
"github.com/erigontech/erigon/polygon/bridge"
"github.com/erigontech/erigon/polygon/heimdall"
"github.com/erigontech/erigon/rpc"
Expand All @@ -98,6 +99,17 @@ var (
polygonSync bool
)

type HeimdallReader interface {
Producers(ctx context.Context, blockNum uint64) (*valset.ValidatorSet, error)
Close()
}

type BridgeReader interface {
Events(ctx context.Context, blockNum uint64) ([]*types.Message, error)
EventTxnLookup(ctx context.Context, borTxHash libcommon.Hash) (uint64, bool, error)
Close()
}

func RootCommand() (*cobra.Command, *httpcfg.HttpCfg) {
utils.CobraFlags(rootCmd, debug.Flags, utils.MetricFlags, logging.Flags)

Expand Down Expand Up @@ -323,7 +335,7 @@ func EmbeddedServices(ctx context.Context,
func RemoteServices(ctx context.Context, cfg *httpcfg.HttpCfg, logger log.Logger, rootCancel context.CancelFunc) (
db kv.RoDB, eth rpchelper.ApiBackend, txPool txpool.TxpoolClient, mining txpool.MiningClient,
stateCache kvcache.Cache, blockReader services.FullBlockReader, engine consensus.EngineReader,
ff *rpchelper.Filters, bridgeReader bridge.ReaderService, heimdallReader *heimdall.Reader, err error) {
ff *rpchelper.Filters, bridgeReader BridgeReader, heimdallReader HeimdallReader, err error) {
if !cfg.WithDatadir && cfg.PrivateApiAddr == "" {
return nil, nil, nil, nil, nil, nil, nil, ff, nil, nil, errors.New("either remote db or local db must be specified")
}
Expand All @@ -338,6 +350,7 @@ func RemoteServices(ctx context.Context, cfg *httpcfg.HttpCfg, logger log.Logger

remoteBackendClient := remote.NewETHBACKENDClient(conn)
remoteBridgeClient := remote.NewBridgeBackendClient(conn)
remoteHeimdallClient := remote.NewHeimdallBackendClient(conn)
remoteKvClient := remote.NewKVClient(conn)
remoteKv, err := remotedb.NewRemote(gointerfaces.VersionFromProto(remotedbserver.KvServiceAPIVersion), logger, remoteKvClient).Open()
if err != nil {
Expand Down Expand Up @@ -500,6 +513,7 @@ func RemoteServices(ctx context.Context, cfg *httpcfg.HttpCfg, logger log.Logger

var remoteCE *remoteConsensusEngine
var remoteBridgeReader *bridge.RemoteReader
var remoteHeimdallReader *heimdall.RemoteReader

if cfg.WithDatadir {
if cc != nil && cc.Bor != nil {
Expand Down Expand Up @@ -533,12 +547,11 @@ func RemoteServices(ctx context.Context, cfg *httpcfg.HttpCfg, logger log.Logger
}
} else {
if polygonSync {
remoteBridgeReader, err = bridge.NewRemoteReader(remoteBridgeClient)
if err != nil {
return nil, nil, nil, nil, nil, nil, nil, ff, nil, nil, err
}

remoteBridgeReader = bridge.NewRemoteReader(remoteBridgeClient)
bridgeReader = remoteBridgeReader

remoteHeimdallReader = heimdall.NewRemoteReader(remoteHeimdallClient)
heimdallReader = remoteHeimdallReader
}

remoteCE = &remoteConsensusEngine{}
Expand All @@ -561,6 +574,9 @@ func RemoteServices(ctx context.Context, cfg *httpcfg.HttpCfg, logger log.Logger
if remoteBridgeReader != nil && !remoteBridgeReader.EnsureVersionCompatibility() {
rootCancel()
}
if remoteHeimdallReader != nil && !remoteHeimdallReader.EnsureVersionCompatibility() {
rootCancel()
}
if remoteCE != nil {
if !remoteCE.init(db, blockReader, remoteKvClient, logger) {
rootCancel()
Expand Down
2 changes: 1 addition & 1 deletion erigon-lib/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22

require (
github.com/erigontech/erigon-snapshot v1.3.1-0.20240814160410-2ce37904b978
github.com/erigontech/interfaces v0.0.0-20240911002112-53ce6989bb37
github.com/erigontech/interfaces v0.0.0-20240912071218-97d86b41623a
github.com/erigontech/mdbx-go v0.38.4
github.com/erigontech/secp256k1 v1.1.0
github.com/rs/dnscache v0.0.0-20211102005908-e0241e321417
Expand Down
4 changes: 2 additions & 2 deletions erigon-lib/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/erigontech/erigon-snapshot v1.3.1-0.20240814160410-2ce37904b978 h1:7ECOf7Us3+/706WGZXIX84qQc6zmxQby8fGbFLiqFlU=
github.com/erigontech/erigon-snapshot v1.3.1-0.20240814160410-2ce37904b978/go.mod h1:ooHlCl+eEYzebiPu+FP6Q6SpPUeMADn8Jxabv3IKb9M=
github.com/erigontech/interfaces v0.0.0-20240911002112-53ce6989bb37 h1:caWCruWxoNSQ7EGV9VWeiNexNiLrM52KoZLJqA0gedc=
github.com/erigontech/interfaces v0.0.0-20240911002112-53ce6989bb37/go.mod h1:N7OUkhkcagp9+7yb4ycHsG2VWCOmuJ1ONBecJshxtLE=
github.com/erigontech/interfaces v0.0.0-20240912071218-97d86b41623a h1:8SkMr0APaj4LiviMVfXHRqNgWmsl8mVnNb/ioMzRedE=
github.com/erigontech/interfaces v0.0.0-20240912071218-97d86b41623a/go.mod h1:N7OUkhkcagp9+7yb4ycHsG2VWCOmuJ1ONBecJshxtLE=
github.com/erigontech/mdbx-go v0.38.4 h1:S9T7mTe9KPcFe4dOoOtVdI6gPzht9y7wMnYfUBgrQLo=
github.com/erigontech/mdbx-go v0.38.4/go.mod h1:IcOLQDPw3VM/asP6T5JVPPN4FHHgJtY16XfYjzWKVNI=
github.com/erigontech/secp256k1 v1.1.0 h1:mO3YJMUSoASE15Ya//SoHiisptUhdXExuMUN1M0X9qY=
Expand Down
Loading

0 comments on commit b4ea75d

Please sign in to comment.