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 #1131

Merged
merged 17 commits into from
Jan 18, 2024
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
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
416 changes: 416 additions & 0 deletions .github/workflows/packager.yml

Large diffs are not rendered by default.

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.

### 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 @@ -268,6 +268,8 @@ func ethFilter(args []string) (nodeFilter, error) {
filter = forkid.NewStaticFilter(params.MumbaiChainConfig, params.MumbaiGenesisHash)
case "bor-mainnet":
filter = forkid.NewStaticFilter(params.BorMainnetChainConfig, params.BorMainnetGenesisHash)
case "bor-amoy":
filter = forkid.NewStaticFilter(params.AmoyChainConfig, params.AmoyGenesisHash)
default:
return nil, fmt.Errorf("unknown network %q", args[0])
}
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 @@ -962,7 +963,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 @@ -975,6 +976,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, errors.New("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 @@ -118,6 +118,10 @@ func loadBaseConfig(ctx *cli.Context) 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 @@ -358,6 +362,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"
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 = 80002
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 @@ -132,7 +132,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 @@ -141,6 +141,7 @@ var (
utils.SepoliaFlag,
utils.GoerliFlag,
utils.MumbaiFlag,
utils.AmoyFlag,
utils.BorMainnetFlag,
utils.DeveloperPeriodFlag,
utils.VMEnableDebugFlag,
Expand Down Expand Up @@ -289,6 +290,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 @@ -319,6 +323,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 @@ -157,6 +157,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 @@ -481,6 +481,8 @@
return params.MumbaiChainConfig
case ghash == params.BorMainnetGenesisHash:
return params.BorMainnetChainConfig
case ghash == params.AmoyGenesisHash:
return params.AmoyChainConfig

Check warning on line 485 in core/genesis.go

View check run for this annotation

Codecov / codecov/patch

core/genesis.go#L484-L485

Added lines #L484 - L485 were not covered by tests
default:
return params.AllEthashProtocolChanges
}
Expand Down Expand Up @@ -646,6 +648,20 @@
}
}

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

Check warning on line 662 in core/genesis.go

View check run for this annotation

Codecov / codecov/patch

core/genesis.go#L652-L662

Added lines #L652 - L662 were not covered by tests
}

// 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 @@ -73,7 +73,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 @@ -127,7 +127,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 @@ -151,7 +151,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 @@ -20,7 +20,7 @@ The ```bor server``` command runs the Bor client.

- ```bor.withoutheimdall```: Run without Heimdall service (for testing purpose) (default: false)

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

- ```config```: Path to the TOML configuration file

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

- ```txpool.pricelimit```: Minimum gas price limit to enforce for acceptance into the pool (default: 1)

- ```txpool.rejournal```: Time interval to regenerate the local transaction journal (default: 1h0m0s)
- ```txpool.rejournal```: Time interval to regenerate the local transaction journal (default: 1h0m0s)
17 changes: 17 additions & 0 deletions internal/cli/server/chains/allocs/amoy.json

Large diffs are not rendered by default.

70 changes: 70 additions & 0 deletions internal/cli/server/chains/amoy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
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{
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: big.NewInt(73100),
ShanghaiBlock: big.NewInt(73100),
Bor: &params.BorConfig{
JaipurBlock: big.NewInt(73100),
DelhiBlock: big.NewInt(73100),
ParallelUniverseBlock: nil,
IndoreBlock: big.NewInt(73100),
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",
"73100": "0xeCDD77cE6f146cCf5dab707941d318Bd50eeD2C9",
},
},
},
Nonce: 0,
Timestamp: 1700225065,
GasLimit: 10000000,
Difficulty: big.NewInt(1),
Mixhash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
Coinbase: common.HexToAddress("0x0000000000000000000000000000000000000000"),
Alloc: readPrealloc("allocs/amoy.json"),
},
Bootnodes: []string{
"enode://bce861be777e91b0a5a49d58a51e14f32f201b4c6c2d1fbea6c7a1f14756cbb3f931f3188d6b65de8b07b53ff28d03b6e366d09e56360d2124a9fc5a15a0913d@54.217.171.196:30303",
"enode://4a3dc0081a346d26a73d79dd88216a9402d2292318e2db9947dbc97ea9c4afb2498dc519c0af04420dc13a238c279062da0320181e7c1461216ce4513bfd40bf@13.251.184.185:30303",
},
}
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/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 miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,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