bor: BorConfig setup fix (#9145)

A crash on startup happens on --chain=mumbai , because I've confused
chainConfig.Bor (from type chain.Config) and config.Bor (from type
ethconfig.Config) in the setup code.

ethconfig.Config.Bor property contained bogus values, and was used only
to check its type in CreateConsensusEngine(). Its value was never read
(before PR #9117).

This change removes the property to avoid confusion and fix the crash.

Devnet network.BorStateSyncDelay was implemented using
ethconfig.Config.Bor, but it wasn't taking any effect. It should be
fixed separately in a different way.
This commit is contained in:
battlmonstr 2024-01-05 14:03:19 +01:00 committed by GitHub
parent 3eeb57218f
commit ebe16d8360
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 13 deletions

View File

@ -8,6 +8,9 @@ import (
"sync"
"github.com/c2h5oh/datasize"
"github.com/ledgerwatch/log/v3"
"github.com/urfave/cli/v2"
"github.com/ledgerwatch/erigon/cmd/devnet/accounts"
"github.com/ledgerwatch/erigon/cmd/devnet/args"
"github.com/ledgerwatch/erigon/cmd/devnet/requests"
@ -17,8 +20,6 @@ import (
"github.com/ledgerwatch/erigon/params"
"github.com/ledgerwatch/erigon/turbo/debug"
enode "github.com/ledgerwatch/erigon/turbo/node"
"github.com/ledgerwatch/log/v3"
"github.com/urfave/cli/v2"
)
type Node interface {
@ -171,7 +172,8 @@ func (n *devnetNode) run(ctx *cli.Context) error {
}
if n.network.BorStateSyncDelay > 0 {
n.ethCfg.Bor.StateSyncConfirmationDelay = map[string]uint64{"0": uint64(n.network.BorStateSyncDelay.Seconds())}
stateSyncConfirmationDelay := map[string]uint64{"0": uint64(n.network.BorStateSyncDelay.Seconds())}
logger.Warn("TODO: custom BorStateSyncDelay is not applied to BorConfig.StateSyncConfirmationDelay", "delay", stateSyncConfirmationDelay)
}
n.ethNode, err = enode.New(ctx.Context, n.nodeCfg, n.ethCfg, logger)

View File

@ -13,6 +13,11 @@ import (
"github.com/c2h5oh/datasize"
"github.com/erigontech/mdbx-go/mdbx"
lru "github.com/hashicorp/golang-lru/arc/v2"
"github.com/ledgerwatch/log/v3"
"github.com/ledgerwatch/secp256k1"
"github.com/spf13/cobra"
"golang.org/x/exp/slices"
"github.com/ledgerwatch/erigon/consensus/bor"
"github.com/ledgerwatch/erigon/consensus/bor/heimdall"
"github.com/ledgerwatch/erigon/consensus/bor/heimdallgrpc"
@ -21,10 +26,6 @@ import (
"github.com/ledgerwatch/erigon/p2p/sentry/sentry_multi_client"
"github.com/ledgerwatch/erigon/turbo/builder"
"github.com/ledgerwatch/erigon/turbo/snapshotsync/freezeblocks"
"github.com/ledgerwatch/log/v3"
"github.com/ledgerwatch/secp256k1"
"github.com/spf13/cobra"
"golang.org/x/exp/slices"
chain2 "github.com/ledgerwatch/erigon-lib/chain"
"github.com/ledgerwatch/erigon-lib/commitment"
@ -1674,7 +1675,7 @@ func initConsensusEngine(ctx context.Context, cc *chain2.Config, dir string, db
} else if cc.Aura != nil {
consensusConfig = &config.Aura
} else if cc.Bor != nil {
consensusConfig = &config.Bor
consensusConfig = cc.Bor
config.HeimdallURL = HeimdallURL
if !config.WithoutHeimdall {
if config.HeimdallgRPCAddress != "" {

View File

@ -288,7 +288,7 @@ func initConsensusEngine(ctx context.Context, cc *chain2.Config, snapshots *free
} else if cc.Aura != nil {
consensusConfig = &config.Aura
} else if cc.Bor != nil {
consensusConfig = &config.Bor
consensusConfig = cc.Bor
} else {
consensusConfig = &config.Ethash
}

View File

@ -32,6 +32,7 @@ import (
"time"
lru "github.com/hashicorp/golang-lru/arc/v2"
"github.com/ledgerwatch/erigon-lib/chain/networkname"
"github.com/ledgerwatch/erigon-lib/chain/snapcfg"
"github.com/ledgerwatch/erigon-lib/diagnostics"
@ -509,7 +510,7 @@ func New(ctx context.Context, stack *node.Node, config *ethconfig.Config, logger
} else if chainConfig.Aura != nil {
consensusConfig = &config.Aura
} else if chainConfig.Bor != nil {
consensusConfig = &config.Bor
consensusConfig = chainConfig.Bor
} else {
consensusConfig = &config.Ethash
}

View File

@ -34,8 +34,6 @@ import (
"github.com/ledgerwatch/erigon-lib/common/datadir"
"github.com/ledgerwatch/erigon-lib/downloader/downloadercfg"
"github.com/ledgerwatch/erigon-lib/txpool/txpoolcfg"
"github.com/ledgerwatch/erigon/consensus/bor/borcfg"
"github.com/ledgerwatch/erigon/cl/beacon/beacon_router_configuration"
"github.com/ledgerwatch/erigon/cl/clparams"
"github.com/ledgerwatch/erigon/consensus/ethash/ethashcfg"
@ -211,7 +209,6 @@ type Config struct {
Clique params.ConsensusSnapshotConfig
Aura chain.AuRaConfig
Bor borcfg.BorConfig
// Transaction pool options
DeprecatedTxPool DeprecatedTxPoolConfig