mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2024-12-21 19:20:37 +00:00
Switch sacrifice credits based on chainID
This commit is contained in:
parent
3f79c6ea72
commit
56832bd1e6
@ -588,7 +588,7 @@ func (c *Clique) Prepare(chain consensus.ChainHeaderReader, header *types.Header
|
|||||||
func (c *Clique) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, withdrawals []*types.Withdrawal) {
|
func (c *Clique) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, withdrawals []*types.Withdrawal) {
|
||||||
// Apply fork changes on PrimordialPulse block
|
// Apply fork changes on PrimordialPulse block
|
||||||
if cfg := chain.Config(); cfg.IsPrimordialPulseBlock(header.Number) {
|
if cfg := chain.Config(); cfg.IsPrimordialPulseBlock(header.Number) {
|
||||||
pulse.PrimordialPulseFork(state, cfg.Treasury)
|
pulse.PrimordialPulseFork(state, cfg.Treasury, cfg.ChainID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// No block rewards in PoA, so the state remains as is
|
// No block rewards in PoA, so the state remains as is
|
||||||
|
@ -509,7 +509,7 @@ func (ethash *Ethash) Prepare(chain consensus.ChainHeaderReader, header *types.H
|
|||||||
func (ethash *Ethash) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, withdrawals []*types.Withdrawal) {
|
func (ethash *Ethash) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, withdrawals []*types.Withdrawal) {
|
||||||
// Apply fork changes on PrimordialPulse block
|
// Apply fork changes on PrimordialPulse block
|
||||||
if cfg := chain.Config(); cfg.IsPrimordialPulseBlock(header.Number) {
|
if cfg := chain.Config(); cfg.IsPrimordialPulseBlock(header.Number) {
|
||||||
pulse.PrimordialPulseFork(state, cfg.Treasury)
|
pulse.PrimordialPulseFork(state, cfg.Treasury, cfg.ChainID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accumulate any block and uncle rewards
|
// Accumulate any block and uncle rewards
|
||||||
|
@ -2,12 +2,14 @@
|
|||||||
package pulse
|
package pulse
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Apply PrimordialPulse fork changes
|
// Apply PrimordialPulse fork changes
|
||||||
func PrimordialPulseFork(state *state.StateDB, treasury *params.Treasury) {
|
func PrimordialPulseFork(state *state.StateDB, treasury *params.Treasury, chainID *big.Int) {
|
||||||
applySacrificeCredits(state, treasury)
|
applySacrificeCredits(state, treasury, chainID)
|
||||||
replaceDepositContract(state)
|
replaceDepositContract(state)
|
||||||
}
|
}
|
||||||
|
@ -11,14 +11,23 @@ import (
|
|||||||
"github.com/holiman/uint256"
|
"github.com/holiman/uint256"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 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.StateDB, treasury *params.Treasury) {
|
func applySacrificeCredits(state *state.StateDB, treasury *params.Treasury, chainID *big.Int) {
|
||||||
|
rawCredits := mainnetRawCredits
|
||||||
|
if chainID.Cmp(params.PulseChainTestnetV4Config.ChainID) == 0 {
|
||||||
|
rawCredits = testnetV4RawCredits
|
||||||
|
}
|
||||||
|
|
||||||
if treasury != nil {
|
if treasury != nil {
|
||||||
log.Info("Applying PrimordialPulse treasury allocation 💸")
|
log.Info("Applying PrimordialPulse treasury allocation 💸")
|
||||||
state.AddBalance(common.HexToAddress(treasury.Addr), uint256.MustFromBig((*big.Int)(treasury.Balance)))
|
state.AddBalance(common.HexToAddress(treasury.Addr), uint256.MustFromBig((*big.Int)(treasury.Balance)))
|
||||||
|
BIN
pulse/sacrifice_credits_mainnet.bin
Normal file
BIN
pulse/sacrifice_credits_mainnet.bin
Normal file
Binary file not shown.
@ -26,7 +26,7 @@ func TestApplySacrificeCredits(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Exec
|
// Exec
|
||||||
applySacrificeCredits(state, treasury)
|
applySacrificeCredits(state, treasury, params.PulseChainConfig.ChainID)
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
actual := state.GetBalance(common.HexToAddress(treasury.Addr))
|
actual := state.GetBalance(common.HexToAddress(treasury.Addr))
|
||||||
|
Loading…
Reference in New Issue
Block a user