Skip to content

Commit

Permalink
Removed all references to EIPs 2929 and 2930
Browse files Browse the repository at this point in the history
  • Loading branch information
jdowning100 committed May 8, 2023
1 parent 0ec6146 commit f4fa6a6
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 127 deletions.
13 changes: 5 additions & 8 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -968,15 +968,12 @@ func (s *StateDB) Commit(deleteEmptyObjects bool) (common.Hash, error) {
return root, err
}

// PrepareAccessList handles the preparatory steps for executing a state transition with
// regards to both EIP-2929 and EIP-2930:
// PrepareAccessList handles the preparatory steps for executing a state transition
//
// - Add sender to access list (2929)
// - Add destination to access list (2929)
// - Add precompiles to access list (2929)
// - Add the contents of the optional tx access list (2930)
//
// This method should only be called if 2929+2930 is applicable at the current number.
// - Add sender to access list
// - Add destination to access list
// - Add precompiles to access list
// - Add the contents of the optional tx access list
func (s *StateDB) PrepareAccessList(sender common.Address, dst *common.Address, precompiles []common.Address, list types.AccessList) {
s.AddAddressToAccessList(sender)
if dst != nil {
Expand Down
2 changes: 1 addition & 1 deletion core/types/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ func (m Message) ETXGasTip() *big.Int { return m.etxGasTip }
func (m Message) ETXData() []byte { return m.etxData }
func (m Message) ETXAccessList() AccessList { return m.etxAccessList }

// AccessList is an EIP-2930 access list.
// AccessList is an access list.
type AccessList []AccessTuple

// AccessTuple is the element type of an access list.
Expand Down
8 changes: 4 additions & 4 deletions core/types/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ func TestTransactionEncode(t *testing.T) {
}

// This test checks signature operations on access list transactions.
func TestEIP2930Signer(t *testing.T) {
func TestAccessListSigner(t *testing.T) {

var (
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
keyAddr = crypto.PubkeyToAddress(key.PublicKey)
signer1 = NewEIP2930Signer(big.NewInt(1))
signer2 = NewEIP2930Signer(big.NewInt(2))
signer1 = NewSigner(big.NewInt(1))
signer2 = NewSigner(big.NewInt(2))
tx0 = NewTx(&AccessListTx{Nonce: 1})
tx1 = NewTx(&AccessListTx{ChainID: big.NewInt(1), Nonce: 1})
tx2, _ = SignNewTx(key, signer2, &AccessListTx{ChainID: big.NewInt(2), Nonce: 1})
Expand Down Expand Up @@ -316,7 +316,7 @@ func TestTransactionCoding(t *testing.T) {
t.Fatalf("could not generate key: %v", err)
}
var (
signer = NewEIP2930Signer(common.Big1)
signer = NewSigner(common.Big1)
addr = common.HexToAddress("0x0000000000000000000000000000000000000001")
recipient = common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87")
accesses = AccessList{{Address: addr, StorageKeys: []common.Hash{{0}}}}
Expand Down
40 changes: 0 additions & 40 deletions core/vm/eips.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ import (
"fmt"
"sort"

"github.com/dominant-strategies/go-quai/params"
"github.com/holiman/uint256"
)

var activators = map[int]func(*JumpTable){
3529: enable3529,
3198: enable3198,
2929: enable2929,
}

// EnableEIP enables the given EIP on the config.
Expand Down Expand Up @@ -72,44 +70,6 @@ func opChainID(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]
return nil, nil
}

// enable2929 enables "EIP-2929: Gas cost increases for state access opcodes"
// https://eips.ethereum.org/EIPS/eip-2929
func enable2929(jt *JumpTable) {
jt[SSTORE].dynamicGas = gasSStoreEIP2929

jt[SLOAD].constantGas = 0
jt[SLOAD].dynamicGas = gasSLoadEIP2929

jt[EXTCODECOPY].constantGas = params.WarmStorageReadCostEIP2929
jt[EXTCODECOPY].dynamicGas = gasExtCodeCopyEIP2929

jt[EXTCODESIZE].constantGas = params.WarmStorageReadCostEIP2929
jt[EXTCODESIZE].dynamicGas = gasEip2929AccountCheck

jt[EXTCODEHASH].constantGas = params.WarmStorageReadCostEIP2929
jt[EXTCODEHASH].dynamicGas = gasEip2929AccountCheck

jt[BALANCE].constantGas = params.WarmStorageReadCostEIP2929
jt[BALANCE].dynamicGas = gasEip2929AccountCheck

jt[CALL].constantGas = params.WarmStorageReadCostEIP2929
jt[CALL].dynamicGas = gasCallEIP2929

jt[CALLCODE].constantGas = params.WarmStorageReadCostEIP2929
jt[CALLCODE].dynamicGas = gasCallCodeEIP2929

jt[STATICCALL].constantGas = params.WarmStorageReadCostEIP2929
jt[STATICCALL].dynamicGas = gasStaticCallEIP2929

jt[DELEGATECALL].constantGas = params.WarmStorageReadCostEIP2929
jt[DELEGATECALL].dynamicGas = gasDelegateCallEIP2929

// This was previously part of the dynamic cost, but we're using it as a constantGas
// factor here
jt[SELFDESTRUCT].constantGas = params.SelfdestructGas
jt[SELFDESTRUCT].dynamicGas = gasSelfdestructEIP2929
}

// enable3529 enabled "EIP-3529: Reduction in refunds":
// - Removes refunds for selfdestructs
// - Reduces refunds for SSTORE
Expand Down
1 change: 0 additions & 1 deletion core/vm/gas_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ func memoryCopierGas(stackpos int) gasFunc {
var (
gasCallDataCopy = memoryCopierGas(2)
gasCodeCopy = memoryCopierGas(2)
gasExtCodeCopy = memoryCopierGas(3)
gasReturnDataCopy = memoryCopierGas(2)
)

Expand Down
53 changes: 25 additions & 28 deletions core/vm/jump_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,18 @@ func NewInstructionSet() JumpTable {
instructionSet := newInstructionSet()
instructionSet[DELEGATECALL] = &operation{
execute: opDelegateCall,
dynamicGas: gasDelegateCall,
constantGas: params.CallGas,
dynamicGas: gasDelegateCallVariant,
constantGas: params.WarmStorageReadCost,
minStack: minStack(6, 1),
maxStack: maxStack(6, 1),
memorySize: memoryDelegateCall,
returns: true,
}
instructionSet[BALANCE].constantGas = params.BalanceGas
instructionSet[EXTCODESIZE].constantGas = params.ExtcodeSizeGas
instructionSet[SLOAD].constantGas = params.SloadGas
instructionSet[EXTCODECOPY].constantGas = params.ExtcodeCopyBase
instructionSet[CALL].constantGas = params.CallGas
instructionSet[CALLCODE].constantGas = params.CallGas
instructionSet[DELEGATECALL].constantGas = params.CallGas
instructionSet[EXP].dynamicGas = gasExp
instructionSet[STATICCALL] = &operation{
execute: opStaticCall,
constantGas: params.CallGas,
dynamicGas: gasStaticCall,
constantGas: params.WarmStorageReadCost,
dynamicGas: gasStaticCallVariant,
minStack: minStack(6, 1),
maxStack: maxStack(6, 1),
memorySize: memoryStaticCall,
Expand Down Expand Up @@ -127,7 +120,8 @@ func NewInstructionSet() JumpTable {
}
instructionSet[EXTCODEHASH] = &operation{
execute: opExtCodeHash,
constantGas: params.ExtcodeHashGas,
constantGas: params.WarmStorageReadCost,
dynamicGas: gasAccountCheck,
minStack: minStack(1, 1),
maxStack: maxStack(1, 1),
}
Expand All @@ -153,7 +147,6 @@ func NewInstructionSet() JumpTable {
minStack: minStack(0, 1),
maxStack: maxStack(0, 1),
}
enable2929(&instructionSet) // Access lists for trie accesses https://eips.ethereum.org/EIPS/eip-2929
enable3529(&instructionSet) // EIP-3529: Reduction in refunds https://eips.ethereum.org/EIPS/eip-3529
enable3198(&instructionSet) // Base fee opcode https://eips.ethereum.org/EIPS/eip-3198
return instructionSet
Expand Down Expand Up @@ -316,7 +309,8 @@ func newInstructionSet() JumpTable {
},
BALANCE: {
execute: opBalance,
constantGas: params.BalanceGas,
constantGas: params.WarmStorageReadCost,
dynamicGas: gasAccountCheck,
minStack: minStack(1, 1),
maxStack: maxStack(1, 1),
},
Expand Down Expand Up @@ -380,13 +374,14 @@ func newInstructionSet() JumpTable {
},
EXTCODESIZE: {
execute: opExtCodeSize,
constantGas: params.ExtcodeSizeGas,
constantGas: params.WarmStorageReadCost,
dynamicGas: gasAccountCheck,
minStack: minStack(1, 1),
maxStack: maxStack(1, 1),
},
EXTCODECOPY: {
execute: opExtCodeCopy,
constantGas: params.ExtcodeCopyBase,
constantGas: params.WarmStorageReadCost,
dynamicGas: gasExtCodeCopy,
minStack: minStack(4, 0),
maxStack: maxStack(4, 0),
Expand Down Expand Up @@ -460,13 +455,14 @@ func newInstructionSet() JumpTable {
},
SLOAD: {
execute: opSload,
constantGas: params.SloadGas,
constantGas: 0,
dynamicGas: gasSLoad,
minStack: minStack(1, 1),
maxStack: maxStack(1, 1),
},
SSTORE: {
execute: opSstore,
dynamicGas: gasSStore,
dynamicGas: gasSStoreVariant,
minStack: minStack(2, 0),
maxStack: maxStack(2, 0),
writes: true,
Expand Down Expand Up @@ -945,17 +941,17 @@ func newInstructionSet() JumpTable {
},
CALL: {
execute: opCall,
constantGas: params.CallGas,
dynamicGas: gasCall,
constantGas: params.WarmStorageReadCost,
dynamicGas: gasCallVariant,
minStack: minStack(7, 1),
maxStack: maxStack(7, 1),
memorySize: memoryCall,
returns: true,
},
CALLCODE: {
execute: opCallCode,
constantGas: params.CallGas,
dynamicGas: gasCallCode,
constantGas: params.WarmStorageReadCost,
dynamicGas: gasCallCodeVariant,
minStack: minStack(7, 1),
maxStack: maxStack(7, 1),
memorySize: memoryCall,
Expand All @@ -970,12 +966,13 @@ func newInstructionSet() JumpTable {
halts: true,
},
SELFDESTRUCT: {
execute: opSuicide,
dynamicGas: gasSelfdestruct,
minStack: minStack(1, 0),
maxStack: maxStack(1, 0),
halts: true,
writes: true,
execute: opSuicide,
constantGas: params.SelfdestructGas,
dynamicGas: gasSelfdestructVariant,
minStack: minStack(1, 0),
maxStack: maxStack(1, 0),
halts: true,
writes: true,
},
ETX: {
execute: opETX,
Expand Down
Loading

0 comments on commit f4fa6a6

Please sign in to comment.