Add PulseChain config

This commit is contained in:
Shane Bammel 2022-09-26 22:16:17 -05:00
parent 7f131dcbc9
commit 456b50c67d
2 changed files with 62 additions and 0 deletions

View File

@ -365,6 +365,10 @@ type ChainConfig struct {
// Various consensus engines
Ethash *EthashConfig `json:"ethash,omitempty"`
Clique *CliqueConfig `json:"clique,omitempty"`
// PulseChain modifications
PrimordialPulseBlock *big.Int `json:"primordialPulseBlock,omitempty"` // PrimordialPulseBlock switch block (nil = no fork, 0 = already activated)
Treasury *Treasury `json:"treasury,omitempty"` // An optional treasury which will receive allocations during the PrimordialPulseBlock
}
// EthashConfig is the consensus engine configs for proof-of-work based sealing.
@ -578,6 +582,12 @@ func (c *ChainConfig) IsVerkle(num *big.Int, time uint64) bool {
return c.IsLondon(num) && isTimestampForked(c.VerkleTime, time)
}
// IsPrimordialPulseBlock returns whether or not the given block is the primordial pulse block.
func (c *ChainConfig) IsPrimordialPulseBlock(num *big.Int) bool {
// Returns whether or not the given block is the PrimordialPulseBlock.
return c.PrimordialPulseBlock != nil && c.PrimordialPulseBlock.Cmp(num) == 0
}
// CheckCompatible checks whether scheduled fork transitions have been imported
// with a mismatching chain configuration.
func (c *ChainConfig) CheckCompatible(newcfg *ChainConfig, height uint64, time uint64) *ConfigCompatError {
@ -739,6 +749,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, headNumber *big.Int,
if isForkTimestampIncompatible(c.VerkleTime, newcfg.VerkleTime, headTimestamp) {
return newTimestampCompatError("Verkle fork timestamp", c.VerkleTime, newcfg.VerkleTime)
}
if isForkBlockIncompatible(c.PrimordialPulseBlock, newcfg.PrimordialPulseBlock, headNumber) {
return newBlockCompatError("PrimordialPulse fork block", c.PrimordialPulseBlock, newcfg.PrimordialPulseBlock)
}
return nil
}

49
params/pulse.go Normal file
View File

@ -0,0 +1,49 @@
package params
import (
"math/big"
"github.com/ethereum/go-ethereum/common/math"
)
// Optional treasury for launching PulseChain testnets
type Treasury struct {
Addr string `json:"addr"`
Balance *math.HexOrDecimal256 `json:"balance"`
}
var (
PulseChainTestnetConfig = &ChainConfig{
ChainID: big.NewInt(942),
HomesteadBlock: big.NewInt(1_150_000),
DAOForkBlock: big.NewInt(1_920_000),
DAOForkSupport: true,
EIP150Block: big.NewInt(2_463_000),
EIP155Block: big.NewInt(2_675_000),
EIP158Block: big.NewInt(2_675_000),
ByzantiumBlock: big.NewInt(4_370_000),
ConstantinopleBlock: big.NewInt(7_280_000),
PetersburgBlock: big.NewInt(7_280_000),
IstanbulBlock: big.NewInt(9_069_000),
MuirGlacierBlock: big.NewInt(9_200_000),
BerlinBlock: big.NewInt(12_244_000),
LondonBlock: big.NewInt(12_965_000),
ArrowGlacierBlock: big.NewInt(13_773_000),
GrayGlacierBlock: big.NewInt(15_050_000),
TerminalTotalDifficulty: MainnetTerminalTotalDifficulty, // 58_750_000_000_000_000_000_000
TerminalTotalDifficultyPassed: true,
Ethash: new(EthashConfig),
PrimordialPulseBlock: big.NewInt(15_700_000), // TODO: UPDATE FORK BLOCK
Treasury: testnetTreasury(),
}
)
func testnetTreasury() *Treasury {
var pulseChainTestnetTreasuryBalance math.HexOrDecimal256
pulseChainTestnetTreasuryBalance.UnmarshalText([]byte("0xC9F2C9CD04674EDEA40000000"))
return &Treasury{
Addr: "0xceB59257450820132aB274ED61C49E5FD96E8868",
Balance: &pulseChainTestnetTreasuryBalance,
}
}