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

Full BSC support with validator mode #3233

Merged
merged 88 commits into from
Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
069309d
migrated consensus and chain config files for bsc support
dmitry123 Nov 23, 2021
d7ceb9e
migrated more files from bsc
dmitry123 Nov 24, 2021
28808e5
fixed consensus crashing
dmitry123 Nov 25, 2021
9538b92
updated erigon lib for parlia snapshot prefix
dmitry123 Nov 25, 2021
935ed6c
added staticpeers for bsc
dmitry123 Nov 25, 2021
109f32b
[+] added system contracts
dmitry123 Nov 25, 2021
6a86981
migrated system contract calls
dmitry123 Nov 25, 2021
5b52c6b
[*] fixed bug with returning mutable balance object
dmitry123 Nov 26, 2021
1401bb4
[*] fixed tendermint deps
dmitry123 Nov 26, 2021
1cd6c41
[+] added some logs
dmitry123 Nov 26, 2021
18bd624
[+] enabled bsc forks
dmitry123 Nov 29, 2021
3e94431
Fix call sys contract gas calculation
convexman Nov 29, 2021
37a0d9b
[*] fixed executing system transactions
dmitry123 Nov 29, 2021
b0c1fdf
[*] enabled receipt hash, gas and bloom filter checks
dmitry123 Nov 29, 2021
5feb33a
[-] removed some logging scripts
dmitry123 Nov 30, 2021
a49426f
[*] fixed bug with commiting dirty inter block state state after syst…
dmitry123 Dec 3, 2021
b6b2734
[+] added chapel and rialto testnet support
dmitry123 Dec 6, 2021
6b3901d
[*] fixed chapel allocs
dmitry123 Dec 6, 2021
7fbca56
[-] removed 6 mil block limit for headers sync
dmitry123 Dec 6, 2021
5a31429
Fix hardforks on chapel and other testnets
convexman Dec 6, 2021
84c564e
Merge branch 'bsc' of github.com:Ankr-network/erigon-for-bsc into bsc
dmitry123 Dec 6, 2021
93f943f
Merge remote-tracking branch 'origin/bsc' into bsc-ankr
dmitry123 Dec 7, 2021
203fbb3
[*] fixed header sync issue after merge
dmitry123 Dec 7, 2021
90261f3
[*] tiny code cleanup
dmitry123 Dec 7, 2021
54c7407
[-] removed some comments
dmitry123 Dec 9, 2021
6c7fac0
[*] increased mdbx map size to 4 TB
dmitry123 Dec 9, 2021
2eb25c0
[*] increased max chaindata size to 6 tb
dmitry123 Dec 14, 2021
469b9aa
[*] bring more compatibility with origin erigon and some code cleanup
dmitry123 Dec 15, 2021
d187f84
[+] added support of validator mode for BSC chain
dmitry123 Dec 15, 2021
90236f7
[*] enable private key load for bsc, rialto and chapel chains
dmitry123 Dec 15, 2021
b914105
[*] fixed running BSC validator node
dmitry123 Dec 15, 2021
8150ca5
Fix the branch list
j75689 Dec 16, 2021
f1298b8
[*] tiny fixes for linter
dmitry123 Dec 16, 2021
5d43735
Merge pull request #4 from j75689/fix/ci_workflows
j75689 Dec 16, 2021
c764b58
[*] formatted imports for core and parlia packages
dmitry123 Dec 16, 2021
73ec558
[*] fixed import rules in other files
dmitry123 Dec 16, 2021
c7e2c2b
Revert "[*] formatted imports for core and parlia packages"
dmitry123 Dec 16, 2021
d555839
[*] changed import rules in more packages
dmitry123 Dec 16, 2021
2345b38
Merge pull request #1 from binance-chain/bsc-ankr
j75689 Dec 16, 2021
13dce95
Merge remote-tracking branch 'origin/bsc' into bsc-validator-support
dmitry123 Dec 16, 2021
3544df3
[*] fixed type mismatch in hack command
dmitry123 Dec 16, 2021
b4ed564
[*] fixed crash on new epoch, enabled bootstrap flags
dmitry123 Dec 16, 2021
798076d
[*] fixed linter errors
dmitry123 Dec 16, 2021
de3b1c6
[*] fixed missing err check for syscalls
dmitry123 Dec 16, 2021
62dd8de
[*] now BSC implementation is fully compatible with erigon original s…
dmitry123 Dec 17, 2021
d195cd0
Merge pull request #5 from binance-chain/bsc-parlia-hotfix
dmitry123 Dec 17, 2021
acd5d04
Merge remote-tracking branch 'origin/bsc' into bsc-erigon-compatibility
dmitry123 Dec 17, 2021
6ebcb28
Merge pull request #6 from binance-chain/bsc-erigon-compatibility
dmitry123 Dec 17, 2021
7b07e99
Merge remote-tracking branch 'origin/bsc' into bsc-validator-support
dmitry123 Dec 17, 2021
c897053
Revert "Add chain config and CLI changes for Binance Smart Chain supp…
dmitry123 Dec 17, 2021
8d22c97
Revert "Add Parlia consensus engine for Binance Smart Chain support (…
dmitry123 Dec 17, 2021
8cc837f
Merge branch 'bsc' into erigon-bsc-merge
dmitry123 Dec 17, 2021
9285a83
Merge branch 'bsc-validator-support' into erigon-bsc-merge
dmitry123 Dec 17, 2021
eb3e171
[*] fixed several issues after merge
dmitry123 Dec 17, 2021
660ff21
[*] fixed integration compilation
dmitry123 Dec 17, 2021
3245254
Merge pull request #3 from binance-chain/bsc-validator-support
dmitry123 Dec 17, 2021
383c52d
Merge remote-tracking branch 'origin/bsc' into erigon-bsc-merge
dmitry123 Dec 17, 2021
2e1c74c
Merge pull request #7 from binance-chain/erigon-bsc-merge
dmitry123 Dec 17, 2021
ce1f76b
Revert "Fix the branch list"
dmitry123 Dec 17, 2021
080c106
[-] removed receipt repair migration
dmitry123 Dec 17, 2021
d9423ef
Merge branch 'erigon-bsc-merge' into bsc
dmitry123 Dec 19, 2021
63983ae
Merge remote-tracking branch 'bsc-remote/bsc' into bsc
dmitry123 Dec 19, 2021
05b1a52
[*] fixed parlia fork numbers output
dmitry123 Dec 22, 2021
ddabb23
Merge remote-tracking branch 'erigon/devel' into bsc
dmitry123 Dec 22, 2021
2c5a094
Merge branch 'devel' into bsc
dmitry123 Dec 23, 2021
bff5928
[*] bring more devel compatibility, fixed bsc address list for access…
dmitry123 Dec 23, 2021
66ccbfd
[*] fixed bug with commiting state transition for bad blocks in BSC
dmitry123 Dec 23, 2021
e338d7c
[*] fixed bsc changes apply for integration command and updated confi…
dmitry123 Dec 24, 2021
91b3637
[*] fixed bug with applying bsc forks for chapel and rialto testnet c…
dmitry123 Dec 23, 2021
37b25da
Merge remote-tracking branch 'erigon/devel' into bsc
dmitry123 Dec 27, 2021
c226668
Merge remote-tracking branch 'erigon/devel' into bsc
dmitry123 Jan 10, 2022
454f2f8
Merge remote-tracking branch 'erigon/devel' into bsc
dmitry123 Jan 11, 2022
2be4744
Fix compilation errors in hack.go
Jan 11, 2022
957739f
Fix lint
Jan 11, 2022
252a7fb
reset changes in erigon-snapshots to devel
Jan 11, 2022
d19c86d
Remove unrelated changes
Jan 11, 2022
00891e7
Fix embed
Jan 11, 2022
b6c52ce
Remove more unrelated changes
Jan 12, 2022
01dd598
Merge remote-tracking branch 'origin/devel' into bsc
Jan 12, 2022
825a031
Remove more unrelated changes
Jan 12, 2022
5120313
Restore clique and aura miner config
Jan 12, 2022
78bdc3b
Refactor interfaces not to use slice pointers
Jan 12, 2022
df6f05d
Refactor parlia functions to return tx and receipt instead of dealing…
Jan 13, 2022
4021cf3
Fix for header panic
Jan 13, 2022
8fea85e
Merge remote-tracking branch 'origin/devel' into bsc
Jan 13, 2022
809003e
Fix lint, restore system contract addresses
Jan 13, 2022
900aef2
Remove more unrelated changes, unify GatherForks
Jan 13, 2022
27824c0
Merge remote-tracking branch 'origin/devel' into bsc
Jan 14, 2022
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
Prev Previous commit
Next Next commit
[*] fixed running BSC validator node
  • Loading branch information
