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
chainID := config.ChainID
if config.PrimordialPulseAhead(blockNumber) {
// ethereum mainnet chainID is 1
// required to validate transactions on mainnet
chainID := big.NewInt(1)
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

@ -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
}