mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-21 19:20:39 +00:00
Switch sacrifice credits based on chainID
This commit is contained in:
parent
93c50d59a5
commit
e8ba24e831
@ -567,7 +567,7 @@ func (ethash *Ethash) Finalize(config *chain.Config, header *types.Header, state
|
|||||||
) (types.Transactions, types.Receipts, error) {
|
) (types.Transactions, types.Receipts, error) {
|
||||||
// Apply fork changes on PrimordialPulse block
|
// Apply fork changes on PrimordialPulse block
|
||||||
if config.IsPrimordialPulseBlock(header.Number.Uint64()) {
|
if config.IsPrimordialPulseBlock(header.Number.Uint64()) {
|
||||||
pulse.PrimordialPulseFork(state, config.PulseChain)
|
pulse.PrimordialPulseFork(state, config.PulseChain, config.ChainID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accumulate any block and uncle rewards and commit the final state root
|
// Accumulate any block and uncle rewards and commit the final state root
|
||||||
|
@ -2,12 +2,17 @@
|
|||||||
package pulse
|
package pulse
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math/big"
|
||||||
|
|
||||||
"github.com/ledgerwatch/erigon-lib/chain"
|
"github.com/ledgerwatch/erigon-lib/chain"
|
||||||
"github.com/ledgerwatch/erigon/core/state"
|
"github.com/ledgerwatch/erigon/core/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var MainnetChainID = big.NewInt(369)
|
||||||
|
var TestnetV4ChainID = big.NewInt(943)
|
||||||
|
|
||||||
// PrimordialPulseFork applies the PrimordialPulse fork changes.
|
// PrimordialPulseFork applies the PrimordialPulse fork changes.
|
||||||
func PrimordialPulseFork(state *state.IntraBlockState, pulseChainConfig *chain.PulseChainConfig) {
|
func PrimordialPulseFork(state *state.IntraBlockState, pulseChainConfig *chain.PulseChainConfig, chainID *big.Int) {
|
||||||
applySacrificeCredits(state, pulseChainConfig)
|
applySacrificeCredits(state, pulseChainConfig, chainID)
|
||||||
replaceDepositContract(state)
|
replaceDepositContract(state)
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
_ "embed"
|
_ "embed"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math/big"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/holiman/uint256"
|
"github.com/holiman/uint256"
|
||||||
@ -14,14 +15,23 @@ import (
|
|||||||
"github.com/ledgerwatch/erigon/core/state"
|
"github.com/ledgerwatch/erigon/core/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The testnet credits are approximate and not final for mainnet
|
// see https://gitlab.com/pulsechaincom/compressed-allocations/-/tags/Mainnet
|
||||||
// see https://gitlab.com/pulsechaincom/compressed-allocations/-/tree/Testnet-R2-Credits
|
|
||||||
//
|
//
|
||||||
//go:embed sacrifice_credits.bin
|
//go:embed sacrifice_credits_mainnet.bin
|
||||||
var rawCredits []byte
|
var mainnetRawCredits []byte
|
||||||
|
|
||||||
|
// see https://gitlab.com/pulsechaincom/compressed-allocations/-/tags/Testnet-V4
|
||||||
|
//
|
||||||
|
//go:embed sacrifice_credits_testnet_v4.bin
|
||||||
|
var testnetV4RawCredits []byte
|
||||||
|
|
||||||
// Applies the sacrifice credits for the PrimordialPulse fork.
|
// Applies the sacrifice credits for the PrimordialPulse fork.
|
||||||
func applySacrificeCredits(state *state.IntraBlockState, pulseChainConfig *chain.PulseChainConfig) {
|
func applySacrificeCredits(state *state.IntraBlockState, pulseChainConfig *chain.PulseChainConfig, chainID *big.Int) {
|
||||||
|
rawCredits := mainnetRawCredits
|
||||||
|
if chainID.Cmp(TestnetV4ChainID) == 0 {
|
||||||
|
rawCredits = testnetV4RawCredits
|
||||||
|
}
|
||||||
|
|
||||||
if pulseChainConfig != nil && pulseChainConfig.Treasury != nil {
|
if pulseChainConfig != nil && pulseChainConfig.Treasury != nil {
|
||||||
balance, err := uint256.FromHex(pulseChainConfig.Treasury.Balance)
|
balance, err := uint256.FromHex(pulseChainConfig.Treasury.Balance)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
BIN
pulse/sacrifice_credits_mainnet.bin
Normal file
BIN
pulse/sacrifice_credits_mainnet.bin
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user