dmitry123 committed Dec 15, 2021
commit b914105d6e453f2a6489b4e695cfa8d25a5f03ec
3 changes: 2 additions & 1 deletion cmd/state/commands/opcode_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,8 @@ func runBlock(ibs *state.IntraBlockState, txnWriter state.StateWriter, blockWrit

if !vmConfig.ReadOnly {
// Finalize the block, applying any consensus engine specific extras (e.g. block rewards)
if _, err := engine.FinalizeAndAssemble(chainConfig, header, ibs, block.Transactions(), block.Uncles(), receipts, nil, nil, nil, nil); err != nil {
tx := block.Transactions()
if _, err := engine.FinalizeAndAssemble(chainConfig, header, ibs, &tx, block.Uncles(), &receipts, nil, nil, nil, nil); err != nil {
return nil, fmt.Errorf("finalize of block %d failed: %w", block.NumberU64(), err)
}

Expand Down
11 changes: 8 additions & 3 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,12 +595,14 @@ func setNodeUserIdentCobra(f *pflag.FlagSet, cfg *node.Config) {
// setBootstrapNodes creates a list of bootstrap nodes from the command line
// flags, reverting to pre-configured ones if none have been specified.
func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
urls := params.MainnetBootnodes
var urls []string
if ctx.GlobalIsSet(BootnodesFlag.Name) {
urls = SplitAndTrim(ctx.GlobalString(BootnodesFlag.Name))
} else {
chain := ctx.GlobalString(ChainFlag.Name)
switch chain {
case params.MainnetChainName:
urls = params.MainnetBootnodes
case params.RopstenChainName:
urls = params.RopstenBootnodes
case params.RinkebyChainName:
Expand Down Expand Up @@ -1375,8 +1377,11 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *node.Config, cfg *ethconfig.Conf
log.Info("Using developer account", "address", developer)

// Create a new developer genesis block or reuse existing one
cfg.Genesis = core.DeveloperGenesisBlock(uint64(ctx.GlobalInt(DeveloperPeriodFlag.Name)), developer)
log.Info("Using custom developer period", "seconds", cfg.Genesis.Config.Clique.Period)
cfg.Genesis = core.DefaultChapelGenesisBlock()
extraData := make([]byte, 32+20+65)
copy(extraData[32:], developer[:])
cfg.Genesis.ExtraData = extraData
log.Info("Using custom developer period", "seconds", cfg.Genesis.Config.Parlia.Period)
if !ctx.GlobalIsSet(MinerGasPriceFlag.Name) {
cfg.Miner.GasPrice = big.NewInt(1)
}
Expand Down
14 changes: 7 additions & 7 deletions consensus/aura/aura.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ func (c *AuRa) Initialize(config *params.ChainConfig, chain consensus.ChainHeade
}

//word `signal epoch` == word `pending epoch`
func (c *AuRa) Finalize(config *params.ChainConfig, header *types.Header, state *state.IntraBlockState, txs []types.Transaction, uncles []*types.Header, r types.Receipts, e consensus.EpochReader, chain consensus.ChainHeaderReader, syscall consensus.SystemCall) error {
func (c *AuRa) Finalize(config *params.ChainConfig, header *types.Header, state *state.IntraBlockState, _ *types.Transactions, uncles []*types.Header, receipts *types.Receipts, e consensus.EpochReader, chain consensus.ChainHeaderReader, syscall consensus.SystemCall) error {
// accumulateRewards retrieves rewards for a block and applies them to the coinbase accounts for miner and uncle miners
beneficiaries, _, rewards, err := AccumulateRewards(config, c, header, uncles, syscall)
if err != nil {
Expand All @@ -846,15 +846,15 @@ func (c *AuRa) Finalize(config *params.ChainConfig, header *types.Header, state

// check_and_lock_block -> check_epoch_end_signal (after enact)
if header.Number.Uint64() >= DEBUG_LOG_FROM {
fmt.Printf("finalize1: %d,%d\n", header.Number.Uint64(), len(r))
fmt.Printf("finalize1: %d,%d\n", header.Number.Uint64(), len(*receipts))
}
pendingTransitionProof, err := c.cfg.Validators.signalEpochEnd(header.Number.Uint64() == 0, header, r)
pendingTransitionProof, err := c.cfg.Validators.signalEpochEnd(header.Number.Uint64() == 0, header, *receipts)
if err != nil {
return err
}
if pendingTransitionProof != nil {
if header.Number.Uint64() >= DEBUG_LOG_FROM {
fmt.Printf("insert_pending_trancition: %d,receipts=%d, lenProof=%d\n", header.Number.Uint64(), len(r), len(pendingTransitionProof))
fmt.Printf("insert_pending_trancition: %d,receipts=%d, lenProof=%d\n", header.Number.Uint64(), len(*receipts), len(pendingTransitionProof))
}
if err = e.PutPendingEpoch(header.Hash(), header.Number.Uint64(), pendingTransitionProof); err != nil {
return err
Expand Down Expand Up @@ -976,12 +976,12 @@ func allHeadersUntil(chain consensus.ChainHeaderReader, from *types.Header, to c
//}

// FinalizeAndAssemble implements consensus.Engine
func (c *AuRa) FinalizeAndAssemble(chainConfig *params.ChainConfig, header *types.Header, state *state.IntraBlockState, txs []types.Transaction, uncles []*types.Header, r types.Receipts,
func (c *AuRa) FinalizeAndAssemble(chainConfig *params.ChainConfig, header *types.Header, state *state.IntraBlockState, txs *types.Transactions, uncles []*types.Header, receipts *types.Receipts,
e consensus.EpochReader, chain consensus.ChainHeaderReader, syscall consensus.SystemCall, call consensus.Call) (*types.Block, error) {
c.Finalize(chainConfig, header, state, txs, uncles, r, e, chain, syscall)
c.Finalize(chainConfig, header, state, txs, uncles, receipts, e, chain, syscall)

// Assemble and return the final block for sealing
return types.NewBlock(header, txs, uncles, r), nil
return types.NewBlock(header, *txs, uncles, *receipts), nil
}

// Authorize injects a private key into the consensus engine to mint new blocks
Expand Down
6 changes: 3 additions & 3 deletions consensus/clique/clique.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,21 +369,21 @@ func (c *Clique) Initialize(config *params.ChainConfig, chain consensus.ChainHea

// Finalize implements consensus.Engine, ensuring no uncles are set, nor block
// rewards given.
func (c *Clique) Finalize(config *params.ChainConfig, header *types.Header, state *state.IntraBlockState, txs []types.Transaction, uncles []*types.Header, r types.Receipts, e consensus.EpochReader, chain consensus.ChainHeaderReader, syscall consensus.SystemCall) error {
func (c *Clique) Finalize(config *params.ChainConfig, header *types.Header, state *state.IntraBlockState, txs *types.Transactions, uncles []*types.Header, r *types.Receipts, e consensus.EpochReader, chain consensus.ChainHeaderReader, syscall consensus.SystemCall) error {
// No block rewards in PoA, so the state remains as is and uncles are dropped
header.UncleHash = types.CalcUncleHash(nil)
return nil
}

// FinalizeAndAssemble implements consensus.Engine, ensuring no uncles are set,
// nor block rewards given, and returns the final block.
func (c *Clique) FinalizeAndAssemble(chainConfig *params.ChainConfig, header *types.Header, state *state.IntraBlockState, txs []types.Transaction, uncles []*types.Header, receipts types.Receipts,
func (c *Clique) FinalizeAndAssemble(chainConfig *params.ChainConfig, header *types.Header, state *state.IntraBlockState, txs *types.Transactions, uncles []*types.Header, receipts *types.Receipts,
e consensus.EpochReader, chain consensus.ChainHeaderReader, syscall consensus.SystemCall, call consensus.Call) (*types.Block, error) {
// No block rewards in PoA, so the state remains as is and uncles are dropped
header.UncleHash = types.CalcUncleHash(nil)

// Assemble and return the final block for sealing
return types.NewBlock(header, txs, nil, receipts), nil
return types.NewBlock(header, *txs, nil, *receipts), nil
}

// Authorize injects a private key into the consensus engine to mint new blocks
Expand Down
6 changes: 3 additions & 3 deletions consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ type Engine interface {
//
// Note: The block header and state database might be updated to reflect any
// consensus rules that happen at finalization (e.g. block rewards).
Finalize(config *params.ChainConfig, header *types.Header, state *state.IntraBlockState, txs []types.Transaction, uncles []*types.Header, r types.Receipts, e EpochReader, chain ChainHeaderReader, syscall SystemCall) error
Finalize(config *params.ChainConfig, header *types.Header, state *state.IntraBlockState, txs *types.Transactions, uncles []*types.Header, receipts *types.Receipts, e EpochReader, chain ChainHeaderReader, syscall SystemCall) error

// FinalizeAndAssemble runs any post-transaction state modifications (e.g. block
// rewards) and assembles the final block.
//
// Note: The block header and state database might be updated to reflect any
// consensus rules that happen at finalization (e.g. block rewards).
FinalizeAndAssemble(config *params.ChainConfig, header *types.Header, state *state.IntraBlockState, txs []types.Transaction,
uncles []*types.Header, receipts types.Receipts, e EpochReader, chain ChainHeaderReader, syscall SystemCall, call Call) (*types.Block, error)
FinalizeAndAssemble(config *params.ChainConfig, header *types.Header, state *state.IntraBlockState, txs *types.Transactions,
uncles []*types.Header, receipts *types.Receipts, e EpochReader, chain ChainHeaderReader, syscall SystemCall, call Call) (*types.Block, error)

// Seal generates a new sealing request for the given input block and pushes
// the result into the given channel.
Expand Down
8 changes: 4 additions & 4 deletions consensus/ethash/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,21 +608,21 @@ func (ethash *Ethash) Initialize(config *params.ChainConfig, chain consensus.Cha

// Finalize implements consensus.Engine, accumulating the block and uncle rewards,
// setting the final state on the header
func (ethash *Ethash) Finalize(config *params.ChainConfig, header *types.Header, state *state.IntraBlockState, txs []types.Transaction, uncles []*types.Header, r types.Receipts, e consensus.EpochReader, chain consensus.ChainHeaderReader, syscall consensus.SystemCall) error {
func (ethash *Ethash) Finalize(config *params.ChainConfig, header *types.Header, state *state.IntraBlockState, txs *types.Transactions, uncles []*types.Header, r *types.Receipts, e consensus.EpochReader, chain consensus.ChainHeaderReader, syscall consensus.SystemCall) error {
// Accumulate any block and uncle rewards and commit the final state root
accumulateRewards(config, state, header, uncles)
return nil
}

// FinalizeAndAssemble implements consensus.Engine, accumulating the block and
// uncle rewards, setting the final state and assembling the block.
func (ethash *Ethash) FinalizeAndAssemble(chainConfig *params.ChainConfig, header *types.Header, state *state.IntraBlockState, txs []types.Transaction, uncles []*types.Header, r types.Receipts,
func (ethash *Ethash) FinalizeAndAssemble(chainConfig *params.ChainConfig, header *types.Header, state *state.IntraBlockState, txs *types.Transactions, uncles []*types.Header, r *types.Receipts,
e consensus.EpochReader, chain consensus.ChainHeaderReader, syscall consensus.SystemCall, call consensus.Call) (*types.Block, error) {

// Finalize block
ethash.Finalize(chainConfig, header, state, txs, uncles, r, e, chain, syscall)
_ = ethash.Finalize(chainConfig, header, state, txs, uncles, r, e, chain, syscall)
// Header seems complete, assemble into a block and return
return types.NewBlock(header, txs, uncles, r), nil
return types.NewBlock(header, *txs, uncles, *r), nil
}

// SealHash returns the hash of a block prior to it being sealed.
Expand Down
Loading