Skip to content

Commit

Permalink
resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
temaniarpit27 committed Jan 24, 2024
2 parents 241af1f + 6801260 commit ca20a99
Show file tree
Hide file tree
Showing 33 changed files with 1,386 additions and 34 deletions.
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
2 changes: 1 addition & 1 deletion cmd/evm/testdata/4/readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
These files exemplify a transition where a transaction (executed on block 5) requests
These files examplify a transition where a transaction (executed on block 5) requests
the blockhash for block `4`, but where the hash for that block is missing.
It's expected that executing these should cause `exit` with errorcode `4`.
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.

30 changes: 18 additions & 12 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,13 @@ type BlockChain struct {
stopping atomic.Bool // false if chain is running, true when stopped
procInterrupt atomic.Bool // interrupt signaler for block processing

engine consensus.Engine
validator Validator // Block and state validator interface
prefetcher Prefetcher
processor Processor // Block transaction processor interface
parallelProcessor Processor // Parallel block transaction processor interface
parallelSpeculativeProcesses int // Number of parallel speculative processes
forker *ForkChoice
vmConfig vm.Config
engine consensus.Engine
validator Validator // Block and state validator interface
prefetcher Prefetcher
processor Processor // Block transaction processor interface
parallelProcessor Processor // Parallel block transaction processor interface
forker *ForkChoice
vmConfig vm.Config

// Bor related changes
borReceiptsCache *lru.Cache[common.Hash, *types.Receipt] // Cache for the most recent bor receipt receipts per block
Expand Down Expand Up @@ -409,8 +408,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
// The first thing the node will do is reconstruct the verification data for
// the head block (ethash cache or clique voting snapshot). Might as well do
// it in advance.
// BOR - commented out intentionally
// bc.engine.VerifyHeader(bc, bc.CurrentHeader())
bc.engine.VerifyHeader(bc, bc.CurrentHeader())

// Check the current state of the block hashes and make sure that we do not have any of the bad blocks in our chain
for hash := range BadHashes {
Expand Down Expand Up @@ -483,7 +481,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
}

// NewParallelBlockChain , similar to NewBlockChain, creates a new blockchain object, but with a parallel state processor
func NewParallelBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis, overrides *ChainOverrides, engine consensus.Engine, vmConfig vm.Config, shouldPreserve func(header *types.Header) bool, txLookupLimit *uint64, checker ethereum.ChainValidator, numprocs int) (*BlockChain, error) {
func NewParallelBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis, overrides *ChainOverrides, engine consensus.Engine, vmConfig vm.Config, shouldPreserve func(header *types.Header) bool, txLookupLimit *uint64, checker ethereum.ChainValidator) (*BlockChain, error) {
bc, err := NewBlockChain(db, cacheConfig, genesis, overrides, engine, vmConfig, shouldPreserve, txLookupLimit, checker)

if err != nil {
Expand All @@ -502,7 +500,6 @@ func NewParallelBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis
}

bc.parallelProcessor = NewParallelStateProcessor(chainConfig, bc, engine)
bc.parallelSpeculativeProcesses = numprocs

return bc, nil
}
Expand Down Expand Up @@ -2142,6 +2139,15 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
parent = bc.GetHeader(block.ParentHash(), block.NumberU64()-1)
}

statedb, err := state.New(parent.Root, bc.stateCache, bc.snaps)
if err != nil {
return it.index, err
}

// Enable prefetching to pull in trie node paths while processing transactions
statedb.StartPrefetcher("chain")
activeState = statedb

// If we have a followup block, run that against the current state to pre-cache
// transactions and probabilistically some of the account/storage trie nodes.
var followupInterrupt atomic.Bool
Expand Down
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 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig {
return params.MumbaiChainConfig
case ghash == params.BorMainnetGenesisHash:
return params.BorMainnetChainConfig
case ghash == params.AmoyGenesisHash:
return params.AmoyChainConfig
default:
return params.AllEthashProtocolChanges
}
Expand Down Expand Up @@ -646,6 +648,20 @@ func DefaultMumbaiGenesisBlock() *Genesis {
}
}

// 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"),
}
}

// DefaultBorMainnet returns the Bor Mainnet network gensis block.
func DefaultBorMainnetGenesisBlock() *Genesis {
return &Genesis{
Expand Down
4 changes: 2 additions & 2 deletions core/parallel_state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
backupStateDB := statedb.Copy()

profile := false
result, err := blockstm.ExecuteParallel(tasks, profile, metadata, p.bc.parallelSpeculativeProcesses, interruptCtx)
result, err := blockstm.ExecuteParallel(tasks, profile, metadata, cfg.ParallelSpeculativeProcesses, interruptCtx)

if err == nil && profile && result.Deps != nil {
_, weight := result.Deps.LongestPath(*result.Stats)
Expand Down Expand Up @@ -376,7 +376,7 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
t.totalUsedGas = usedGas
}

_, err = blockstm.ExecuteParallel(tasks, false, metadata, p.bc.parallelSpeculativeProcesses, interruptCtx)
_, err = blockstm.ExecuteParallel(tasks, false, metadata, cfg.ParallelSpeculativeProcesses, interruptCtx)

break
}
Expand Down
4 changes: 4 additions & 0 deletions core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ type Config struct {
NoBaseFee bool // Forces the EIP-1559 baseFee to 0 (needed for 0 price calls)
EnablePreimageRecording bool // Enables recording of SHA3/keccak preimages
ExtraEips []int // Additional EIPS that are to be enabled

// parallel EVM configs
ParallelEnable bool
ParallelSpeculativeProcesses int
}

// ScopeContext contains the things that are per-call, such as stack and memory,
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)
2 changes: 1 addition & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
// check if Parallel EVM is enabled
// if enabled, use parallel state processor
if config.ParallelEVM.Enable {
eth.blockchain, err = core.NewParallelBlockChain(chainDb, cacheConfig, config.Genesis, &overrides, eth.engine, vmConfig, eth.shouldPreserve, &config.TxLookupLimit, checker, config.ParallelEVM.SpeculativeProcesses)
eth.blockchain, err = core.NewParallelBlockChain(chainDb, cacheConfig, config.Genesis, &overrides, eth.engine, vmConfig, eth.shouldPreserve, &config.TxLookupLimit, checker)
} else {
eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, config.Genesis, &overrides, eth.engine, vmConfig, eth.shouldPreserve, &config.TxLookupLimit, checker)
}
Expand Down
17 changes: 17 additions & 0 deletions internal/cli/server/chains/allocs/amoy.json

Large diffs are not rendered by default.

Loading

0 comments on commit ca20a99

Please sign in to comment.