Skip to content

Commit

Permalink
Check availability of preverified.toml contents (#12415)
Browse files Browse the repository at this point in the history
covers #12409
requires erigontech/erigon-snapshot#321

For actions for user i came up with checking network and giving a link
to github status page.
Can you guys give any other advice like to have some flag etc?

---------

Co-authored-by: alex.sharov <AskAlexSharov@gmail.com>
  • Loading branch information
awskii and AskAlexSharov authored Oct 23, 2024
1 parent e7cb625 commit 09d9ea8
Show file tree
Hide file tree
Showing 49 changed files with 314 additions and 240 deletions.
10 changes: 5 additions & 5 deletions cl/clparams/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1056,19 +1056,19 @@ func GetConfigsByNetwork(net NetworkType) (*NetworkConfig, *BeaconChainConfig) {

func GetConfigsByNetworkName(net string) (*NetworkConfig, *BeaconChainConfig, NetworkType, error) {
switch net {
case networkname.MainnetChainName:
case networkname.Mainnet:
networkCfg, beaconCfg := GetConfigsByNetwork(MainnetNetwork)
return networkCfg, beaconCfg, MainnetNetwork, nil
case networkname.SepoliaChainName:
case networkname.Sepolia:
networkCfg, beaconCfg := GetConfigsByNetwork(SepoliaNetwork)
return networkCfg, beaconCfg, SepoliaNetwork, nil
case networkname.GnosisChainName:
case networkname.Gnosis:
networkCfg, beaconCfg := GetConfigsByNetwork(GnosisNetwork)
return networkCfg, beaconCfg, GnosisNetwork, nil
case networkname.ChiadoChainName:
case networkname.Chiado:
networkCfg, beaconCfg := GetConfigsByNetwork(ChiadoNetwork)
return networkCfg, beaconCfg, ChiadoNetwork, nil
case networkname.HoleskyChainName:
case networkname.Holesky:
networkCfg, beaconCfg := GetConfigsByNetwork(HoleskyNetwork)
return networkCfg, beaconCfg, HoleskyNetwork, nil
default:
Expand Down
4 changes: 2 additions & 2 deletions cmd/devnet/args/node_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ func (m *BlockProducer) Configure(baseNode NodeArgs, nodeNumber int) error {
}

switch m.Chain {
case networkname.DevChainName:
case networkname.Dev:
if m.DevPeriod == 0 {
m.DevPeriod = 30
}
m.account = accounts.NewAccount(m.GetName() + "-etherbase")
core.DevnetEtherbase = m.account.Address
core.DevnetSignPrivateKey = m.account.SigKey()

case networkname.BorDevnetChainName:
case networkname.BorDevnet:
m.account = accounts.NewAccount(m.GetName() + "-etherbase")

if len(m.HttpApi) == 0 {
Expand Down
14 changes: 7 additions & 7 deletions cmd/devnet/contracts/steps/l1l2transfers.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func init() {

func GenerateSyncEvents(ctx context.Context, senderName string, numberOfTransfers int, minTransfer int, maxTransfer int) error {
sender := accounts.GetAccount(senderName)
ctx = devnet.WithCurrentNetwork(ctx, networkname.DevChainName)
ctx = devnet.WithCurrentNetwork(ctx, networkname.Dev)

auth, err := contracts.TransactOpts(ctx, sender.Address)

Expand Down Expand Up @@ -170,7 +170,7 @@ func GenerateSyncEvents(ctx context.Context, senderName string, numberOfTransfer

func DeployRootChainSender(ctx context.Context, deployerName string) (context.Context, error) {
deployer := accounts.GetAccount(deployerName)
ctx = devnet.WithCurrentNetwork(ctx, networkname.DevChainName)
ctx = devnet.WithCurrentNetwork(ctx, networkname.Dev)

auth, backend, err := contracts.DeploymentTransactor(ctx, deployer.Address)

Expand All @@ -197,15 +197,15 @@ func DeployRootChainSender(ctx context.Context, deployerName string) (context.Co
return nil, err
}

devnet.Logger(ctx).Info("RootSender deployed", "chain", networkname.DevChainName, "block", block.Number, "addr", address)
devnet.Logger(ctx).Info("RootSender deployed", "chain", networkname.Dev, "block", block.Number, "addr", address)

return scenarios.WithParam(ctx, "rootSenderAddress", address).
WithParam("rootSender", contract), nil
}

func DeployChildChainReceiver(ctx context.Context, deployerName string) (context.Context, error) {
deployer := accounts.GetAccount(deployerName)
ctx = devnet.WithCurrentNetwork(ctx, networkname.BorDevnetChainName)
ctx = devnet.WithCurrentNetwork(ctx, networkname.BorDevnet)

waiter, cancel := blocks.BlockWaiter(ctx, contracts.DeploymentChecker)
defer cancel()
Expand All @@ -222,15 +222,15 @@ func DeployChildChainReceiver(ctx context.Context, deployerName string) (context
return nil, err
}

devnet.Logger(ctx).Info("ChildReceiver deployed", "chain", networkname.BorDevnetChainName, "block", block.Number, "addr", address)
devnet.Logger(ctx).Info("ChildReceiver deployed", "chain", networkname.BorDevnet, "block", block.Number, "addr", address)

return scenarios.WithParam(ctx, "childReceiverAddress", address).
WithParam("childReceiver", contract), nil
}

func ProcessRootTransfers(ctx context.Context, sourceName string, numberOfTransfers int, minTransfer int, maxTransfer int) error {
source := accounts.GetAccount(sourceName)
ctx = devnet.WithCurrentNetwork(ctx, networkname.DevChainName)
ctx = devnet.WithCurrentNetwork(ctx, networkname.Dev)

auth, err := contracts.TransactOpts(ctx, source.Address)

Expand Down Expand Up @@ -380,7 +380,7 @@ func ProcessRootTransfers(ctx context.Context, sourceName string, numberOfTransf

func BatchProcessRootTransfers(ctx context.Context, sourceName string, batches int, transfersPerBatch, minTransfer int, maxTransfer int) error {
source := accounts.GetAccount(sourceName)
ctx = devnet.WithCurrentNetwork(ctx, networkname.DevChainName)
ctx = devnet.WithCurrentNetwork(ctx, networkname.Dev)

auth, err := contracts.TransactOpts(ctx, source.Address)

Expand Down
10 changes: 5 additions & 5 deletions cmd/devnet/contracts/steps/l2l1transfers.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func init() {

func DeployChildChainSender(ctx context.Context, deployerName string) (context.Context, error) {
deployer := accounts.GetAccount(deployerName)
ctx = devnet.WithCurrentNetwork(ctx, networkname.BorDevnetChainName)
ctx = devnet.WithCurrentNetwork(ctx, networkname.BorDevnet)

auth, backend, err := contracts.DeploymentTransactor(ctx, deployer.Address)

Expand All @@ -72,15 +72,15 @@ func DeployChildChainSender(ctx context.Context, deployerName string) (context.C
return nil, err
}

devnet.Logger(ctx).Info("ChildSender deployed", "chain", networkname.BorDevnetChainName, "block", block.Number, "addr", address)
devnet.Logger(ctx).Info("ChildSender deployed", "chain", networkname.BorDevnet, "block", block.Number, "addr", address)

return scenarios.WithParam(ctx, "childSenderAddress", address).
WithParam("childSender", contract), nil
}

func DeployRootChainReceiver(ctx context.Context, deployerName string) (context.Context, error) {
deployer := accounts.GetAccount(deployerName)
ctx = devnet.WithCurrentNetwork(ctx, networkname.DevChainName)
ctx = devnet.WithCurrentNetwork(ctx, networkname.Dev)

auth, backend, err := contracts.DeploymentTransactor(ctx, deployer.Address)

Expand All @@ -105,15 +105,15 @@ func DeployRootChainReceiver(ctx context.Context, deployerName string) (context.
return nil, err
}

devnet.Logger(ctx).Info("RootReceiver deployed", "chain", networkname.BorDevnetChainName, "block", block.Number, "addr", address)
devnet.Logger(ctx).Info("RootReceiver deployed", "chain", networkname.BorDevnet, "block", block.Number, "addr", address)

return scenarios.WithParam(ctx, "rootReceiverAddress", address).
WithParam("rootReceiver", contract), nil
}

func ProcessChildTransfers(ctx context.Context, sourceName string, numberOfTransfers int, minTransfer int, maxTransfer int) error {
source := accounts.GetAccount(sourceName)
ctx = devnet.WithCurrentNetwork(ctx, networkname.DevChainName)
ctx = devnet.WithCurrentNetwork(ctx, networkname.Dev)

auth, err := contracts.TransactOpts(ctx, source.Address)

Expand Down
6 changes: 5 additions & 1 deletion cmd/devnet/devnet/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,11 @@ func (n *devnetNode) run(ctx *cli.Context) error {

logger.Info("Build info", "git_branch", params.GitBranch, "git_tag", params.GitTag, "git_commit", params.GitCommit)

n.nodeCfg = enode.NewNodConfigUrfave(ctx, logger)
nodeConf, err := enode.NewNodConfigUrfave(ctx, logger)
if err != nil {
return err
}
n.nodeCfg = nodeConf
n.ethCfg = enode.NewEthConfigUrfave(ctx, n.nodeCfg, logger)

// These are set to prevent disk and page size churn which can be excessive
Expand Down
14 changes: 7 additions & 7 deletions cmd/devnet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var (
ChainFlag = cli.StringFlag{
Name: "chain",
Usage: "The devnet chain to run (dev,bor-devnet)",
Value: networkname.DevChainName,
Value: networkname.Dev,
}

ScenariosFlag = cli.StringFlag{
Expand Down Expand Up @@ -332,8 +332,8 @@ func allScenarios(cliCtx *cli.Context, runCtx devnet.Context) scenarios.Scenario
"state-sync": {
Steps: []*scenarios.Step{
{Text: "InitSubscriptions", Args: []any{[]requests.SubMethod{requests.Methods.ETHNewHeads}}},
{Text: "CreateAccountWithFunds", Args: []any{networkname.DevChainName, "root-funder", 200.0}},
{Text: "CreateAccountWithFunds", Args: []any{networkname.BorDevnetChainName, "child-funder", 200.0}},
{Text: "CreateAccountWithFunds", Args: []any{networkname.Dev, "root-funder", 200.0}},
{Text: "CreateAccountWithFunds", Args: []any{networkname.BorDevnet, "child-funder", 200.0}},
{Text: "DeployChildChainReceiver", Args: []any{"child-funder"}},
{Text: "DeployRootChainSender", Args: []any{"root-funder"}},
{Text: "GenerateSyncEvents", Args: []any{"root-funder", 10, 2, 2}},
Expand All @@ -343,8 +343,8 @@ func allScenarios(cliCtx *cli.Context, runCtx devnet.Context) scenarios.Scenario
},
"child-chain-exit": {
Steps: []*scenarios.Step{
{Text: "CreateAccountWithFunds", Args: []any{networkname.DevChainName, "root-funder", 200.0}},
{Text: "CreateAccountWithFunds", Args: []any{networkname.BorDevnetChainName, "child-funder", 200.0}},
{Text: "CreateAccountWithFunds", Args: []any{networkname.Dev, "root-funder", 200.0}},
{Text: "CreateAccountWithFunds", Args: []any{networkname.BorDevnet, "child-funder", 200.0}},
{Text: "DeployRootChainReceiver", Args: []any{"root-funder"}},
{Text: "DeployChildChainSender", Args: []any{"child-funder"}},
{Text: "ProcessChildTransfers", Args: []any{"child-funder", 1, 2, 2}},
Expand Down Expand Up @@ -420,7 +420,7 @@ func initDevnet(ctx *cli.Context, logger log.Logger) (devnet.Devnet, error) {
}

switch chainName {
case networkname.BorDevnetChainName:
case networkname.BorDevnet:
if ctx.Bool(WithoutHeimdallFlag.Name) {
return networks.NewBorDevnetWithoutHeimdall(dataDir, baseRpcHost, baseRpcPort, gasLimit, logger, consoleLogLevel, dirLogLevel), nil
} else if ctx.Bool(LocalHeimdallFlag.Name) {
Expand All @@ -431,7 +431,7 @@ func initDevnet(ctx *cli.Context, logger log.Logger) (devnet.Devnet, error) {
return networks.NewBorDevnetWithRemoteHeimdall(dataDir, baseRpcHost, baseRpcPort, producerCount, gasLimit, logger, consoleLogLevel, dirLogLevel), nil
}

case networkname.DevChainName:
case networkname.Dev:
return networks.NewDevDevnet(dataDir, baseRpcHost, baseRpcPort, producerCount, gasLimit, logger, consoleLogLevel, dirLogLevel), nil

default:
Expand Down
12 changes: 6 additions & 6 deletions cmd/devnet/networks/devnet_bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func NewBorDevnetWithoutHeimdall(

network := devnet.Network{
DataDir: dataDir,
Chain: networkname.BorDevnetChainName,
Chain: networkname.BorDevnet,
Logger: logger,
BasePort: 40303,
BasePrivateApiAddr: "localhost:10090",
Expand All @@ -61,7 +61,7 @@ func NewBorDevnetWithoutHeimdall(
GasLimit: gasLimit,
},
Services: []devnet.Service{
account_services.NewFaucet(networkname.BorDevnetChainName, faucetSource),
account_services.NewFaucet(networkname.BorDevnet, faucetSource),
},
Nodes: []devnet.Node{
&args.BlockProducer{
Expand Down Expand Up @@ -125,15 +125,15 @@ func NewBorDevnetWithHeimdall(

borNetwork := devnet.Network{
DataDir: dataDir,
Chain: networkname.BorDevnetChainName,
Chain: networkname.BorDevnet,
Logger: logger,
BasePort: 40303,
BasePrivateApiAddr: "localhost:10090",
BaseRPCHost: baseRpcHost,
BaseRPCPort: baseRpcPort,
BorStateSyncDelay: 5 * time.Second,
BorWithMilestones: &withMilestones,
Services: append(services, account_services.NewFaucet(networkname.BorDevnetChainName, faucetSource)),
Services: append(services, account_services.NewFaucet(networkname.BorDevnet, faucetSource)),
Genesis: &types.Genesis{
Alloc: types.GenesisAlloc{
faucetSource.Address: {Balance: accounts.EtherAmount(200_000)},
Expand All @@ -152,13 +152,13 @@ func NewBorDevnetWithHeimdall(

devNetwork := devnet.Network{
DataDir: dataDir,
Chain: networkname.DevChainName,
Chain: networkname.Dev,
Logger: logger,
BasePort: 30403,
BasePrivateApiAddr: "localhost:10190",
BaseRPCHost: baseRpcHost,
BaseRPCPort: baseRpcPort + 1000,
Services: append(services, account_services.NewFaucet(networkname.DevChainName, faucetSource)),
Services: append(services, account_services.NewFaucet(networkname.Dev, faucetSource)),
Genesis: &types.Genesis{
Alloc: types.GenesisAlloc{
faucetSource.Address: {Balance: accounts.EtherAmount(200_000)},
Expand Down
4 changes: 2 additions & 2 deletions cmd/devnet/networks/devnet_dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func NewDevDevnet(

network := devnet.Network{
DataDir: dataDir,
Chain: networkname.DevChainName,
Chain: networkname.Dev,
Logger: logger,
BasePrivateApiAddr: "localhost:10090",
BaseRPCHost: baseRpcHost,
Expand All @@ -70,7 +70,7 @@ func NewDevDevnet(
GasLimit: gasLimit,
},
Services: []devnet.Service{
account_services.NewFaucet(networkname.DevChainName, faucetSource),
account_services.NewFaucet(networkname.Dev, faucetSource),
},
MaxNumberOfEmptyBlockChecks: 30,
Nodes: append(nodes,
Expand Down
2 changes: 1 addition & 1 deletion cmd/devnet/services/polygon/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ func (h *Heimdall) getRootHash(ctx context.Context, start uint64, end uint64) (l
return libcommon.Hash{}, errors.New("number of headers requested exceeds")
}

return devnet.SelectBlockProducer(devnet.WithCurrentNetwork(ctx, networkname.BorDevnetChainName)).GetRootHash(ctx, start, end)
return devnet.SelectBlockProducer(devnet.WithCurrentNetwork(ctx, networkname.BorDevnet)).GetRootHash(ctx, start, end)
}

func (h *Heimdall) shouldSendCheckpoint(start uint64, end uint64) (bool, error) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/devnet/services/polygon/proofgenerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (pg *ProofGenerator) GenerateExitPayload(ctx context.Context, burnTxHash li
}

func (pg *ProofGenerator) getChainBlockInfo(ctx context.Context, burnTxHash libcommon.Hash) (uint64, uint64, error) {
childNode := devnet.SelectBlockProducer(devnet.WithCurrentNetwork(ctx, networkname.BorDevnetChainName))
childNode := devnet.SelectBlockProducer(devnet.WithCurrentNetwork(ctx, networkname.BorDevnet))

var wg sync.WaitGroup

Expand Down
12 changes: 6 additions & 6 deletions cmd/devnet/tests/bor_devnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ import (
func TestStateSync(t *testing.T) {
t.Skip()

runCtx, err := ContextStart(t, networkname.BorDevnetChainName)
runCtx, err := ContextStart(t, networkname.BorDevnet)
require.Nil(t, err)
var ctx context.Context = runCtx

t.Run("InitSubscriptions", func(t *testing.T) {
services.InitSubscriptions(ctx, []requests.SubMethod{requests.Methods.ETHNewHeads})
})
t.Run("CreateAccountWithFunds", func(t *testing.T) {
_, err := accounts_steps.CreateAccountWithFunds(ctx, networkname.DevChainName, "root-funder", 200.0)
_, err := accounts_steps.CreateAccountWithFunds(ctx, networkname.Dev, "root-funder", 200.0)
require.Nil(t, err)
})
t.Run("CreateAccountWithFunds", func(t *testing.T) {
_, err := accounts_steps.CreateAccountWithFunds(ctx, networkname.BorDevnetChainName, "child-funder", 200.0)
_, err := accounts_steps.CreateAccountWithFunds(ctx, networkname.BorDevnet, "child-funder", 200.0)
require.Nil(t, err)
})
t.Run("DeployChildChainReceiver", func(t *testing.T) {
Expand All @@ -73,16 +73,16 @@ func TestStateSync(t *testing.T) {
func TestChildChainExit(t *testing.T) {
t.Skip("FIXME: step CreateAccountWithFunds fails: Failed to get transfer tx: failed to search reserves for hashes: no block heads subscription")

runCtx, err := ContextStart(t, networkname.BorDevnetChainName)
runCtx, err := ContextStart(t, networkname.BorDevnet)
require.Nil(t, err)
var ctx context.Context = runCtx

t.Run("CreateAccountWithFunds", func(t *testing.T) {
_, err := accounts_steps.CreateAccountWithFunds(ctx, networkname.DevChainName, "root-funder", 200.0)
_, err := accounts_steps.CreateAccountWithFunds(ctx, networkname.Dev, "root-funder", 200.0)
require.Nil(t, err)
})
t.Run("CreateAccountWithFunds", func(t *testing.T) {
_, err := accounts_steps.CreateAccountWithFunds(ctx, networkname.BorDevnetChainName, "child-funder", 200.0)
_, err := accounts_steps.CreateAccountWithFunds(ctx, networkname.BorDevnet, "child-funder", 200.0)
require.Nil(t, err)
})
t.Run("DeployRootChainReceiver", func(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions cmd/devnet/tests/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ func initDevnet(chainName string, dataDir string, producerCount int, gasLimit ui
const baseRpcPort = 9545

switch chainName {
case networkname.BorDevnetChainName:
case networkname.BorDevnet:
heimdallURL := polygon.HeimdallURLDefault
const sprintSize uint64 = 0
return networks.NewBorDevnetWithLocalHeimdall(dataDir, baseRpcHost, baseRpcPort, heimdallURL, sprintSize, producerCount, gasLimit, logger, consoleLogLevel, dirLogLevel), nil

case networkname.DevChainName:
case networkname.Dev:
return networks.NewDevDevnet(dataDir, baseRpcHost, baseRpcPort, producerCount, gasLimit, logger, consoleLogLevel, dirLogLevel), nil

case "":
envChainName, _ := os.LookupEnv("DEVNET_CHAIN")
if envChainName == "" {
envChainName = networkname.DevChainName
envChainName = networkname.Dev
}
return initDevnet(envChainName, dataDir, producerCount, gasLimit, logger, consoleLogLevel, dirLogLevel)

Expand Down
7 changes: 5 additions & 2 deletions cmd/downloader/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,12 @@ func Downloader(ctx context.Context, logger log.Logger) error {
webseedsList = append(webseedsList, known...)
}
if seedbox {
snapcfg.LoadRemotePreverified()
_, err = downloadercfg.LoadSnapshotsHashes(ctx, dirs, chain)
if err != nil {
return err
}
}
cfg, err := downloadercfg.New(dirs, version, torrentLogLevel, downloadRate, uploadRate, torrentPort, torrentConnsPerFile, torrentDownloadSlots, staticPeers, webseedsList, chain, true, dbWritemap)
cfg, err := downloadercfg.New(ctx, dirs, version, torrentLogLevel, downloadRate, uploadRate, torrentPort, torrentConnsPerFile, torrentDownloadSlots, staticPeers, webseedsList, chain, true, dbWritemap)
if err != nil {
return err
}
Expand Down
5 changes: 4 additions & 1 deletion cmd/erigon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ func runErigon(cliCtx *cli.Context) error {
erigonInfoGauge := metrics.GetOrCreateGauge(fmt.Sprintf(`erigon_info{version="%s",commit="%s"}`, params.Version, params.GitCommit))
erigonInfoGauge.Set(1)

nodeCfg := node.NewNodConfigUrfave(cliCtx, logger)
nodeCfg, err := node.NewNodConfigUrfave(cliCtx, logger)
if err != nil {
return err
}
if err := datadir.ApplyMigrations(nodeCfg.Dirs); err != nil {
return err
}
Expand Down
Loading

0 comments on commit 09d9ea8

Please sign in to comment.