From f63cb14f240894039b3fbbb9fc939d033f6905d6 Mon Sep 17 00:00:00 2001 From: Ferran Borreguero Date: Thu, 9 Nov 2023 11:59:01 +0100 Subject: [PATCH 1/3] Add flag to sync rigil --- cmd/geth/main.go | 11 ++++++++ cmd/utils/flags.go | 6 ++++ suave/genesis/fixtures/rigil.json | 47 +++++++++++++++++++++++++++++++ suave/genesis/genesis.go | 14 +++++---- suave/genesis/genesis_test.go | 5 +++- suave/genesis/test.json | 1 - 6 files changed, 76 insertions(+), 8 deletions(-) create mode 100644 suave/genesis/fixtures/rigil.json delete mode 100644 suave/genesis/test.json diff --git a/cmd/geth/main.go b/cmd/geth/main.go index caf35eff5d..ecb275e220 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -344,6 +344,8 @@ func geth(ctx *cli.Context) error { return fmt.Errorf("failed to setup suave development mode: %v", err) } + prepareSuaveNetworksRemapping(ctx) + prepare(ctx) stack, backend := makeFullNode(ctx) defer stack.Close() @@ -482,6 +484,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) { diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 7180e51a57..07bac21398 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -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{ @@ -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...) diff --git a/suave/genesis/fixtures/rigil.json b/suave/genesis/fixtures/rigil.json new file mode 100644 index 0000000000..ea26ccf95a --- /dev/null +++ b/suave/genesis/fixtures/rigil.json @@ -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@13.59.100.95:0?discport=30303" + ] +} \ No newline at end of file diff --git a/suave/genesis/genesis.go b/suave/genesis/genesis.go index c6e104d430..00fa932993 100644 --- a/suave/genesis/genesis.go +++ b/suave/genesis/genesis.go @@ -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) { @@ -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 } diff --git a/suave/genesis/genesis_test.go b/suave/genesis/genesis_test.go index f6ad6b593f..36535cf254 100644 --- a/suave/genesis/genesis_test.go +++ b/suave/genesis/genesis_test.go @@ -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") diff --git a/suave/genesis/test.json b/suave/genesis/test.json deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/suave/genesis/test.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file From 02d111b031c2b19a2e27039999bee22c8a5c6aa8 Mon Sep 17 00:00:00 2001 From: Ferran Borreguero Date: Thu, 9 Nov 2023 11:59:48 +0100 Subject: [PATCH 2/3] Handle error --- cmd/geth/main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index ecb275e220..1503c0581b 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -344,7 +344,9 @@ func geth(ctx *cli.Context) error { return fmt.Errorf("failed to setup suave development mode: %v", err) } - prepareSuaveNetworksRemapping(ctx) + if err := prepareSuaveNetworksRemapping(ctx); err != nil { + return err + } prepare(ctx) stack, backend := makeFullNode(ctx) From 8402a53594aa4a3f299ca76c35c0609640cebb84 Mon Sep 17 00:00:00 2001 From: Ferran Borreguero Date: Fri, 10 Nov 2023 09:45:22 +0100 Subject: [PATCH 3/3] Update rigil genesis --- suave/genesis/fixtures/rigil.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/suave/genesis/fixtures/rigil.json b/suave/genesis/fixtures/rigil.json index ea26ccf95a..962c86b5e2 100644 --- a/suave/genesis/fixtures/rigil.json +++ b/suave/genesis/fixtures/rigil.json @@ -42,6 +42,6 @@ } }, "bootnodes": [ - "enode://3e575f38caa316c3c9cde227080578bbab03e3966e324616eaa22dac2aa085d9b77ac20c0fd0c67b7077b296b29db493af30a69e283d7a8c7c737203b5639ed2@13.59.100.95:0?discport=30303" + "enode://3e575f38caa316c3c9cde227080578bbab03e3966e324616eaa22dac2aa085d9b77ac20c0fd0c67b7077b296b29db493af30a69e283d7a8c7c737203b5639ed2@bootnode-0.rigil.suave.flashbots.net:0?discport=30303" ] } \ No newline at end of file