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 : amoy flags and genesis #1072

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Heimdall client version: [e.g. v0.2.10] <!--Can be found by running the command

OS & Version: Windows / Linux / OSX

Environment: Polygon Mainnet / Polygon Mumbai / Devnet
Environment: Polygon Mainnet / Polygon Mumbai / Polygon Amoy / Devnet

Type of node: Validator / Sentry / Archive

Expand Down
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ In case this PR includes changes that must be applied only to a subset of nodes,
- [ ] I have added tests to CI
- [ ] I have tested this code manually on local environment
- [ ] I have tested this code manually on remote devnet using express-cli
- [ ] I have tested this code manually on mumbai
- [ ] I have tested this code manually on mumbai/amoy
- [ ] I have created new e2e tests into express-cli

### Manual tests
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ The easiest way to get started with bor is to install the packages using the com

curl -L https://raw.githubusercontent.com/maticnetwork/install/main/bor.sh | bash -s -- v0.4.0 <network> <node_type>

The network accepts `mainnet` or `mumbai` and the node type accepts `validator` or `sentry` or `archive`. The installation script does the following things:
The network accepts `mainnet`,`amoy` or `mumbai` and the node type accepts `validator` or `sentry` or `archive`. The installation script does the following things:
- Create a new user named `bor`.
- Install the bor binary at `/usr/bin/bor`.
- Dump the suitable config file (based on the network and node type provided) at `/var/lib/bor` and uses it as the home dir.
- Create a systemd service named `bor` at `/lib/systemd/system/bor.service` which starts bor using the config file as `bor` user.

The releases supports both the networks i.e. Polygon Mainnet and Mumbai (Testnet) unless explicitly specified. Before the stable release for mainnet, pre-releases will be available marked with `beta` tag for deploying on Mumbai (testnet). On sufficient testing, stable release for mainnet will be announced with a forum post.
The releases supports both the networks i.e. Polygon Mainnet, Amoy and Mumbai (Testnet) unless explicitly specified. Before the stable release for mainnet, pre-releases will be available marked with `beta` tag for deploying on Mumbai/Amoy (testnet). On sufficient testing, stable release for mainnet will be announced with a forum post.
0xsharma marked this conversation as resolved.
Show resolved Hide resolved

### Building from source

Expand Down
2 changes: 1 addition & 1 deletion builder/files/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# `mine`, `etherbase`, `nodiscover`, `maxpeers`, `keystore`, `allow-insecure-unlock`, `password`, `unlock`

chain = "mainnet"
# chain = "mumbai"
# chain = "mumbai", "amoy"
# identity = "Annon-Identity"
# verbosity = 3
# vmdebug = false
Expand Down
2 changes: 2 additions & 0 deletions cmd/devp2p/nodesetcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ func minAgeFilter(args []string) (nodeFilter, error) {
return f, nil
}

// TODO : 0xSharma : Add amoy genesis hash

