Skip to content

Commit

Permalink
disable milestones on local heimdall
Browse files Browse the repository at this point in the history
  • Loading branch information
battlmonstr committed Oct 25, 2023
1 parent 94e6853 commit 45d2573
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 4 deletions.
3 changes: 3 additions & 0 deletions cmd/devnet/args/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type Node struct {
StaticPeers string `arg:"--staticpeers" json:"staticpeers,omitempty"`
WithoutHeimdall bool `arg:"--bor.withoutheimdall" flag:"" default:"false" json:"bor.withoutheimdall,omitempty"`
HeimdallGRpc string `arg:"--bor.heimdallgRPC" json:"bor.heimdallgRPC,omitempty"`
WithHeimdallMilestones bool `arg:"--bor.milestone" json:"bor.milestone"`
VMDebug bool `arg:"--vmdebug" flag:"" default:"false" json:"dmdebug"`
}

Expand Down Expand Up @@ -86,6 +87,8 @@ func (node *Node) configure(base Node, nodeNumber int) error {

node.Port = base.Port + nodeNumber

node.WithHeimdallMilestones = base.WithHeimdallMilestones

return nil
}

Expand Down
44 changes: 40 additions & 4 deletions cmd/devnet/args/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,26 @@ func producingNodeArgs(dataDir string, nodeNumber int) []string {
authrpcPortArg, _ := parameterFromArgument("--authrpc.port", "8551")
natArg, _ := parameterFromArgument("--nat", "none")
accountSlotsArg, _ := parameterFromArgument("--txpool.accountslots", "16")

return []string{buildDirArg, dataDirArg, chainType, privateApiAddr, httpPortArg, authrpcPortArg, mine, httpApi, ws, natArg, devPeriod, consoleVerbosity, p2pProtocol, downloaderArg, accountSlotsArg}
withHeimdallMilestonesArg, _ := parameterFromArgument("--bor.milestone", "false")

return []string{
buildDirArg,
dataDirArg,
chainType,
privateApiAddr,
httpPortArg,
authrpcPortArg,
mine,
httpApi,
ws,
natArg,
devPeriod,
consoleVerbosity,
p2pProtocol,
downloaderArg,
accountSlotsArg,
withHeimdallMilestonesArg,
}
}

// nonMiningNodeArgs returns custom args for starting a non-mining node
Expand All @@ -182,6 +200,24 @@ func nonProducingNodeArgs(dataDir string, nodeNumber int, enode string) []string
authrpcPortArg, _ := parameterFromArgument("--authrpc.port", "8551")
natArg, _ := parameterFromArgument("--nat", "none")
ws := wsArg

return []string{buildDirArg, dataDirArg, chainType, privateApiAddr, httpPortArg, authrpcPortArg, httpApi, ws, natArg, staticPeers, noDiscover, consoleVerbosity, torrentPort, p2pProtocol, downloaderArg}
withHeimdallMilestonesArg, _ := parameterFromArgument("--bor.milestone", "false")

return []string{
buildDirArg,
dataDirArg,
chainType,
privateApiAddr,
httpPortArg,
authrpcPortArg,
httpApi,
ws,
natArg,
staticPeers,
noDiscover,
consoleVerbosity,
torrentPort,
p2pProtocol,
downloaderArg,
withHeimdallMilestonesArg,
}
}
8 changes: 8 additions & 0 deletions cmd/devnet/devnet/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"github.com/ledgerwatch/erigon/cmd/utils"
"math/big"
"net"
"os"
Expand Down Expand Up @@ -39,6 +40,7 @@ type Network struct {
BorStateSyncDelay time.Duration
BorPeriod time.Duration
BorMinBlockSize int
BorWithMilestones *bool
wg sync.WaitGroup
peers []string
namedNodes map[string]Node
Expand Down Expand Up @@ -75,6 +77,12 @@ func (nw *Network) Start(ctx context.Context) error {
Snapshots: nw.Snapshots,
}

if nw.BorWithMilestones != nil {
baseNode.WithHeimdallMilestones = *nw.BorWithMilestones
} else {
baseNode.WithHeimdallMilestones = utils.WithHeimdallMilestones.Value
}

cliCtx := CliContext(ctx)

metricsEnabled := cliCtx.Bool("metrics")
Expand Down
5 changes: 5 additions & 0 deletions cmd/devnet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"fmt"
"github.com/ledgerwatch/erigon/cmd/utils"
"os"
"os/signal"
"path/filepath"
Expand Down Expand Up @@ -364,11 +365,14 @@ func initDevnet(ctx *cli.Context, logger log.Logger) (devnet.Devnet, error) {
} else {
var heimdallGrpc string
var services []devnet.Service
var withMilestones = utils.WithHeimdallMilestones.Value

checkpointOwner := accounts.NewAccount("checkpoint-owner")

if ctx.Bool(LocalHeimdallFlag.Name) {
config := *params.BorDevnetChainConfig
// milestones are not supported yet on the local heimdall
withMilestones = false

if sprintSize := uint64(ctx.Int(BorSprintSizeFlag.Name)); sprintSize > 0 {
config.Bor.Sprint = map[string]uint64{"0": sprintSize}
Expand All @@ -394,6 +398,7 @@ func initDevnet(ctx *cli.Context, logger log.Logger) (devnet.Devnet, error) {
BaseRPCHost: baseRpcHost,
BaseRPCPort: baseRpcPort,
BorStateSyncDelay: 5 * time.Second,
BorWithMilestones: &withMilestones,
Services: append(services, account_services.NewFaucet(networkname.BorDevnetChainName, faucetSource)),
Alloc: types.GenesisAlloc{
faucetSource.Address: {Balance: accounts.EtherAmount(200_000)},
Expand Down

0 comments on commit 45d2573

Please sign in to comment.