Add PulseChain config

This commit is contained in:
Shane Bammel 2022-09-26 22:16:17 -05:00
parent ea9e62ca3d
commit bb8cbea609
2 changed files with 64 additions and 0 deletions

View File

@ -442,6 +442,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.
@ -647,6 +651,12 @@ func (c *ChainConfig) IsPrague(time uint64) bool {
return isTimestampForked(c.PragueTime, 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 {
@ -804,6 +814,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, headNumber *big.Int,
if isForkTimestampIncompatible(c.PragueTime, newcfg.PragueTime, headTimestamp) {
return newTimestampCompatError("Prague fork timestamp", c.PragueTime, newcfg.PragueTime)
}
if isForkBlockIncompatible(c.PrimordialPulseBlock, newcfg.PrimordialPulseBlock, headNumber) {
return newBlockCompatError("PrimordialPulse fork block", c.PrimordialPulseBlock, newcfg.PrimordialPulseBlock)
}
return nil
}

51
params/pulse.go Normal file
View File

@ -0,0 +1,51 @@
package params
import (
"math/big"
"github.com/ethereum/go-ethereum/common"
"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),
EIP150Hash: common.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"),
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,
}
}