func ethFilter(args []string) (nodeFilter, error) {
var filter forkid.Filter

Expand Down
7 changes: 5 additions & 2 deletions cmd/faucet/faucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ var (
goerliFlag = flag.Bool("goerli", false, "Initializes the faucet with Görli network config")
sepoliaFlag = flag.Bool("sepolia", false, "Initializes the faucet with Sepolia network config")
mumbaiFlag = flag.Bool("bor-mumbai", false, "Initializes the faucet with Bor-Mumbai network config")
amoyFlag = flag.Bool("bor-amoy", false, "Initializes the faucet with Bor-Amoy network config")
)

var (
Expand Down Expand Up @@ -146,7 +147,7 @@ func main() {
log.Crit("Failed to render the faucet template", "err", err)
}
// Load and parse the genesis block requested by the user
genesis, err := getGenesis(*genesisFlag, *goerliFlag, *sepoliaFlag, *mumbaiFlag)
genesis, err := getGenesis(*genesisFlag, *goerliFlag, *sepoliaFlag, *mumbaiFlag, *amoyFlag)
if err != nil {
log.Crit("Failed to parse genesis config", "err", err)
}
Expand Down Expand Up @@ -967,7 +968,7 @@ func authNoAuth(url string) (string, string, common.Address, error) {
}

// getGenesis returns a genesis based on input args
func getGenesis(genesisFlag string, goerliFlag bool, sepoliaFlag bool, mumbaiFlag bool) (*core.Genesis, error) {
func getGenesis(genesisFlag string, goerliFlag bool, sepoliaFlag bool, mumbaiFlag bool, amoyFlag bool) (*core.Genesis, error) {
switch {
case genesisFlag != "":
var genesis core.Genesis
Expand All @@ -980,6 +981,8 @@ func getGenesis(genesisFlag string, goerliFlag bool, sepoliaFlag bool, mumbaiFla
return core.DefaultSepoliaGenesisBlock(), nil
case mumbaiFlag:
return core.DefaultMumbaiGenesisBlock(), nil
case amoyFlag:
return core.DefaultAmoyGenesisBlock(), nil
default:
return nil, fmt.Errorf("no genesis flag provided")
}
Expand Down
28 changes: 28 additions & 0 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
setDefaultMumbaiGethConfig(ctx, &cfg)
}

if ctx.IsSet(utils.AmoyFlag.Name) {
setDefaultAmoyGethConfig(ctx, &cfg)
}

if ctx.IsSet(utils.BorMainnetFlag.Name) {
setDefaultBorMainnetGethConfig(ctx, &cfg)
}
Expand Down Expand Up @@ -348,6 +352,30 @@ func setDefaultMumbaiGethConfig(ctx *cli.Context, config *gethConfig) {
// --pprof is enabled in 'internal/debug/flags.go'
}

// nolint : wsl
func setDefaultAmoyGethConfig(ctx *cli.Context, config *gethConfig) {
config.Node.P2P.ListenAddr = fmt.Sprintf(":%d", 30303)
config.Node.HTTPHost = "0.0.0.0"
0xsharma marked this conversation as resolved.
Show resolved Hide resolved
config.Node.HTTPVirtualHosts = []string{"*"}
config.Node.HTTPCors = []string{"*"}
config.Node.HTTPPort = 8545
config.Node.IPCPath = utils.MakeDataDir(ctx) + "/bor.ipc"
config.Node.HTTPModules = []string{"eth", "net", "web3", "txpool", "bor"}
config.Eth.SyncMode = downloader.FullSync
config.Eth.NetworkId = 80001
0xsharma marked this conversation as resolved.
Show resolved Hide resolved
config.Eth.Miner.GasCeil = 20000000
//--miner.gastarget is deprecated, No longed used
config.Eth.TxPool.NoLocals = true
config.Eth.TxPool.AccountSlots = 16
config.Eth.TxPool.GlobalSlots = 131072
config.Eth.TxPool.AccountQueue = 64
config.Eth.TxPool.GlobalQueue = 131072
config.Eth.TxPool.Lifetime = 90 * time.Minute
config.Node.P2P.MaxPeers = 50
config.Metrics.Enabled = true
// --pprof is enabled in 'internal/debug/flags.go'
}

func setDefaultBorMainnetGethConfig(ctx *cli.Context, config *gethConfig) {
config.Node.P2P.ListenAddr = fmt.Sprintf(":%d", 30303)
config.Node.HTTPHost = "0.0.0.0"
Expand Down
2 changes: 1 addition & 1 deletion cmd/geth/consolecmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func remoteConsole(ctx *cli.Context) error {
if path != "" {
if ctx.Bool(utils.GoerliFlag.Name) {
path = filepath.Join(path, "goerli")
} else if ctx.Bool(utils.MumbaiFlag.Name) || ctx.Bool(utils.BorMainnetFlag.Name) {
} else if ctx.Bool(utils.MumbaiFlag.Name) || ctx.Bool(utils.AmoyFlag.Name) || ctx.Bool(utils.BorMainnetFlag.Name) {
homeDir, _ := os.UserHomeDir()
path = filepath.Join(homeDir, "/.bor/data")
} else if ctx.Bool(utils.SepoliaFlag.Name) {
Expand Down
5 changes: 5 additions & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ var (
utils.SepoliaFlag,
utils.GoerliFlag,
utils.MumbaiFlag,
utils.AmoyFlag,
utils.BorMainnetFlag,
utils.VMEnableDebugFlag,
utils.NetworkIdFlag,
Expand Down Expand Up @@ -297,6 +298,9 @@ func prepare(ctx *cli.Context) {
case ctx.IsSet(utils.MumbaiFlag.Name):
log.Info("Starting Bor on Mumbai testnet...")

case ctx.IsSet(utils.AmoyFlag.Name):
log.Info("Starting Bor on Amoy testnet...")

case ctx.IsSet(utils.BorMainnetFlag.Name):
log.Info("Starting Bor on Bor mainnet...")

Expand Down Expand Up @@ -327,6 +331,7 @@ func prepare(ctx *cli.Context) {
if !ctx.IsSet(utils.SepoliaFlag.Name) &&
!ctx.IsSet(utils.GoerliFlag.Name) &&
!ctx.IsSet(utils.MumbaiFlag.Name) &&
!ctx.IsSet(utils.AmoyFlag.Name) &&
!ctx.IsSet(utils.DeveloperFlag.Name) {
// Nope, we're really on mainnet. Bump that cache up!
log.Info("Bumping default cache on mainnet", "provided", ctx.Int(utils.CacheFlag.Name), "updated", 4096)
Expand Down
4 changes: 4 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ var (
Name: "bor-mumbai",
Usage: "Mumbai network: pre-configured proof-of-stake test network",
}
AmoyFlag = &cli.BoolFlag{
Name: "bor-amoy",
Usage: "Amoy network: pre-configured proof-of-stake test network",
}
BorMainnetFlag = &cli.BoolFlag{
Name: "bor-mainnet",
Usage: "Bor mainnet",
Expand Down
17 changes: 17 additions & 0 deletions core/allocs/amoy.json

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@ func LoadCliqueConfig(db ethdb.Database, genesis *Genesis) (*params.CliqueConfig
return nil, nil
}

// TODO : 0xSharma : add : Amoy Genesis Hash

func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig {
switch {
case g != nil:
Expand Down Expand Up @@ -660,6 +662,20 @@ func DefaultMumbaiGenesisBlock() *Genesis {
}
}

// DefaultAmoyGenesisBlock returns the Amoy network genesis block.
func DefaultAmoyGenesisBlock() *Genesis {
return &Genesis{
Config: params.AmoyChainConfig,
Nonce: 0,
Timestamp: 1558348305,
GasLimit: 10000000,
Difficulty: big.NewInt(1),
Mixhash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
Coinbase: common.HexToAddress("0x0000000000000000000000000000000000000000"),
Alloc: readPrealloc("allocs/amoy.json"),
}
}

// DefaultBorMainnet returns the Bor Mainnet network gensis block.
func DefaultBorMainnetGenesisBlock() *Genesis {
return &Genesis{
Expand Down
10 changes: 5 additions & 5 deletions docs/cli/example_config.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# This configuration file is for reference and learning purpose only.
# The default value of the flags is provided below (except a few flags which has custom defaults which are explicitly mentioned).
# Recommended values for mainnet and/or mumbai are also provided.
# Recommended values for mainnet and/or mumbai,amoy are also provided.

chain = "mainnet" # Name of the chain to sync ("mumbai", "mainnet") or path to a genesis file
chain = "mainnet" # Name of the chain to sync ("amoy", "mumbai", "mainnet") or path to a genesis file
identity = "Annon-Identity" # Name/Identity of the node (default = OS hostname)
verbosity = 3 # Logging verbosity for the server (5=trace|4=debug|3=info|2=warn|1=error|0=crit) (`log-level` was replaced by `verbosity`, and thus will be deprecated soon)
vmdebug = false # Record information useful for VM and contract debugging
Expand Down Expand Up @@ -72,7 +72,7 @@ devfakeauthor = false # Run miner without validator set authorization
etherbase = "" # Public address for block mining rewards
extradata = "" # Block extra data set by the miner (default = client version)
gaslimit = 30000000 # Target gas ceiling for mined blocks
gasprice = "1000000000" # Minimum gas price for mining a transaction (recommended for mainnet = 30000000000, default suitable for mumbai/devnet)
gasprice = "1000000000" # Minimum gas price for mining a transaction (recommended for mainnet = 30000000000, default suitable for amoy/mumbai/devnet)
recommit = "2m5s" # The time interval for miner to re-create mining work
commitinterrupt = true # Interrupt the current mining work when time is exceeded and create partial blocks

Expand Down Expand Up @@ -126,7 +126,7 @@ devfakeauthor = false # Run miner without validator set authorization
maxheaderhistory = 1024 # Maximum header history of gasprice oracle
maxblockhistory = 1024 # Maximum block history of gasprice oracle
maxprice = "5000000000000" # Maximum gas price will be recommended by gpo
ignoreprice = "2" # Gas price below which gpo will ignore transactions (recommended for mainnet = 30000000000, default suitable for mumbai/devnet)
ignoreprice = "2" # Gas price below which gpo will ignore transactions (recommended for mainnet = 30000000000, default suitable for amoy/mumbai/devnet)

[telemetry]
metrics = false # Enable metrics collection and reporting
Expand All @@ -150,7 +150,7 @@ devfakeauthor = false # Run miner without validator set authorization
region = "us-north-1"

[cache]
cache = 1024 # Megabytes of memory allocated to internal caching (recommended for mainnet = 4096, default suitable for mumbai/devnet)
cache = 1024 # Megabytes of memory allocated to internal caching (recommended for mainnet = 4096, default suitable for amoy/mumbai/devnet)
gc = 25 # Percentage of cache memory allowance to use for trie pruning (default = 25% full mode, 0% archive mode)
snapshot = 10 # Percentage of cache memory allowance to use for snapshot caching (default = 10% full mode, 20% archive mode)
database = 50 # Percentage of cache memory allowance to use for database io
Expand Down
4 changes: 2 additions & 2 deletions docs/cli/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The ```bor server``` command runs the Bor client.

## Options

- ```chain```: Name of the chain to sync ('mumbai', 'mainnet') or path to a genesis file (default: mainnet)
- ```chain```: Name of the chain to sync ('amoy', 'mumbai', 'mainnet') or path to a genesis file (default: mainnet)

- ```identity```: Name/Identity of the node

Expand Down Expand Up @@ -304,4 +304,4 @@ The ```bor server``` command runs the Bor client.

- ```txpool.globalqueue```: Maximum number of non-executable transaction slots for all accounts (default: 32768)

- ```txpool.lifetime```: Maximum amount of time non-executable transaction are queued (default: 3h0m0s)
- ```txpool.lifetime```: Maximum amount of time non-executable transaction are queued (default: 3h0m0s)
65 changes: 65 additions & 0 deletions internal/cli/server/chains/amoy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package chains

import (
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/params"
)

var amoyTestnet = &Chain{
NetworkId: 80002,
Genesis: &core.Genesis{
Config: &params.ChainConfig{
cffls marked this conversation as resolved.
Show resolved Hide resolved
ChainID: big.NewInt(80002),
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: true,
EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: nil,
ShanghaiBlock: nil,
0xsharma marked this conversation as resolved.
Show resolved Hide resolved
Bor: &params.BorConfig{
JaipurBlock: nil,
DelhiBlock: nil,
ParallelUniverseBlock: nil,
IndoreBlock: nil,
StateSyncConfirmationDelay: map[string]uint64{
"0": 128,
},
Period: map[string]uint64{
"0": 2,
},
ProducerDelay: map[string]uint64{
"0": 4,
},
Sprint: map[string]uint64{
"0": 16,
},
BackupMultiplier: map[string]uint64{
"0": 2,
},
ValidatorContract: "0x0000000000000000000000000000000000001000",
StateReceiverContract: "0x0000000000000000000000000000000000001001",
BurntContract: map[string]string{
"0": "0x000000000000000000000000000000000000dead",
},
},
},
Nonce: 0,
Timestamp: 1558348305,
GasLimit: 10000000,
Difficulty: big.NewInt(1),
Mixhash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
Coinbase: common.HexToAddress("0x0000000000000000000000000000000000000000"),
Alloc: readPrealloc("allocs/amoy.json"),
},
}
1 change: 1 addition & 0 deletions internal/cli/server/chains/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Chain struct {
var chains = map[string]*Chain{
"mainnet": mainnetBor,
"mumbai": mumbaiTestnet,
"amoy": amoyTestnet,
}

func GetChain(name string) (*Chain, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ func DefaultConfig() *Config {
},
},
Cache: &CacheConfig{
Cache: 1024, // geth's default (suitable for mumbai)
Cache: 1024, // geth's default (suitable for mumbai, amoy)
PercDatabase: 50,
PercTrie: 15,
PercGc: 25,
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/server/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func (c *Command) Flags(config *Config) *flagset.Flagset {

f.StringFlag(&flagset.StringFlag{
Name: "chain",
Usage: "Name of the chain to sync ('mumbai', 'mainnet') or path to a genesis file",
Usage: "Name of the chain to sync ('amoy', 'mumbai', 'mainnet') or path to a genesis file",
Value: &c.cliConfig.Chain,
Default: c.cliConfig.Chain,
})
Expand Down
2 changes: 1 addition & 1 deletion internal/debug/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ func Setup(ctx *cli.Context) error {
// This context value ("metrics.addr") represents the utils.MetricsHTTPFlag.Name.
// It cannot be imported because it will cause a cyclical dependency.
StartPProf(address, !ctx.IsSet("metrics.addr"))
} else if ctx.IsSet("bor-mumbai") || ctx.IsSet("bor-mainnet") {
} else if ctx.IsSet("bor-mumbai") || ctx.IsSet("bor-amoy") || ctx.IsSet("bor-mainnet") {
address := fmt.Sprintf("%s:%d", "0.0.0.0", 7071)
StartPProf(address, !ctx.IsSet("metrics.addr"))
}
Expand Down
2 changes: 1 addition & 1 deletion miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ func (w *worker) mainLoop(ctx context.Context) {
for {
select {
case req := <-w.newWorkCh:
if w.chainConfig.ChainID.Cmp(params.BorMainnetChainConfig.ChainID) == 0 || w.chainConfig.ChainID.Cmp(params.MumbaiChainConfig.ChainID) == 0 {
if w.chainConfig.ChainID.Cmp(params.BorMainnetChainConfig.ChainID) == 0 || w.chainConfig.ChainID.Cmp(params.MumbaiChainConfig.ChainID) == 0 || w.chainConfig.ChainID.Cmp(params.AmoyChainConfig.ChainID) == 0 {
if w.eth.PeerCount() > 0 {
//nolint:contextcheck
w.commitWork(req.ctx, req.interrupt, req.noempty, req.timestamp)
Expand Down
Loading
Loading