Support for non-pulse, non-mainnet eth chains

This commit is contained in:
Shane Bammel 2021-09-10 13:48:35 -05:00
parent b4e9dd5362
commit 30708436bf
3 changed files with 13 additions and 10 deletions

View File

@ -20,11 +20,11 @@ import (
"crypto/ecdsa"
"errors"
"fmt"
"github.com/ethereum/go-ethereum/log"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
)
@ -41,19 +41,22 @@ type sigCache struct {
func MakeSigner(config *params.ChainConfig, blockNumber *big.Int) Signer {
var signer Signer
// ethereum mainnet chainID is 1
// required to validate transactions on mainnet
chainID := big.NewInt(1)
chainID := config.ChainID
if config.PrimordialPulseAhead(blockNumber) {
// ethereum mainnet chainID is 1
// required to validate transactions on mainnet
chainID = big.NewInt(1)
}
switch {
case config.IsPrimordialPulse(blockNumber):
signer = NewLondonSigner(chainID)
case config.IsLondon(blockNumber):
signer = NewLondonSigner(config.ChainID)
signer = NewLondonSigner(chainID)
case config.IsBerlin(blockNumber):
signer = NewEIP2930Signer(config.ChainID)
signer = NewEIP2930Signer(chainID)
case config.IsEIP155(blockNumber):
signer = NewEIP155Signer(config.ChainID)
signer = NewEIP155Signer(chainID)
case config.IsHomestead(blockNumber):
signer = HomesteadSigner{}
default:

View File

@ -127,7 +127,7 @@ type EVM struct {
func NewEVM(blockCtx BlockContext, txCtx TxContext, statedb StateDB, chainConfig *params.ChainConfig, config Config) *EVM {
msgChainConfig := chainConfig
if !chainConfig.IsPrimordialPulse(blockCtx.BlockNumber) {
if chainConfig.PrimordialPulseAhead(blockCtx.BlockNumber) {
// create a shallow of chainConfig struct and set to ethereum mainnet
chainCfgCpy := *chainConfig
chainCfgCpy.ChainID = big.NewInt(1)

View File

@ -80,7 +80,7 @@ var (
SectionHead: common.HexToHash("0x50fd3cec5376ede90ef9129772022690cd1467f22c18abb7faa11e793c51e9c9"),
CHTRoot: common.HexToHash("0xb57b4b22a77b5930847b1ca9f62daa11eae6578948cb7b18997f2c0fe5757025"),
BloomRoot: common.HexToHash("0xa338f8a868a194fa90327d0f5877f656a9f3640c618d2a01a01f2e76ef9ef954"),
}
}
// MainnetCheckpointOracle contains a set of configs for the main network oracle.
MainnetCheckpointOracle = &CheckpointOracleConfig{
@ -649,7 +649,7 @@ func (c *ChainConfig) IsPrimordialPulseBlock(number uint64) bool {
}
// Returns true if there is a PrimordialPulse block in the future, indicating this chain
// should still be evaluated using the ethash consensus engine.
// should still be evaluated using the ethash consensus engine and with mainnet ChainID.
func (c *ChainConfig) PrimordialPulseAhead(number *big.Int) bool {
return c.PrimordialPulseBlock != nil && c.PrimordialPulseBlock.Cmp(number) > 0
}