-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 Parlia consensus engine for Binance Smart Chain support #3086
Add Parlia consensus engine for Binance Smart Chain support #3086
Conversation
thank you! Can you please fix formatting in couple of files, you can see which in the "Files Changed" tab |
// IsConstantinople returns whether num is either equal to the Constantinople fork block or greater. | ||
func (c *ChainConfig) IsConstantinople(num uint64) bool { | ||
return isForked(c.ConstantinopleBlock, num) | ||
} | ||
|
||
// IsRamanujan returns whether num is either equal to the IsRamanujan fork block or greater. | ||
func (c *ChainConfig) IsRamanujanBigInt(num *big.Int) bool { | ||
return configNumEqual(c.RamanujanBlock, num) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be using isForked
function instead of configNumEqual
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will double check with what BSC did here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use configNumEqual
here since the definitions are:
func isForked(s *big.Int, head uint64) bool
func configNumEqual(x, y *big.Int) bool
There is a compilation error when using isForked
:
params/config.go:581:19: cannot use num (type *big.Int) as type uint64 in argument to isForked
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps in BSC, this hardfork is different, and instead of changing the rules after certain block, it has to execute something on that block, then I would understand the semantics. Can you confirm what Ramanujan hardfork is doing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is what BSC is doing - https://github.com/binance-chain/bsc/blob/master/params/config.go#L732 and here is what is implemented in Erigon - https://github.com/covalenthq/erigon/blob/devel/params/config.go#L710. What I've added is basically a workaround to deal with the 2 forks using big.Int
vs uint64
.
This is all so I can do the checks in these locations: https://github.com/ledgerwatch/erigon/blob/8791d432c846c118e64239ba26e9e8d6416ef92c/consensus/parlia/ramanujanfork.go#L18 https://github.com/ledgerwatch/erigon/blob/8791d432c846c118e64239ba26e9e8d6416ef92c/consensus/parlia/ramanujanfork.go#L31 https://github.com/ledgerwatch/erigon/blob/8791d432c846c118e64239ba26e9e8d6416ef92c/consensus/parlia/ramanujanfork.go#L38
Can you also remove the empty branches and ineffectual assignments (can also be found on "Files Changed" tab. Please do not try to introduce JSON RPC API inside Erigon, and leave it for later. If there are bsc specific APIs that needed to the added to the RPC Daemon, then we can figure out necessary grpc interfaces between RPC Daemon and Erigon. Currently the interface definition is here: https://github.com/ledgerwatch/interfaces/blob/master/remote/ethbackend.proto |
…rigontech#3086)" This reverts commit ee99f17.
* migrated consensus and chain config files for bsc support * migrated more files from bsc * fixed consensus crashing * updated erigon lib for parlia snapshot prefix * added staticpeers for bsc * [+] added system contracts [*] fixed bug with loading snapshot [+] enabled gas bailout [+] added fix to prevent syncing more than 1000 headers (for testing only) [*] fixed bug with crashing sender recover sometimes * migrated system contract calls * [*] fixed bug with returning mutable balance object [+] migrated lightclient contracts from bsc [*] fixed parlia consensus config param * [*] fixed tendermint deps * [+] added some logs * [+] enabled bsc forks [*] fixed syscalls from coinbase [*] more logging * Fix call sys contract gas calculation * [*] fixed executing system transactions * [*] enabled receipt hash, gas and bloom filter checks * [-] removed some logging scripts [*] set header checkpoint to 10 million blocks (for testing forks) * [*] fixed bug with commiting dirty inter block state state after system transaction execution [-] removed some extra logs and comments * [+] added chapel and rialto testnet support * [*] fixed chapel allocs * [-] removed 6 mil block limit for headers sync * Fix hardforks on chapel and other testnets * [*] fixed header sync issue after merge * [*] tiny code cleanup * [-] removed some comments * [*] increased mdbx map size to 4 TB * [*] increased max chaindata size to 6 tb * [*] bring more compatibility with origin erigon and some code cleanup * [+] added support of validator mode for BSC chain * [*] enable private key load for bsc, rialto and chapel chains * [*] fixed running BSC validator node * Fix the branch list * [*] tiny fixes for linter * [*] formatted imports for core and parlia packages * [*] fixed import rules in other files * Revert "[*] formatted imports for core and parlia packages" This reverts commit c764b58. * [*] changed import rules in more packages * [*] fixed type mismatch in hack command * [*] fixed crash on new epoch, enabled bootstrap flags * [*] fixed linter errors * [*] fixed missing err check for syscalls * [*] now BSC implementation is fully compatible with erigon original sources * Revert "Add chain config and CLI changes for Binance Smart Chain support (#3131)" This reverts commit 3d048b7. * Revert "Add Parlia consensus engine for Binance Smart Chain support (#3086)" This reverts commit ee99f17. * [*] fixed several issues after merge * [*] fixed integration compilation * Revert "Fix the branch list" This reverts commit 8150ca5. * [-] removed receipt repair migration * [*] fixed parlia fork numbers output * [*] bring more devel compatibility, fixed bsc address list for access list calculation * [*] fixed bug with commiting state transition for bad blocks in BSC * [*] fixed bsc changes apply for integration command and updated config print for parlia * [*] fixed bug with applying bsc forks for chapel and rialto testnet chains [*] let's use finalize and assemble for mining to let consensus know for what it's finalizing block * Fix compilation errors in hack.go * Fix lint * reset changes in erigon-snapshots to devel * Remove unrelated changes * Fix embed * Remove more unrelated changes * Remove more unrelated changes * Restore clique and aura miner config * Refactor interfaces not to use slice pointers * Refactor parlia functions to return tx and receipt instead of dealing with slices * Fix for header panic * Fix lint, restore system contract addresses * Remove more unrelated changes, unify GatherForks Co-authored-by: Dmitry Ivanov <convexman18@gmail.com> Co-authored-by: j75689 <j75689@gmail.com> Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local> Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
No description provided.