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

Add flag to sync rigil #100

Merged
merged 3 commits into from
Nov 22, 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
13 changes: 13 additions & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ func geth(ctx *cli.Context) error {
return fmt.Errorf("failed to setup suave development mode: %v", err)
}

if err := prepareSuaveNetworksRemapping(ctx); err != nil {
return err
}

prepare(ctx)
stack, backend := makeFullNode(ctx)
defer stack.Close()
Expand Down Expand Up @@ -482,6 +486,15 @@ func unlockAccounts(ctx *cli.Context, stack *node.Node) {
}
}

func prepareSuaveNetworksRemapping(ctx *cli.Context) error {
if ctx.Bool(utils.RigilFlag.Name) {
if err := ctx.Set(utils.CustomChainFlag.Name, "rigil"); err != nil {
return err
}
}
return nil
}

func prepareSuaveDev(ctx *cli.Context) error {
// if suave dev mode is enabled, we need to set some defaults
if !ctx.Bool(utils.SuaveDevModeFlag.Name) {
Expand Down
6 changes: 6 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ var (
Usage: "Path to a custom chain specification file",
Category: flags.EthCategory,
}
RigilFlag = &cli.BoolFlag{
Name: "rigil",
Usage: "Rigil network: pre-configured proof-of-authority test network",
Category: flags.EthCategory,
}

// Dev mode
DeveloperFlag = &cli.BoolFlag{
Expand Down Expand Up @@ -996,6 +1001,7 @@ var (
SuaveFlag,
SepoliaFlag,
CustomChainFlag,
RigilFlag,
}
// NetworkFlags is the flag group of all built-in supported networks.
NetworkFlags = append([]cli.Flag{MainnetFlag}, TestnetFlags...)
Expand Down
47 changes: 47 additions & 0 deletions suave/genesis/fixtures/rigil.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "suave-rigil",
"config": {
"chainId": 16813125,
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"berlinBlock": 0,
"suaveBlock": 0,
"clique": {
"period": 4,
"epoch": 30000,
"initial_signers": [
"0981717712ed2c4919fdbc27dfc804800a9eeff9",
"0e5b9aa4925ed1beeb08d1c5a92477a1b719baa7",
"0e8705e07bbe1ce2c39093df3d20aaa5120bfc7a"
]
}
},
"difficulty": "1",
"gasLimit": "30000000",
"alloc": {
"7514bf4200868b9e40b6ea36bbeb6ce4965d4a57": {
"balance": "524288000000000000000000"
},
"a5104355c4cdca495fc00b17f4d8d29ad4fc0000": {
"balance": "524288000000000000000000"
},
"0981717712ed2c4919fdbc27dfc804800a9eeff9": {
"balance": "524288000000000000000000"
},
"0e5b9aa4925ed1beeb08d1c5a92477a1b719baa7": {
"balance": "524288000000000000000000"
},
"0e8705e07bbe1ce2c39093df3d20aaa5120bfc7a": {
"balance": "524288000000000000000000"
}
},
"bootnodes": [
"enode://3e575f38caa316c3c9cde227080578bbab03e3966e324616eaa22dac2aa085d9b77ac20c0fd0c67b7077b296b29db493af30a69e283d7a8c7c737203b5639ed2@bootnode-0.rigil.suave.flashbots.net:0?discport=30303"
]
}
14 changes: 8 additions & 6 deletions suave/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ package genesis

import (
"embed"
"io/fs"
"os"
"strings"
)

// Right now there is only a test.json file because
// the binary does not compile if the embed.FS is empty.
//
//go:embed *.json
//go:embed fixtures
var genesisFiles embed.FS

func Load(name string) ([]byte, error) {
Expand All @@ -22,8 +20,12 @@ func Load(name string) ([]byte, error) {
return genesisRaw, nil
}

// load 'name' frrom the embedded files
data, err := genesisFiles.ReadFile(name + ".json")
// load 'name' from the embedded files
fsys, err := fs.Sub(genesisFiles, "fixtures")
if err != nil {
return nil, err
}
data, err := fs.ReadFile(fsys, name+".json")
if err != nil {
return nil, err
}
Expand Down
5 changes: 4 additions & 1 deletion suave/genesis/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import (
)

func TestGenesis(t *testing.T) {
_, err := Load("test")
_, err := Load("genesis-test")
require.NoError(t, err)

_, err = Load("rigil")
require.NoError(t, err)

_, err = Load("./fixtures/genesis-test.json")
Expand Down
1 change: 0 additions & 1 deletion suave/genesis/test.json

This file was deleted.

Loading