Skip to content

Commit

Permalink
Removed all references to Istanbul and EIP2028 from the codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
jdowning100 committed May 5, 2023
1 parent 1f46861 commit c6bb195
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 105 deletions.
1 change: 0 additions & 1 deletion consensus/misc/eip1559_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
func copyConfig(original *params.ChainConfig) *params.ChainConfig {
return &params.ChainConfig{
ChainID: original.ChainID,
IstanbulBlock: original.IstanbulBlock,
MuirGlacierBlock: original.MuirGlacierBlock,
BerlinBlock: original.BerlinBlock,
LondonBlock: original.LondonBlock,
Expand Down
1 change: 0 additions & 1 deletion core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,6 @@ func TestStateProcessorErrors(t *testing.T) {
var (
config = &params.ChainConfig{
ChainID: big.NewInt(1),
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
Expand Down
8 changes: 2 additions & 6 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (result *ExecutionResult) Revert() []byte {
}

// IntrinsicGas computes the 'intrinsic gas' for a message with the given data.
func IntrinsicGas(data []byte, accessList types.AccessList, isContractCreation bool, isEIP2028 bool) (uint64, error) {
func IntrinsicGas(data []byte, accessList types.AccessList, isContractCreation bool) (uint64, error) {
// Set the starting gas for the raw transaction
var gas uint64
if isContractCreation {
Expand All @@ -145,9 +145,6 @@ func IntrinsicGas(data []byte, accessList types.AccessList, isContractCreation b
}
// Make sure we don't exceed uint64 for all data combinations
nonZeroGas := params.TxDataNonZeroGas
if isEIP2028 {
nonZeroGas = params.TxDataNonZeroGasEIP2028
}
if (math.MaxUint64-gas)/nonZeroGas < nz {
return 0, ErrGasUintOverflow
}
Expand Down Expand Up @@ -304,12 +301,11 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
}
msg := st.msg
sender := vm.AccountRef(msg.From())
istanbul := st.evm.ChainConfig().IsIstanbul(st.evm.Context.BlockNumber)
london := st.evm.ChainConfig().IsLondon(st.evm.Context.BlockNumber)
contractCreation := msg.To() == nil

// Check clauses 4-5, subtract intrinsic gas if everything is correct
gas, err := IntrinsicGas(st.data, st.msg.AccessList(), contractCreation, istanbul)
gas, err := IntrinsicGas(st.data, st.msg.AccessList(), contractCreation)
if err != nil {
return nil, err
}
Expand Down
8 changes: 3 additions & 5 deletions core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,8 @@ type TxPool struct {
signer types.Signer
mu sync.RWMutex

istanbul bool // Fork indicator whether we are in the istanbul stage.
eip2718 bool // Fork indicator whether we are using EIP-2718 type transactions.
eip1559 bool // Fork indicator whether we are using EIP-1559 type transactions.
eip2718 bool // Fork indicator whether we are using EIP-2718 type transactions.
eip1559 bool // Fork indicator whether we are using EIP-1559 type transactions.

currentState *state.StateDB // Current state in the blockchain head
pendingNonces *txNoncer // Pending state tracking virtual nonces
Expand Down Expand Up @@ -633,7 +632,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
return ErrInsufficientFunds
}
// Ensure the transaction has more gas than the basic tx fee.
intrGas, err := IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, pool.istanbul)
intrGas, err := IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil)
if err != nil {
return err
}
Expand Down Expand Up @@ -1309,7 +1308,6 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) {

// Update all fork indicator by next pending block number.
next := new(big.Int).Add(newHead.Number(), big.NewInt(1))
pool.istanbul = pool.chainconfig.IsIstanbul(next)
pool.eip2718 = pool.chainconfig.IsBerlin(next)
pool.eip1559 = pool.chainconfig.IsLondon(next)
}
Expand Down
41 changes: 20 additions & 21 deletions core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ func InitializePrecompiles() {
PrecompiledContracts[PrecompiledAddresses[common.NodeLocation.Name()][2]] = &ripemd160hash{}
PrecompiledContracts[PrecompiledAddresses[common.NodeLocation.Name()][3]] = &dataCopy{}
PrecompiledContracts[PrecompiledAddresses[common.NodeLocation.Name()][4]] = &bigModExp{eip2565: true}
PrecompiledContracts[PrecompiledAddresses[common.NodeLocation.Name()][5]] = &bn256AddIstanbul{}
PrecompiledContracts[PrecompiledAddresses[common.NodeLocation.Name()][6]] = &bn256ScalarMulIstanbul{}
PrecompiledContracts[PrecompiledAddresses[common.NodeLocation.Name()][7]] = &bn256PairingIstanbul{}
PrecompiledContracts[PrecompiledAddresses[common.NodeLocation.Name()][5]] = &bn256Add{}
PrecompiledContracts[PrecompiledAddresses[common.NodeLocation.Name()][6]] = &bn256ScalarMul{}
PrecompiledContracts[PrecompiledAddresses[common.NodeLocation.Name()][7]] = &bn256Pairing{}
PrecompiledContracts[PrecompiledAddresses[common.NodeLocation.Name()][8]] = &blake2F{}
}

Expand Down Expand Up @@ -462,16 +462,15 @@ func runBn256Add(input []byte) ([]byte, error) {
return res.Marshal(), nil
}

// bn256Add implements a native elliptic curve point addition conforming to
// Istanbul consensus rules.
type bn256AddIstanbul struct{}
// bn256Add implements a native elliptic curve point addition conforming to consensus rules.
type bn256Add struct{}

// RequiredGas returns the gas required to execute the pre-compiled contract.
func (c *bn256AddIstanbul) RequiredGas(input []byte) uint64 {
return params.Bn256AddGasIstanbul
func (c *bn256Add) RequiredGas(input []byte) uint64 {
return params.Bn256AddGas
}

func (c *bn256AddIstanbul) Run(input []byte) ([]byte, error) {
func (c *bn256Add) Run(input []byte) ([]byte, error) {
return runBn256Add(input)
}

Expand All @@ -486,16 +485,16 @@ func runBn256ScalarMul(input []byte) ([]byte, error) {
return res.Marshal(), nil
}

// bn256ScalarMulIstanbul implements a native elliptic curve scalar
// multiplication conforming to Istanbul consensus rules.
type bn256ScalarMulIstanbul struct{}
// bn256ScalarMul implements a native elliptic curve scalar
// multiplication conforming to consensus rules.
type bn256ScalarMul struct{}

// RequiredGas returns the gas required to execute the pre-compiled contract.
func (c *bn256ScalarMulIstanbul) RequiredGas(input []byte) uint64 {
return params.Bn256ScalarMulGasIstanbul
func (c *bn256ScalarMul) RequiredGas(input []byte) uint64 {
return params.Bn256ScalarMulGas
}

func (c *bn256ScalarMulIstanbul) Run(input []byte) ([]byte, error) {
func (c *bn256ScalarMul) Run(input []byte) ([]byte, error) {
return runBn256ScalarMul(input)
}

Expand Down Expand Up @@ -540,16 +539,16 @@ func runBn256Pairing(input []byte) ([]byte, error) {
return false32Byte, nil
}

// bn256PairingIstanbul implements a pairing pre-compile for the bn256 curve
// conforming to Istanbul consensus rules.
type bn256PairingIstanbul struct{}
// bn256Pairing implements a pairing pre-compile for the bn256 curve
// conforming to consensus rules.
type bn256Pairing struct{}

// RequiredGas returns the gas required to execute the pre-compiled contract.
func (c *bn256PairingIstanbul) RequiredGas(input []byte) uint64 {
return params.Bn256PairingBaseGasIstanbul + uint64(len(input)/192)*params.Bn256PairingPerPointGasIstanbul
func (c *bn256Pairing) RequiredGas(input []byte) uint64 {
return params.Bn256PairingBaseGas + uint64(len(input)/192)*params.Bn256PairingPerPointGas
}

func (c *bn256PairingIstanbul) Run(input []byte) ([]byte, error) {
func (c *bn256Pairing) Run(input []byte) ([]byte, error) {
return runBn256Pairing(input)
}

Expand Down
6 changes: 3 additions & 3 deletions core/vm/contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ var allPrecompiles = map[common.Address]PrecompiledContract{
common.BytesToAddress([]byte{4}): &dataCopy{},
common.BytesToAddress([]byte{5}): &bigModExp{eip2565: false},
common.BytesToAddress([]byte{0xf5}): &bigModExp{eip2565: true},
common.BytesToAddress([]byte{6}): &bn256AddIstanbul{},
common.BytesToAddress([]byte{7}): &bn256ScalarMulIstanbul{},
common.BytesToAddress([]byte{8}): &bn256PairingIstanbul{},
common.BytesToAddress([]byte{6}): &bn256Add{},
common.BytesToAddress([]byte{7}): &bn256ScalarMul{},
common.BytesToAddress([]byte{8}): &bn256Pairing{},
common.BytesToAddress([]byte{9}): &blake2F{},
}

Expand Down
1 change: 0 additions & 1 deletion core/vm/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func setDefaults(cfg *Config) {
if cfg.ChainConfig == nil {
cfg.ChainConfig = &params.ChainConfig{
ChainID: big.NewInt(1),
IstanbulBlock: new(big.Int),
MuirGlacierBlock: new(big.Int),
BerlinBlock: new(big.Int),
LondonBlock: new(big.Int),
Expand Down
30 changes: 6 additions & 24 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ var (
// ColosseumChainConfig is the chain parameters to run a node on the Colosseum network.
ColosseumChainConfig = &ChainConfig{
ChainID: big.NewInt(9000),
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
Expand All @@ -47,7 +46,6 @@ var (
// GardenChainConfig contains the chain parameters to run a node on the Garden test network.
GardenChainConfig = &ChainConfig{
ChainID: big.NewInt(12000),
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
Expand All @@ -58,7 +56,6 @@ var (
// OrchardChainConfig contains the chain parameters to run a node on the Orchard test network.
OrchardChainConfig = &ChainConfig{
ChainID: big.NewInt(15000),
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
Expand All @@ -69,7 +66,6 @@ var (
// GalenaChainConfig contains the chain parameters to run a node on the Galena test network.
GalenaChainConfig = &ChainConfig{
ChainID: big.NewInt(17000),
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
Expand All @@ -80,7 +76,6 @@ var (
// LocalChainConfig contains the chain parameters to run a node on the Local test network.
LocalChainConfig = &ChainConfig{
ChainID: big.NewInt(1337),
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
Expand All @@ -93,9 +88,9 @@ var (
//
// This configuration is intentionally not using keyed fields to force anyone
// adding flags to the config to also have to set these fields.
AllBlake3powProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), new(Blake3powConfig), common.Hash{}}
AllBlake3powProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), big.NewInt(0), big.NewInt(0), new(Blake3powConfig), common.Hash{}}

TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), new(Blake3powConfig), common.Hash{}}
TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), big.NewInt(0), big.NewInt(0), new(Blake3powConfig), common.Hash{}}
TestRules = TestChainConfig.Rules(new(big.Int))
)

Expand All @@ -107,7 +102,6 @@ var (
type ChainConfig struct {
ChainID *big.Int `json:"chainId"` // chainId identifies the current chain and is used for replay protection

IstanbulBlock *big.Int `json:"istanbulBlock,omitempty"` // Istanbul switch block (nil = no fork, 0 = already on istanbul)
MuirGlacierBlock *big.Int `json:"muirGlacierBlock,omitempty"` // Eip-2384 (bomb delay) switch block (nil = no fork, 0 = already activated)
BerlinBlock *big.Int `json:"berlinBlock,omitempty"` // Berlin switch block (nil = no fork, 0 = already on berlin)
LondonBlock *big.Int `json:"londonBlock,omitempty"` // London switch block (nil = no fork, 0 = already on london)
Expand All @@ -134,9 +128,8 @@ func (c *ChainConfig) String() string {
default:
engine = "unknown"
}
return fmt.Sprintf("{ChainID: %v %v Istanbul: %v, Muir Glacier: %v, Berlin: %v, London: %v, Engine: %v}",
return fmt.Sprintf("{ChainID: %v Muir Glacier: %v, Berlin: %v, London: %v, Engine: %v}",
c.ChainID,
c.IstanbulBlock,
c.MuirGlacierBlock,
c.BerlinBlock,
c.LondonBlock,
Expand All @@ -149,11 +142,6 @@ func (c *ChainConfig) IsMuirGlacier(num *big.Int) bool {
return isForked(c.MuirGlacierBlock, num)
}

// IsIstanbul returns whether num is either equal to the Istanbul fork block or greater.
func (c *ChainConfig) IsIstanbul(num *big.Int) bool {
return isForked(c.IstanbulBlock, num)
}

// IsBerlin returns whether num is either equal to the Berlin fork block or greater.
func (c *ChainConfig) IsBerlin(num *big.Int) bool {
return isForked(c.BerlinBlock, num)
Expand Down Expand Up @@ -192,7 +180,6 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
}
var lastFork fork
for _, cur := range []fork{
{name: "istanbulBlock", block: c.IstanbulBlock},
{name: "muirGlacierBlock", block: c.MuirGlacierBlock, optional: true},
{name: "berlinBlock", block: c.BerlinBlock},
{name: "londonBlock", block: c.LondonBlock},
Expand All @@ -219,9 +206,6 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
}

func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *ConfigCompatError {
if isForkIncompatible(c.IstanbulBlock, newcfg.IstanbulBlock, head) {
return newCompatError("Istanbul fork block", c.IstanbulBlock, newcfg.IstanbulBlock)
}
if isForkIncompatible(c.MuirGlacierBlock, newcfg.MuirGlacierBlock, head) {
return newCompatError("Muir Glacier fork block", c.MuirGlacierBlock, newcfg.MuirGlacierBlock)
}
Expand Down Expand Up @@ -296,7 +280,6 @@ func (err *ConfigCompatError) Error() string {
// phases.
type Rules struct {
ChainID *big.Int
IsIstanbul bool
IsBerlin, IsLondon bool
}

Expand All @@ -307,9 +290,8 @@ func (c *ChainConfig) Rules(num *big.Int) Rules {
chainID = new(big.Int)
}
return Rules{
ChainID: new(big.Int).Set(chainID),
IsIstanbul: c.IsIstanbul(num),
IsBerlin: c.IsBerlin(num),
IsLondon: c.IsLondon(num),
ChainID: new(big.Int).Set(chainID),
IsBerlin: c.IsBerlin(num),
IsLondon: c.IsLondon(num),
}
}
19 changes: 9 additions & 10 deletions params/protocol_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,20 @@ const (
SelfdestructRefundGas uint64 = 24000 // Refunded following a selfdestruct operation.
MemoryGas uint64 = 3 // Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL.

TxDataNonZeroGas uint64 = 68 // Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions.
TxDataNonZeroGasEIP2028 uint64 = 16 // Per byte of non zero data attached to a transaction after EIP 2028 (part in Istanbul)
TxDataNonZeroGas uint64 = 16 // Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions.
TxAccessListAddressGas uint64 = 2400 // Per address specified in EIP 2930 access list
TxAccessListStorageKeyGas uint64 = 1900 // Per storage key specified in EIP 2930 access list

// These have been changed during the course of the chain
CallGas uint64 = 700 // Static portion of gas for CALL-derivates
BalanceGas uint64 = 400 // The cost of a BALANCE operation
BalanceGasEIP1884 uint64 = 700 // The cost of a BALANCE operation after EIP 1884 (part of Istanbul)
BalanceGasEIP1884 uint64 = 700 // The cost of a BALANCE operation after EIP 1884
ExtcodeSizeGas uint64 = 700 // Cost of EXTCODESIZE
SloadGas uint64 = 200
SloadGasEIP1884 uint64 = 800 // Cost of SLOAD after EIP 1884 (part of Istanbul)
SloadGasEIP2200 uint64 = 800 // Cost of SLOAD after EIP 2200 (part of Istanbul)
SloadGasEIP1884 uint64 = 800 // Cost of SLOAD after EIP 1884
SloadGasEIP2200 uint64 = 800 // Cost of SLOAD after EIP 2200
ExtcodeHashGas uint64 = 400 // Cost of EXTCODEHASH
ExtcodeHashGasEIP1884 uint64 = 700 // Cost of EXTCODEHASH after EIP 1884 (part in Istanbul)
ExtcodeHashGasEIP1884 uint64 = 700 // Cost of EXTCODEHASH after EIP 1884
SelfdestructGas uint64 = 5000 // Cost of SELFDESTRUCT

// EXP has a dynamic portion depending on the size of the exponent
Expand Down Expand Up @@ -129,10 +128,10 @@ const (
IdentityBaseGas uint64 = 15 // Base price for a data copy operation
IdentityPerWordGas uint64 = 3 // Per-work price for a data copy operation

Bn256AddGasIstanbul uint64 = 150 // Gas needed for an elliptic curve addition
Bn256ScalarMulGasIstanbul uint64 = 6000 // Gas needed for an elliptic curve scalar multiplication
Bn256PairingBaseGasIstanbul uint64 = 45000 // Base price for an elliptic curve pairing check
Bn256PairingPerPointGasIstanbul uint64 = 34000 // Per-point price for an elliptic curve pairing check
Bn256AddGas uint64 = 150 // Gas needed for an elliptic curve addition
Bn256ScalarMulGas uint64 = 6000 // Gas needed for an elliptic curve scalar multiplication
Bn256PairingBaseGas uint64 = 45000 // Base price for an elliptic curve pairing check
Bn256PairingPerPointGas uint64 = 34000 // Per-point price for an elliptic curve pairing check

// The Refund Quotient is the cap on how much of the used gas can be refunded. Before EIP-3529,
// up to half the consumed gas could be refunded. Redefined as 1/5th in EIP-3529
Expand Down
3 changes: 0 additions & 3 deletions tests/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,4 @@ func TestBlockchain(t *testing.T) {
t.Errorf("test with snapshotter failed: %v", err)
}
})
// There is also a LegacyTests folder, containing blockchain tests generated
// prior to Istanbul. However, they are all derived from GeneralStateTests,
// which run natively, so there's no reason to run them here.
}
30 changes: 11 additions & 19 deletions tests/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,24 @@ import (

// Forks table defines supported forks and their chain config.
var Forks = map[string]*params.ChainConfig{
"Istanbul": {
ChainID: big.NewInt(1),
IstanbulBlock: big.NewInt(0),
},
"Berlin": {
ChainID: big.NewInt(1),
IstanbulBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
ChainID: big.NewInt(1),
BerlinBlock: big.NewInt(0),
},
"BerlinToLondonAt5": {
ChainID: big.NewInt(1),
IstanbulBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(5),
ChainID: big.NewInt(1),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(5),
},
"London": {
ChainID: big.NewInt(1),
IstanbulBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
ChainID: big.NewInt(1),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
},
"Aleut": {
ChainID: big.NewInt(1),
IstanbulBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
ChainID: big.NewInt(1),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
},
}

Expand Down
Loading

0 comments on commit c6bb195

Please sign in to comment.