Skip to content

Commit

Permalink
Removed all references to frontier
Browse files Browse the repository at this point in the history
  • Loading branch information
jdowning100 committed Apr 26, 2023
1 parent 7d676c5 commit 157cb05
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 106 deletions.
13 changes: 0 additions & 13 deletions consensus/blake3pow/consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ func TestDifficultyCalculators(t *testing.T) {
bigFn func(time uint64, parent *types.Header) *big.Int
u256Fn func(time uint64, parent *types.Header) *big.Int
}{
{FrontierDifficultyCalulator, CalcDifficultyFrontierU256},
{DynamicDifficultyCalculator(bombDelay), MakeDifficultyCalculatorU256(bombDelay)},
} {
time := header.Time() + timeDelta
Expand All @@ -132,18 +131,6 @@ func BenchmarkDifficultyCalculator(b *testing.B) {
Number: big.NewInt(500000),
Time: 1000000,
}
b.Run("big-frontier", func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
calcDifficultyFrontier(1000014, h)
}
})
b.Run("u256-frontier", func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
CalcDifficultyFrontierU256(1000014, h)
}
})
b.Run("big-generic", func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
Expand Down
43 changes: 0 additions & 43 deletions consensus/blake3pow/difficulty.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ import (
)

const (
// frontierDurationLimit is for Frontier:
// The decision boundary on the blocktime duration used to determine
// whether difficulty should go up or down.
frontierDurationLimit = 13
// minimumDifficulty The minimum that the difficulty may ever be.
minimumDifficulty = 131072
// expDiffPeriod is the exponential difficulty period
Expand All @@ -21,45 +17,6 @@ const (
difficultyBoundDivisor = 11
)

// CalcDifficultyFrontierU256 is the difficulty adjustment algorithm. It returns the
// difficulty that a new block should have when created at time given the parent
// block's time and difficulty. The calculation uses the Frontier rules.
func CalcDifficultyFrontierU256(time uint64, parent *types.Header) *big.Int {
/*
Algorithm
block_diff = pdiff + pdiff / 2048 * (1 if time - ptime < 13 else -1) + int(2^((num // 100000) - 2))
Where:
- pdiff = parent.difficulty
- ptime = parent.time
- time = block.timestamp
- num = block.number
*/

pDiff, _ := uint256.FromBig(parent.Difficulty()) // pDiff: pdiff
adjust := pDiff.Clone()
adjust.Rsh(adjust, difficultyBoundDivisor) // adjust: pDiff / 2048

if time-parent.Time() < frontierDurationLimit {
pDiff.Add(pDiff, adjust)
} else {
pDiff.Sub(pDiff, adjust)
}
if pDiff.LtUint64(minimumDifficulty) {
pDiff.SetUint64(minimumDifficulty)
}
// 'pdiff' now contains:
// pdiff + pdiff / 2048 * (1 if time - ptime < 13 else -1)

if periodCount := (parent.Number().Uint64() + 1) / expDiffPeriodUint; periodCount > 1 {
// diff = diff + 2^(periodCount - 2)
expDiff := adjust.SetOne()
expDiff.Lsh(expDiff, uint(periodCount-2)) // expdiff: 2 ^ (periodCount -2)
pDiff.Add(pDiff, expDiff)
}
return pDiff.ToBig()
}

// MakeDifficultyCalculatorU256 creates a difficultyCalculator with the given bomb-delay.
// the difficulty is calculated with Byzantium rules, which differs in
// how uncles affect the calculation
Expand Down
1 change: 0 additions & 1 deletion core/forkid/forkid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func TestCreation(t *testing.T) {
params.ColosseumGenesisHash,
[]testcase{
{0, ID{Hash: checksumToBytes(0xfc64ec04), Next: 1150000}}, // Unsynced
{1149999, ID{Hash: checksumToBytes(0xfc64ec04), Next: 1150000}}, // Last Frontier block
{2675000, ID{Hash: checksumToBytes(0x3edd5b10), Next: 4370000}}, // First Spurious block
{4369999, ID{Hash: checksumToBytes(0x3edd5b10), Next: 4370000}}, // Last Spurious block
{4370000, ID{Hash: checksumToBytes(0xa00bc324), Next: 7280000}}, // First Byzantium block
Expand Down
2 changes: 1 addition & 1 deletion core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func IntrinsicGas(data []byte, accessList types.AccessList, isContractCreation b
}
}
// Make sure we don't exceed uint64 for all data combinations
nonZeroGas := params.TxDataNonZeroGasFrontier
nonZeroGas := params.TxDataNonZeroGas
if isEIP2028 {
nonZeroGas = params.TxDataNonZeroGasEIP2028
}
Expand Down
13 changes: 0 additions & 13 deletions core/vm/gas_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,19 +307,6 @@ func gasCreate2(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memoryS
return gas, nil
}

func gasExpFrontier(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
expByteLen := uint64((stack.data[stack.len()-2].BitLen() + 7) / 8)

var (
gas = expByteLen * params.ExpByteFrontier // no overflow check required. Max is 256 * ExpByte gas
overflow bool
)
if gas, overflow = math.SafeAdd(gas, params.ExpGas); overflow {
return 0, ErrGasUintOverflow
}
return gas, nil
}

func gasExp(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
expByteLen := uint64((stack.data[stack.len()-2].BitLen() + 7) / 8)

Expand Down
5 changes: 1 addition & 4 deletions core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,10 +613,7 @@ func opCreate(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]b
}

res, addr, returnGas, suberr := interpreter.evm.Create(scope.Contract, input, gas, bigVal)
// Push item on the stack based on the returned error. If the ruleset is
// _ we must check for CodeStoreOutOfGasError (_ only
// rule) and treat as an error, if the ruleset is frontier we must
// ignore this error and pretend the operation was successful.
// Push item on the stack based on the returned error.
if suberr != nil {
stackvalue.Clear()
} else {
Expand Down
16 changes: 8 additions & 8 deletions core/vm/jump_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func NewInstructionSet() JumpTable {
instructionSet[DELEGATECALL] = &operation{
execute: opDelegateCall,
dynamicGas: gasDelegateCall,
constantGas: params.CallGasFrontier,
constantGas: params.CallGas,
minStack: minStack(6, 1),
maxStack: maxStack(6, 1),
memorySize: memoryDelegateCall,
Expand Down Expand Up @@ -215,7 +215,7 @@ func newInstructionSet() JumpTable {
},
EXP: {
execute: opExp,
dynamicGas: gasExpFrontier,
dynamicGas: gasExp,
minStack: minStack(2, 1),
maxStack: maxStack(2, 1),
},
Expand Down Expand Up @@ -307,7 +307,7 @@ func newInstructionSet() JumpTable {
},
BALANCE: {
execute: opBalance,
constantGas: params.BalanceGasFrontier,
constantGas: params.BalanceGas,
minStack: minStack(1, 1),
maxStack: maxStack(1, 1),
},
Expand Down Expand Up @@ -371,13 +371,13 @@ func newInstructionSet() JumpTable {
},
EXTCODESIZE: {
execute: opExtCodeSize,
constantGas: params.ExtcodeSizeGasFrontier,
constantGas: params.ExtcodeSizeGas,
minStack: minStack(1, 1),
maxStack: maxStack(1, 1),
},
EXTCODECOPY: {
execute: opExtCodeCopy,
constantGas: params.ExtcodeCopyBaseFrontier,
constantGas: params.ExtcodeCopyBase,
dynamicGas: gasExtCodeCopy,
minStack: minStack(4, 0),
maxStack: maxStack(4, 0),
Expand Down Expand Up @@ -451,7 +451,7 @@ func newInstructionSet() JumpTable {
},
SLOAD: {
execute: opSload,
constantGas: params.SloadGasFrontier,
constantGas: params.SloadGas,
minStack: minStack(1, 1),
maxStack: maxStack(1, 1),
},
Expand Down Expand Up @@ -936,7 +936,7 @@ func newInstructionSet() JumpTable {
},
CALL: {
execute: opCall,
constantGas: params.CallGasFrontier,
constantGas: params.CallGas,
dynamicGas: gasCall,
minStack: minStack(7, 1),
maxStack: maxStack(7, 1),
Expand All @@ -945,7 +945,7 @@ func newInstructionSet() JumpTable {
},
CALLCODE: {
execute: opCallCode,
constantGas: params.CallGasFrontier,
constantGas: params.CallGas,
dynamicGas: gasCallCode,
minStack: minStack(7, 1),
maxStack: maxStack(7, 1),
Expand Down
2 changes: 1 addition & 1 deletion crypto/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func ValidateSignatureValues(v byte, r, s *big.Int) bool {
if s.Cmp(secp256k1halfN) > 0 {
return false
}
// Frontier: allow s to be in full N range
// allow s to be in full N range
return r.Cmp(secp256k1N) < 0 && s.Cmp(secp256k1N) < 0 && (v == 0 || v == 1)
}

Expand Down
4 changes: 2 additions & 2 deletions eth/handler_eth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ func testForkIDSplit(t *testing.T, protocol uint) {
select {
case err := <-errc:
if err != nil {
t.Fatalf("frontier nofork <-> profork failed: %v", err)
t.Fatalf(" nofork <-> profork failed: %v", err)
}
case <-time.After(250 * time.Millisecond):
t.Fatalf("frontier nofork <-> profork handler timeout")
t.Fatalf(" nofork <-> profork handler timeout")
}
}

Expand Down
18 changes: 6 additions & 12 deletions params/protocol_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,16 @@ 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.

TxDataNonZeroGasFrontier 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.
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)
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
CallGasFrontier uint64 = 40 // Once per CALL operation & message call transaction.
CallGas uint64 = 700 // Static portion of gas for CALL-derivates now
BalanceGasFrontier uint64 = 20 // The cost of a BALANCE operation
BalanceGas uint64 = 400 // The cost of a BALANCE operation after
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)
ExtcodeSizeGasFrontier uint64 = 20 // Cost of EXTCODESIZE before
ExtcodeSizeGas uint64 = 700 // Cost of EXTCODESIZE now
SloadGasFrontier uint64 = 50
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)
Expand All @@ -106,13 +102,11 @@ const (
SelfdestructGas uint64 = 5000 // Cost of SELFDESTRUCT

// EXP has a dynamic portion depending on the size of the exponent
ExpByteFrontier uint64 = 10 // was set to 10 in Frontier
ExpByte uint64 = 50 // was raised to 50
ExpByte uint64 = 50 // was raised to 50

// Extcodecopy has a dynamic AND a static cost. This represents only the
// static portion of the gas.
ExtcodeCopyBaseFrontier uint64 = 20
ExtcodeCopyBase uint64 = 700
ExtcodeCopyBase uint64 = 700

// CreateBySelfdestructGas is used when the refunded account is one that does
// not exist. This logic is similar to call.
Expand Down
2 changes: 0 additions & 2 deletions tests/difficulty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,11 @@ func TestDifficulty(t *testing.T) {

dt.config("Garden", *params.GardenChainConfig)
dt.config("Morden", *params.GardenChainConfig)
dt.config("Frontier", params.ChainConfig{})

dt.config("Byzantium", params.ChainConfig{
ByzantiumBlock: big.NewInt(0),
})

dt.config("Frontier", *params.GardenChainConfig)
dt.config("MainNetwork", mainnetChainConfig)
dt.config("CustomMainNetwork", mainnetChainConfig)
dt.config("Constantinople", params.ChainConfig{
Expand Down
1 change: 0 additions & 1 deletion tests/fuzzers/difficulty/difficulty-fuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ func (f *fuzzer) fuzz() int {
bigFn calculator
u256Fn calculator
}{
{blake3pow.FrontierDifficultyCalulator, blake3pow.CalcDifficultyFrontierU256},
{blake3pow.DynamicDifficultyCalculator(bombDelay), blake3pow.MakeDifficultyCalculatorU256(bombDelay)},
} {
want := pair.bigFn(time, header)
Expand Down
3 changes: 0 additions & 3 deletions tests/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ import (

// Forks table defines supported forks and their chain config.
var Forks = map[string]*params.ChainConfig{
"Frontier": {
ChainID: big.NewInt(1),
},
"Byzantium": {
ChainID: big.NewInt(1),
EIP155Block: big.NewInt(0),
Expand Down
2 changes: 0 additions & 2 deletions tests/transaction_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ type TransactionTest struct {
Byzantium ttFork
Constantinople ttFork
Istanbul ttFork
Frontier ttFork
}

type ttFork struct {
Expand Down Expand Up @@ -69,7 +68,6 @@ func (tt *TransactionTest) Run(config *params.ChainConfig) error {
fork ttFork
isIstanbul bool
}{
{"Frontier", types.FrontierSigner{}, tt.Frontier, false, false},
{"Byzantium", types.NewEIP155Signer(config.ChainID), tt.Byzantium, true, false},
{"Constantinople", types.NewEIP155Signer(config.ChainID), tt.Constantinople, true, false},
{"Istanbul", types.NewEIP155Signer(config.ChainID), tt.Istanbul, true, true},
Expand Down

0 comments on commit 157cb05

Please sign in to comment.