From 1d653e57abf70a4277dc184e3cac97e2a8b01b4f Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Tue, 18 Feb 2025 19:34:17 +0800 Subject: [PATCH 1/5] cmd, core: merge flags testnet and apothem --- cmd/XDC/chaincmd.go | 8 ++++---- cmd/XDC/config.go | 2 +- cmd/XDC/main.go | 3 +-- cmd/utils/flags.go | 24 +++++++----------------- core/genesis.go | 4 +--- 5 files changed, 14 insertions(+), 27 deletions(-) diff --git a/cmd/XDC/chaincmd.go b/cmd/XDC/chaincmd.go index 84dac53598..2b4dc5941c 100644 --- a/cmd/XDC/chaincmd.go +++ b/cmd/XDC/chaincmd.go @@ -45,7 +45,7 @@ var ( utils.DataDirFlag, utils.XDCXDataDirFlag, utils.LightModeFlag, - utils.XDCTestnetFlag, + utils.TestnetFlag, }, Description: ` The init command initializes a new genesis block and definition for the network. @@ -156,9 +156,9 @@ Use "ethereum dump 0" to dump the genesis block.`, func initGenesis(ctx *cli.Context) error { var err error genesis := new(core.Genesis) - if ctx.Bool(utils.XDCTestnetFlag.Name) { + if ctx.Bool(utils.TestnetFlag.Name) { if ctx.Args().Len() > 0 { - utils.Fatalf("Flags --apothem and genesis file can't be used at the same time") + utils.Fatalf("The testnet flag and genesis file can't be used at the same time") } err = json.Unmarshal(xdc_genesis.TestnetGenesis, &genesis) } else { @@ -168,7 +168,7 @@ func initGenesis(ctx *cli.Context) error { genesisPath := ctx.Args().First() if genesisPath == "mainnet" { err = json.Unmarshal(xdc_genesis.MainnetGenesis, &genesis) - } else if genesisPath == "testnet" { + } else if genesisPath == "testnet" || genesisPath == "apothem" { err = json.Unmarshal(xdc_genesis.TestnetGenesis, &genesis) } else if genesisPath == "devnet" { err = json.Unmarshal(xdc_genesis.DevnetGenesis, &genesis) diff --git a/cmd/XDC/config.go b/cmd/XDC/config.go index 38ff730bdf..b5e22c12e9 100644 --- a/cmd/XDC/config.go +++ b/cmd/XDC/config.go @@ -157,7 +157,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, XDCConfig) { } // Check testnet is enable. - if ctx.Bool(utils.XDCTestnetFlag.Name) { + if ctx.Bool(utils.TestnetFlag.Name) { common.IsTestnet = true common.TRC21IssuerSMC = common.TRC21IssuerSMCTestNet cfg.Eth.NetworkId = 51 diff --git a/cmd/XDC/main.go b/cmd/XDC/main.go index d87f5e2b61..f8c85e4746 100644 --- a/cmd/XDC/main.go +++ b/cmd/XDC/main.go @@ -117,10 +117,9 @@ var ( utils.NodeKeyHexFlag, //utils.DeveloperFlag, //utils.DeveloperPeriodFlag, - //utils.TestnetFlag, + utils.TestnetFlag, //utils.RinkebyFlag, //utils.VMEnableDebugFlag, - utils.XDCTestnetFlag, utils.Enable0xPrefixFlag, utils.EnableXDCPrefixFlag, utils.RewoundFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 569144c246..b781c20947 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -106,12 +106,8 @@ var ( } TestnetFlag = &cli.BoolFlag{ Name: "testnet", - Usage: "Ropsten network: pre-configured proof-of-work test network", - Category: flags.EthCategory, - } - XDCTestnetFlag = &cli.BoolFlag{ - Name: "apothem", - Usage: "XDC Apothem Network", + Aliases: []string{"apothem"}, + Usage: "XDC apothem network", Category: flags.EthCategory, } RinkebyFlag = &cli.BoolFlag{ @@ -883,14 +879,11 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) { if cfg.BootstrapNodes != nil { return // Already set by config file, don't apply defaults. } - networkID := uint64(0) - if ctx.IsSet(NetworkIdFlag.Name) { - networkID = ctx.Uint64(NetworkIdFlag.Name) - } + networkID := ctx.Uint64(NetworkIdFlag.Name) switch { - case ctx.Bool(XDCTestnetFlag.Name) || networkID == params.TestnetChainConfig.ChainId.Uint64(): + case ctx.Bool(TestnetFlag.Name) || networkID == 51: urls = params.TestnetBootnodes - case networkID == params.DevnetChainConfig.ChainId.Uint64(): + case networkID == 551: urls = params.DevnetBootnodes } } @@ -921,7 +914,7 @@ func setBootstrapNodesV5(ctx *cli.Context, cfg *p2p.Config) { urls = SplitAndTrim(ctx.String(BootnodesFlag.Name)) case ctx.IsSet(BootnodesV5Flag.Name): urls = SplitAndTrim(ctx.String(BootnodesV5Flag.Name)) - case ctx.Bool(XDCTestnetFlag.Name): + case ctx.Bool(TestnetFlag.Name): urls = params.TestnetBootnodes case cfg.BootstrapNodesV5 != nil: return // already set, don't apply defaults. @@ -1443,9 +1436,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { if ctx.IsSet(NetworkIdFlag.Name) { cfg.NetworkId = ctx.Uint64(NetworkIdFlag.Name) } - if ctx.Bool(XDCTestnetFlag.Name) { - cfg.NetworkId = 51 - } if ctx.IsSet(CacheFlag.Name) || ctx.IsSet(CacheDatabaseFlag.Name) { cfg.DatabaseCache = ctx.Int(CacheFlag.Name) * ctx.Int(CacheDatabaseFlag.Name) / 100 @@ -1501,7 +1491,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { switch { case ctx.Bool(TestnetFlag.Name): if !ctx.IsSet(NetworkIdFlag.Name) { - cfg.NetworkId = 3 + cfg.NetworkId = 51 } cfg.Genesis = core.DefaultTestnetGenesisBlock() case ctx.Bool(RinkebyFlag.Name): diff --git a/core/genesis.go b/core/genesis.go index 2540b99afb..224a47f143 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -281,10 +281,8 @@ func DefaultGenesisBlock() *Genesis { } } -// DefaultTestnetGenesisBlock returns the Ropsten network genesis block. +// DefaultTestnetGenesisBlock returns the XDC testnet genesis block. func DefaultTestnetGenesisBlock() *Genesis { - config := params.TestnetChainConfig - config.XDPoS.V2 = nil return &Genesis{ Config: params.TestnetChainConfig, Nonce: 0, From 54b4be1aa2a0928b6f1918d0a799c126710d5090 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Tue, 18 Feb 2025 20:52:39 +0800 Subject: [PATCH 2/5] cmd, core: add flag mainet and devnet --- cmd/XDC/chaincmd.go | 18 ++++++++++++++++-- cmd/XDC/consolecmd.go | 2 ++ cmd/XDC/main.go | 2 ++ cmd/utils/flags.go | 36 ++++++++++++++++++++++++++++++++++-- core/genesis.go | 18 +++++++++++++++--- 5 files changed, 69 insertions(+), 7 deletions(-) diff --git a/cmd/XDC/chaincmd.go b/cmd/XDC/chaincmd.go index 2b4dc5941c..d41d8aab9e 100644 --- a/cmd/XDC/chaincmd.go +++ b/cmd/XDC/chaincmd.go @@ -45,7 +45,9 @@ var ( utils.DataDirFlag, utils.XDCXDataDirFlag, utils.LightModeFlag, + utils.MainnetFlag, utils.TestnetFlag, + utils.DevnetFlag, }, Description: ` The init command initializes a new genesis block and definition for the network. @@ -154,19 +156,31 @@ Use "ethereum dump 0" to dump the genesis block.`, // initGenesis will initialise the given JSON format genesis file and writes it as // the zero'd block (i.e. genesis) or will fail hard if it can't succeed. func initGenesis(ctx *cli.Context) error { + utils.CheckExclusive(ctx, utils.MainnetFlag, utils.TestnetFlag, utils.DevnetFlag) + var err error genesis := new(core.Genesis) - if ctx.Bool(utils.TestnetFlag.Name) { + if ctx.Bool(utils.MainnetFlag.Name) { + if ctx.Args().Len() > 0 { + utils.Fatalf("The mainnet flag and genesis file can't be used at the same time") + } + err = json.Unmarshal(xdc_genesis.TestnetGenesis, &genesis) + } else if ctx.Bool(utils.TestnetFlag.Name) { if ctx.Args().Len() > 0 { utils.Fatalf("The testnet flag and genesis file can't be used at the same time") } err = json.Unmarshal(xdc_genesis.TestnetGenesis, &genesis) + } else if ctx.Bool(utils.DevnetFlag.Name) { + if ctx.Args().Len() > 0 { + utils.Fatalf("The devnet flag and genesis file can't be used at the same time") + } + err = json.Unmarshal(xdc_genesis.TestnetGenesis, &genesis) } else { if ctx.Args().Len() != 1 { utils.Fatalf("need the genesis.json file or the network name [ mainnet | testnet | devnet ] as the only argument") } genesisPath := ctx.Args().First() - if genesisPath == "mainnet" { + if genesisPath == "mainnet" || genesisPath == "xinfin" { err = json.Unmarshal(xdc_genesis.MainnetGenesis, &genesis) } else if genesisPath == "testnet" || genesisPath == "apothem" { err = json.Unmarshal(xdc_genesis.TestnetGenesis, &genesis) diff --git a/cmd/XDC/consolecmd.go b/cmd/XDC/consolecmd.go index 8fb64a99c9..77627e7df3 100644 --- a/cmd/XDC/consolecmd.go +++ b/cmd/XDC/consolecmd.go @@ -125,6 +125,8 @@ func remoteConsole(ctx *cli.Context) error { if path != "" { if ctx.Bool(utils.TestnetFlag.Name) { path = filepath.Join(path, "testnet") + } else if ctx.Bool(utils.DevnetFlag.Name) { + path = filepath.Join(path, "devnet") } else if ctx.Bool(utils.RinkebyFlag.Name) { path = filepath.Join(path, "rinkeby") } diff --git a/cmd/XDC/main.go b/cmd/XDC/main.go index f8c85e4746..125887cc37 100644 --- a/cmd/XDC/main.go +++ b/cmd/XDC/main.go @@ -117,7 +117,9 @@ var ( utils.NodeKeyHexFlag, //utils.DeveloperFlag, //utils.DeveloperPeriodFlag, + utils.MainnetFlag, utils.TestnetFlag, + utils.DevnetFlag, //utils.RinkebyFlag, //utils.VMEnableDebugFlag, utils.Enable0xPrefixFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index b781c20947..bcd6d434a7 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -104,12 +104,23 @@ var ( Value: ethconfig.Defaults.NetworkId, Category: flags.EthCategory, } + MainnetFlag = &cli.BoolFlag{ + Name: "mainnet", + Aliases: []string{"xinfin"}, + Usage: "XDC xinfin network", + Category: flags.EthCategory, + } TestnetFlag = &cli.BoolFlag{ Name: "testnet", Aliases: []string{"apothem"}, Usage: "XDC apothem network", Category: flags.EthCategory, } + DevnetFlag = &cli.BoolFlag{ + Name: "devnet", + Usage: "XDC develop network", + Category: flags.EthCategory, + } RinkebyFlag = &cli.BoolFlag{ Name: "rinkeby", Usage: "Rinkeby network: pre-configured proof-of-authority test network", @@ -819,6 +830,9 @@ func MakeDataDir(ctx *cli.Context) string { if ctx.Bool(TestnetFlag.Name) { return filepath.Join(path, "testnet") } + if ctx.Bool(DevnetFlag.Name) { + return filepath.Join(path, "devnet") + } if ctx.Bool(RinkebyFlag.Name) { return filepath.Join(path, "rinkeby") } @@ -883,7 +897,7 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) { switch { case ctx.Bool(TestnetFlag.Name) || networkID == 51: urls = params.TestnetBootnodes - case networkID == 551: + case ctx.Bool(DevnetFlag.Name) || networkID == 551: urls = params.DevnetBootnodes } } @@ -916,6 +930,8 @@ func setBootstrapNodesV5(ctx *cli.Context, cfg *p2p.Config) { urls = SplitAndTrim(ctx.String(BootnodesV5Flag.Name)) case ctx.Bool(TestnetFlag.Name): urls = params.TestnetBootnodes + case ctx.Bool(DevnetFlag.Name): + urls = params.DevnetBootnodes case cfg.BootstrapNodesV5 != nil: return // already set, don't apply defaults. } @@ -1193,6 +1209,8 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) { cfg.DataDir = "" // unless explicitly requested, use memory databases case ctx.Bool(TestnetFlag.Name): cfg.DataDir = filepath.Join(node.DefaultDataDir(), "testnet") + case ctx.Bool(DevnetFlag.Name): + cfg.DataDir = filepath.Join(node.DefaultDataDir(), "devnet") case ctx.Bool(RinkebyFlag.Name): cfg.DataDir = filepath.Join(node.DefaultDataDir(), "rinkeby") } @@ -1386,7 +1404,7 @@ func SetXDCXConfig(ctx *cli.Context, cfg *XDCx.Config, XDCDataDir string) { // SetEthConfig applies eth-related command line flags to the config. func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { // Avoid conflicting network flags - CheckExclusive(ctx, DeveloperFlag, TestnetFlag, RinkebyFlag) + CheckExclusive(ctx, MainnetFlag, TestnetFlag, DevnetFlag, DeveloperFlag, RinkebyFlag) CheckExclusive(ctx, FastSyncFlag, LightModeFlag, SyncModeFlag) CheckExclusive(ctx, LightServFlag, LightModeFlag) CheckExclusive(ctx, LightServFlag, SyncModeFlag, "light") @@ -1489,11 +1507,21 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { } // Override any default configs for hard coded networks. switch { + case ctx.Bool(MainnetFlag.Name): + if !ctx.IsSet(NetworkIdFlag.Name) { + cfg.NetworkId = 50 + } + cfg.Genesis = core.DefaultGenesisBlock() case ctx.Bool(TestnetFlag.Name): if !ctx.IsSet(NetworkIdFlag.Name) { cfg.NetworkId = 51 } cfg.Genesis = core.DefaultTestnetGenesisBlock() + case ctx.Bool(DevnetFlag.Name): + if !ctx.IsSet(NetworkIdFlag.Name) { + cfg.NetworkId = 551 + } + cfg.Genesis = core.DefaultDevnetGenesisBlock() case ctx.Bool(RinkebyFlag.Name): if !ctx.IsSet(NetworkIdFlag.Name) { cfg.NetworkId = 4 @@ -1618,8 +1646,12 @@ func MakeChainDatabase(ctx *cli.Context, stack *node.Node, readonly bool) ethdb. func MakeGenesis(ctx *cli.Context) *core.Genesis { var genesis *core.Genesis switch { + case ctx.Bool(MainnetFlag.Name): + genesis = core.DefaultGenesisBlock() case ctx.Bool(TestnetFlag.Name): genesis = core.DefaultTestnetGenesisBlock() + case ctx.Bool(DevnetFlag.Name): + genesis = core.DefaultDevnetGenesisBlock() case ctx.Bool(RinkebyFlag.Name): genesis = core.DefaultRinkebyGenesisBlock() case ctx.Bool(DeveloperFlag.Name): diff --git a/core/genesis.go b/core/genesis.go index 224a47f143..418d77e8f7 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -267,11 +267,10 @@ func GenesisBlockForTesting(db ethdb.Database, addr common.Address, balance *big return g.MustCommit(db) } -// DefaultGenesisBlock returns the Ethereum main net genesis block. +// DefaultGenesisBlock returns the XDC mainnet genesis block. func DefaultGenesisBlock() *Genesis { - config := params.XDCMainnetChainConfig return &Genesis{ - Config: config, + Config: params.XDCMainnetChainConfig, Nonce: 0, ExtraData: hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000000025c65b4b379ac37cf78357c4915f73677022eaffc7d49d0a2cf198deebd6ce581af465944ec8b2bbcfccdea1006a5cfa7d9484b5b293b46964c265c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"), GasLimit: 4700000, @@ -294,6 +293,19 @@ func DefaultTestnetGenesisBlock() *Genesis { } } +// DefaultDevnetGenesisBlock returns the XDC devnet genesis block. +func DefaultDevnetGenesisBlock() *Genesis { + return &Genesis{ + Config: params.DevnetChainConfig, + Nonce: 0, + ExtraData: hexutil.MustDecode("0x0000000000000000000000000000000000000000000000000000000000000000311bdf9066246e68559816e7f636435867f824ef442a44a6fc20f5b8dfa8b304d7137581f7e6bef347318441696e9ae962633c16e04d53935272639d537fc89618edae86950e12687a612e15c4786b8473898cc3c5beca5841306b26fdb4e30411392a6a74826141342a4dc33a1045cefa4182b6212ec0317bc30fbeb7208192d1474b5f87ffbc056de43c11888c073313b36cf03cf1f739f39443551ff12bbe8d993351c0e2db739f9bcbfdeda94d73b50b16d3a242960b7ca1937e826bda6c397df74d9f9ab01aa89af636787499e81362e815e36f28763eac120babebf5a6cbe6113780cbe489e3eb0db882381aebaf81190100d82f41ad2c95898195c7a47dc59115bb5ec85408683795da2f604a5c0464868eabfcb6da489a1b4304f49aafaec938c7adc48539470624e1f9c75ce33e568d8fa3ace90497ee0c60dc921eefea93e384a6ccaaf28e33790a2d1b2625bf964dfc087e2622b02b0bb78713e872c02796ef64c8f10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"), + GasLimit: 4700000, + Difficulty: big.NewInt(1), + Alloc: DecodeAllocJson(DevnetAllocData), + Timestamp: 1735513074, + } +} + // DefaultRinkebyGenesisBlock returns the Rinkeby network genesis block. func DefaultRinkebyGenesisBlock() *Genesis { return &Genesis{ From 98cff5d6c277c3bef1c7d881dfe9ef94debc580f Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Tue, 18 Feb 2025 21:03:52 +0800 Subject: [PATCH 3/5] all: remove network rinkeby --- cmd/XDC/consolecmd.go | 2 -- cmd/XDC/main.go | 1 - cmd/utils/flags.go | 19 +------------------ core/genesis.go | 26 -------------------------- eth/handler.go | 2 +- les/handler.go | 2 +- params/config.go | 23 ----------------------- 7 files changed, 3 insertions(+), 72 deletions(-) diff --git a/cmd/XDC/consolecmd.go b/cmd/XDC/consolecmd.go index 77627e7df3..fb5b7de77d 100644 --- a/cmd/XDC/consolecmd.go +++ b/cmd/XDC/consolecmd.go @@ -127,8 +127,6 @@ func remoteConsole(ctx *cli.Context) error { path = filepath.Join(path, "testnet") } else if ctx.Bool(utils.DevnetFlag.Name) { path = filepath.Join(path, "devnet") - } else if ctx.Bool(utils.RinkebyFlag.Name) { - path = filepath.Join(path, "rinkeby") } } endpoint = fmt.Sprintf("%s/XDC.ipc", path) diff --git a/cmd/XDC/main.go b/cmd/XDC/main.go index 125887cc37..bd1c10f04c 100644 --- a/cmd/XDC/main.go +++ b/cmd/XDC/main.go @@ -120,7 +120,6 @@ var ( utils.MainnetFlag, utils.TestnetFlag, utils.DevnetFlag, - //utils.RinkebyFlag, //utils.VMEnableDebugFlag, utils.Enable0xPrefixFlag, utils.EnableXDCPrefixFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index bcd6d434a7..c337100f0a 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -121,11 +121,6 @@ var ( Usage: "XDC develop network", Category: flags.EthCategory, } - RinkebyFlag = &cli.BoolFlag{ - Name: "rinkeby", - Usage: "Rinkeby network: pre-configured proof-of-authority test network", - Category: flags.EthCategory, - } // Dev mode DeveloperFlag = &cli.BoolFlag{ @@ -833,9 +828,6 @@ func MakeDataDir(ctx *cli.Context) string { if ctx.Bool(DevnetFlag.Name) { return filepath.Join(path, "devnet") } - if ctx.Bool(RinkebyFlag.Name) { - return filepath.Join(path, "rinkeby") - } return path } Fatalf("Cannot determine default data directory, please set manually (--datadir)") @@ -1211,8 +1203,6 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) { cfg.DataDir = filepath.Join(node.DefaultDataDir(), "testnet") case ctx.Bool(DevnetFlag.Name): cfg.DataDir = filepath.Join(node.DefaultDataDir(), "devnet") - case ctx.Bool(RinkebyFlag.Name): - cfg.DataDir = filepath.Join(node.DefaultDataDir(), "rinkeby") } if ctx.IsSet(KeyStoreDirFlag.Name) { @@ -1404,7 +1394,7 @@ func SetXDCXConfig(ctx *cli.Context, cfg *XDCx.Config, XDCDataDir string) { // SetEthConfig applies eth-related command line flags to the config. func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { // Avoid conflicting network flags - CheckExclusive(ctx, MainnetFlag, TestnetFlag, DevnetFlag, DeveloperFlag, RinkebyFlag) + CheckExclusive(ctx, MainnetFlag, TestnetFlag, DevnetFlag, DeveloperFlag) CheckExclusive(ctx, FastSyncFlag, LightModeFlag, SyncModeFlag) CheckExclusive(ctx, LightServFlag, LightModeFlag) CheckExclusive(ctx, LightServFlag, SyncModeFlag, "light") @@ -1522,11 +1512,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { cfg.NetworkId = 551 } cfg.Genesis = core.DefaultDevnetGenesisBlock() - case ctx.Bool(RinkebyFlag.Name): - if !ctx.IsSet(NetworkIdFlag.Name) { - cfg.NetworkId = 4 - } - cfg.Genesis = core.DefaultRinkebyGenesisBlock() case ctx.Bool(DeveloperFlag.Name): // Create new developer account or reuse existing one var ( @@ -1652,8 +1637,6 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis { genesis = core.DefaultTestnetGenesisBlock() case ctx.Bool(DevnetFlag.Name): genesis = core.DefaultDevnetGenesisBlock() - case ctx.Bool(RinkebyFlag.Name): - genesis = core.DefaultRinkebyGenesisBlock() case ctx.Bool(DeveloperFlag.Name): Fatalf("Developer chains are ephemeral") } diff --git a/core/genesis.go b/core/genesis.go index 418d77e8f7..689d7d0979 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -21,7 +21,6 @@ import ( "errors" "fmt" "math/big" - "strings" "github.com/XinFinOrg/XDPoSChain/common" "github.com/XinFinOrg/XDPoSChain/common/hexutil" @@ -33,7 +32,6 @@ import ( "github.com/XinFinOrg/XDPoSChain/ethdb" "github.com/XinFinOrg/XDPoSChain/log" "github.com/XinFinOrg/XDPoSChain/params" - "github.com/XinFinOrg/XDPoSChain/rlp" ) //go:generate go run github.com/fjl/gencodec -type Genesis -field-override genesisSpecMarshaling -out gen_genesis.go @@ -306,18 +304,6 @@ func DefaultDevnetGenesisBlock() *Genesis { } } -// DefaultRinkebyGenesisBlock returns the Rinkeby network genesis block. -func DefaultRinkebyGenesisBlock() *Genesis { - return &Genesis{ - Config: params.RinkebyChainConfig, - Timestamp: 1492009146, - ExtraData: hexutil.MustDecode("0x52657370656374206d7920617574686f7269746168207e452e436172746d616e42eb768f2244c8811c63729a21a3569731535f067ffc57839b00206d1ad20c69a1981b489f772031b279182d99e65703f0076e4812653aab85fca0f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"), - GasLimit: 4700000, - Difficulty: big.NewInt(1), - Alloc: decodePrealloc(""), - } -} - // DeveloperGenesisBlock returns the 'geth --dev' genesis block. Note, this must // be seeded with the func DeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis { @@ -346,18 +332,6 @@ func DeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis { } } -func decodePrealloc(data string) types.GenesisAlloc { - var p []struct{ Addr, Balance *big.Int } - if err := rlp.NewStream(strings.NewReader(data), 0).Decode(&p); err != nil { - panic(err) - } - ga := make(types.GenesisAlloc, len(p)) - for _, account := range p { - ga[common.BigToAddress(account.Addr)] = types.Account{Balance: account.Balance} - } - return ga -} - func DecodeAllocJson(s string) types.GenesisAlloc { alloc := types.GenesisAlloc{} json.Unmarshal([]byte(s), &alloc) diff --git a/eth/handler.go b/eth/handler.go index 7ac5c633f7..0abf711fe2 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -1080,7 +1080,7 @@ func (pm *ProtocolManager) lendingTxBroadcastLoop() { // NodeInfo represents a short summary of the Ethereum sub-protocol metadata // known about the host peer. type NodeInfo struct { - Network uint64 `json:"network"` // Ethereum network ID (1=Frontier, 2=Morden, Ropsten=3, Rinkeby=4) + Network uint64 `json:"network"` // XDC network ID (50=xinfin, 51=apothem, 551=devnet) Difficulty *big.Int `json:"difficulty"` // Total difficulty of the host's blockchain Genesis common.Hash `json:"genesis"` // SHA3 hash of the host's genesis block Config *params.ChainConfig `json:"config"` // Chain configuration for the fork rules diff --git a/les/handler.go b/les/handler.go index bef0fd6467..d988101004 100644 --- a/les/handler.go +++ b/les/handler.go @@ -1184,7 +1184,7 @@ func (pm *ProtocolManager) txStatus(hashes []common.Hash) []txStatus { // NodeInfo represents a short summary of the Ethereum sub-protocol metadata // known about the host peer. type NodeInfo struct { - Network uint64 `json:"network"` // Ethereum network ID (1=Frontier, 2=Morden, Ropsten=3, Rinkeby=4) + Network uint64 `json:"network"` // XDC network ID (50=xinfin, 51=apothem, 551=devnet) Difficulty *big.Int `json:"difficulty"` // Total difficulty of the host's blockchain Genesis common.Hash `json:"genesis"` // SHA3 hash of the host's genesis block Config *params.ChainConfig `json:"config"` // Chain configuration for the fork rules diff --git a/params/config.go b/params/config.go index 971892bc13..67007c7871 100644 --- a/params/config.go +++ b/params/config.go @@ -240,29 +240,6 @@ var ( }, } - // RinkebyChainConfig contains the chain parameters to run a node on the Rinkeby test network. - RinkebyChainConfig = &ChainConfig{ - ChainId: big.NewInt(4), - HomesteadBlock: big.NewInt(1), - DAOForkBlock: nil, - DAOForkSupport: true, - EIP150Block: big.NewInt(2), - EIP155Block: big.NewInt(3), - EIP158Block: big.NewInt(3), - ByzantiumBlock: big.NewInt(1035301), - ConstantinopleBlock: nil, - XDPoS: &XDPoSConfig{ - Period: 15, - Epoch: 900, - V2: &V2{ - SwitchEpoch: 9999999999 / 900, - SwitchBlock: big.NewInt(9999999999), - CurrentConfig: MainnetV2Configs[0], - AllConfigs: MainnetV2Configs, - }, - }, - } - // AllEthashProtocolChanges contains every protocol change (EIPs) introduced // and accepted by the Ethereum core developers into the Ethash consensus. // From 5f750498f4cc26389b6b6f0a6b825538a6f49d71 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Tue, 18 Feb 2025 21:06:37 +0800 Subject: [PATCH 4/5] les: copy constans after get networkID --- les/backend.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/les/backend.go b/les/backend.go index 0f250f5181..3b0f6bed41 100644 --- a/les/backend.go +++ b/les/backend.go @@ -92,6 +92,12 @@ func New(ctx *node.ServiceContext, config *ethconfig.Config) (*LightEthereum, er return nil, genesisErr } + networkID := config.NetworkId + if networkID == 0 { + networkID = chainConfig.ChainId.Uint64() + } + common.CopyConstans(networkID) + log.Info(strings.Repeat("-", 153)) for _, line := range strings.Split(chainConfig.Description(), "\n") { log.Info(line) @@ -101,10 +107,6 @@ func New(ctx *node.ServiceContext, config *ethconfig.Config) (*LightEthereum, er peers := newPeerSet() quitSync := make(chan struct{}) - networkID := config.NetworkId - if networkID == 0 { - networkID = chainConfig.ChainId.Uint64() - } leth := &LightEthereum{ config: config, chainConfig: chainConfig, From 1819d5b7b46c855e36005c5665aa0e744593e585 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Wed, 19 Feb 2025 15:51:30 +0800 Subject: [PATCH 5/5] common: set eip1559Block to 0 for local net --- common/constants.local.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/constants.local.go b/common/constants.local.go index 737b609182..5626c97a08 100644 --- a/common/constants.local.go +++ b/common/constants.local.go @@ -28,7 +28,7 @@ var localConstant = constant{ TIPV2SwitchBlock: big.NewInt(0), tipXDCXMinerDisable: big.NewInt(0), tipXDCXReceiverDisable: big.NewInt(0), - eip1559Block: big.NewInt(9999999999), + eip1559Block: big.NewInt(0), cancunBlock: big.NewInt(9999999999), trc21IssuerSMCTestNet: HexToAddress("0x0E2C88753131CE01c7551B726b28BFD04e44003F"),