Skip to content

Commit

Permalink
Merge branch 'master' into ci-shellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
ceyonur authored Jan 31, 2024
2 parents d4e0cb9 + 840876a commit d013ac5
Show file tree
Hide file tree
Showing 52 changed files with 794 additions and 727 deletions.
7 changes: 3 additions & 4 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,8 @@ func NewSimulatedBackendWithDatabase(database ethdb.Database, alloc core.Genesis
Alloc: alloc,
}
cacheConfig := &core.CacheConfig{}
blockchain, err := core.NewBlockChain(database, cacheConfig, &genesis, dummy.NewCoinbaseFaker(), vm.Config{}, common.Hash{}, false)
if err != nil {
panic(fmt.Sprintf("failed to create simulated blockchain: %v", err))
}
blockchain, _ := core.NewBlockChain(database, cacheConfig, &genesis, dummy.NewCoinbaseFaker(), vm.Config{}, common.Hash{}, false)

backend := &SimulatedBackend{
database: database,
blockchain: blockchain,
Expand Down Expand Up @@ -610,6 +608,7 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call interfaces.Call
for lo+1 < hi {
mid := (hi + lo) / 2
failed, _, err := executable(mid)

// If the error is not nil(consensus error), it means the provided message
// call or transaction will never be accepted no matter how much gas it is
// assigned. Return the error directly, don't struggle any more
Expand Down
136 changes: 75 additions & 61 deletions accounts/abi/bind/bind_test.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion consensus/dummy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The dummy consensus engine is responsible for performing verification on the hea

Subnet-EVM includes a dynamic fee algorithm based off of (EIP-1559)[https://eips.ethereum.org/EIPS/eip-1559]. This introduces a field to the block type called `BaseFee`. The Base Fee sets a minimum gas price for any transaction to be included in the block. For example, a transaction with a gas price of 49 gwei, will be invalid to include in a block with a base fee of 50 gwei.

The dynamic fee algorithm aims to adjust the base fee to handle network congestion. Subnet-EVM sets a target utilization on the network, and the dynamic fee algorithm adjusts the base fee accordingly. If the network operates above the target utilization, the dynamic fee algorithm will increase the base fee to make utilizing he network more expensive and bring overall utilization down. If the network operates below the target utilization, the dynamic fee algorithm will decrease the base fee to make it cheaper to use the network.
The dynamic fee algorithm aims to adjust the base fee to handle network congestion. Subnet-EVM sets a target utilization on the network, and the dynamic fee algorithm adjusts the base fee accordingly. If the network operates above the target utilization, the dynamic fee algorithm will increase the base fee to make utilizing the network more expensive and bring overall utilization down. If the network operates below the target utilization, the dynamic fee algorithm will decrease the base fee to make it cheaper to use the network.

- EIP-1559 is intended for Ethereum where a block is produced roughly every 10s
- The dynamic fee algorithm needs to handle the case that the network quiesces and there are no blocks for a long period of time
Expand Down
865 changes: 479 additions & 386 deletions contracts/package-lock.json

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@avalabs/subnet-evm-contracts",
"devDependencies": {
"@types/chai": "^4.3.5",
"@types/mocha": "^9.0.0",
"chai": "^4.3.7",
"prettier": "^2.5.1",
"prettier-plugin-solidity": "^1.1.3"
"@types/chai": "^4.3.11",
"@types/mocha": "^9.1.1",
"chai": "^4.4.1",
"prettier": "^3.2.4",
"prettier-plugin-solidity": "^1.3.1"
},
"version": "1.1.0",
"version": "1.2.0",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -30,13 +30,13 @@
"dependencies": {
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@nomiclabs/hardhat-waffle": "^2.0.6",
"@types/node": "^16.7.1",
"@types/node": "^16.11.7",
"@avalabs/avalanchejs": "^3.17.0",
"ethers": "^5.4.5",
"hardhat": "2.17.1",
"ts-node": "^10.9.1",
"typescript": "^5.1.6",
"@openzeppelin/contracts": "^4.9.3",
"ethers": "^5.7.2",
"hardhat": "2.19.4",
"ts-node": "^10.9.2",
"typescript": "^5.3.3",
"@openzeppelin/contracts": "^4.9.5",
"ds-test": "https://github.com/dapphub/ds-test.git"
},
"engines": {
Expand Down
22 changes: 1 addition & 21 deletions core/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
"testing"

"github.com/ava-labs/subnet-evm/consensus/dummy"
"github.com/ava-labs/subnet-evm/constants"
"github.com/ava-labs/subnet-evm/core/rawdb"
"github.com/ava-labs/subnet-evm/core/types"
"github.com/ava-labs/subnet-evm/core/vm"
Expand All @@ -46,39 +45,31 @@ import (
func BenchmarkInsertChain_empty_memdb(b *testing.B) {
benchInsertChain(b, false, nil)
}

func BenchmarkInsertChain_empty_diskdb(b *testing.B) {
benchInsertChain(b, true, nil)
}

func BenchmarkInsertChain_valueTx_memdb(b *testing.B) {
benchInsertChain(b, false, genValueTx(0))
}

func BenchmarkInsertChain_valueTx_diskdb(b *testing.B) {
benchInsertChain(b, true, genValueTx(0))
}

func BenchmarkInsertChain_valueTx_100kB_memdb(b *testing.B) {
benchInsertChain(b, false, genValueTx(100*1024))
}

func BenchmarkInsertChain_valueTx_100kB_diskdb(b *testing.B) {
benchInsertChain(b, true, genValueTx(100*1024))
}

func BenchmarkInsertChain_ring200_memdb(b *testing.B) {
benchInsertChain(b, false, genTxRing(200))
}

func BenchmarkInsertChain_ring200_diskdb(b *testing.B) {
benchInsertChain(b, true, genTxRing(200))
}

func BenchmarkInsertChain_ring1000_memdb(b *testing.B) {
benchInsertChain(b, false, genTxRing(1000))
}

func BenchmarkInsertChain_ring1000_diskdb(b *testing.B) {
benchInsertChain(b, true, genTxRing(1000))
}
Expand Down Expand Up @@ -187,47 +178,36 @@ func benchInsertChain(b *testing.B, disk bool, gen func(int, *BlockGen)) {
func BenchmarkChainRead_header_10k(b *testing.B) {
benchReadChain(b, false, 10000)
}

func BenchmarkChainRead_full_10k(b *testing.B) {
benchReadChain(b, true, 10000)
}

func BenchmarkChainRead_header_100k(b *testing.B) {
benchReadChain(b, false, 100000)
}

func BenchmarkChainRead_full_100k(b *testing.B) {
benchReadChain(b, true, 100000)
}

func BenchmarkChainRead_header_500k(b *testing.B) {
benchReadChain(b, false, 500000)
}

func BenchmarkChainRead_full_500k(b *testing.B) {
benchReadChain(b, true, 500000)
}

func BenchmarkChainWrite_header_10k(b *testing.B) {
benchWriteChain(b, false, 10000)
}

func BenchmarkChainWrite_full_10k(b *testing.B) {
benchWriteChain(b, true, 10000)
}

func BenchmarkChainWrite_header_100k(b *testing.B) {
benchWriteChain(b, false, 100000)
}

func BenchmarkChainWrite_full_100k(b *testing.B) {
benchWriteChain(b, true, 100000)
}

func BenchmarkChainWrite_header_500k(b *testing.B) {
benchWriteChain(b, false, 500000)
}

func BenchmarkChainWrite_full_500k(b *testing.B) {
benchWriteChain(b, true, 500000)
}
Expand All @@ -238,7 +218,7 @@ func makeChainForBench(db ethdb.Database, full bool, count uint64) {
var hash common.Hash
for n := uint64(0); n < count; n++ {
header := &types.Header{
Coinbase: constants.BlackholeAddr,
Coinbase: common.Address{},
Number: big.NewInt(int64(n)),
ParentHash: hash,
Difficulty: big.NewInt(1),
Expand Down
4 changes: 1 addition & 3 deletions core/fifo_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package core

import (
"sync"
)
import "sync"

var (
_ FIFOCache[int, int] = (*BufferFIFOCache[int, int])(nil)
Expand Down
1 change: 0 additions & 1 deletion core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ func SetupGenesisBlock(
if genesis.Config == nil {
return nil, common.Hash{}, errGenesisNoConfig
}

// Just commit the new block if there is no stored genesis block.
stored := rawdb.ReadCanonicalHash(db, 0)
if (stored == common.Hash{}) {
Expand Down
2 changes: 1 addition & 1 deletion core/rawdb/chain_iterator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestChainIterator(t *testing.T) {
WriteCanonicalHash(chainDb, block.Hash(), block.NumberU64())
}

cases := []struct {
var cases = []struct {
from, to uint64
reverse bool
expect []int
Expand Down
2 changes: 1 addition & 1 deletion core/state/pruner/pruner.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ const warningLog = `
WARNING!
The clean trie cache is not found. Please delete it by yourself after the
The clean trie cache is not found. Please delete it by yourself after the
pruning. Remember don't start the Subnet-EVM without deleting the clean trie cache
otherwise the entire database may be damaged!
Expand Down
1 change: 1 addition & 0 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
if err := st.preCheck(); err != nil {
return nil, err
}

if tracer := st.evm.Config.Tracer; tracer != nil {
tracer.CaptureTxStart(st.initialGas)
defer func() {
Expand Down
6 changes: 3 additions & 3 deletions core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte,
if !evm.Context.CanTransfer(evm.StateDB, caller.Address(), value) {
return nil, gas, vmerrs.ErrInsufficientBalance
}
snapshot := evm.StateDB.Snapshot()
var snapshot = evm.StateDB.Snapshot()

// Invoke tracer hooks that signal entering/exiting a call frame
if evm.Config.Tracer != nil {
Expand Down Expand Up @@ -394,7 +394,7 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by
if evm.depth > int(params.CallCreateDepth) {
return nil, gas, vmerrs.ErrDepth
}
snapshot := evm.StateDB.Snapshot()
var snapshot = evm.StateDB.Snapshot()

// Invoke tracer hooks that signal entering/exiting a call frame
if evm.Config.Tracer != nil {
Expand Down Expand Up @@ -442,7 +442,7 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte
// after all empty accounts were deleted, so this is not required. However, if we omit this,
// then certain tests start failing; stRevertTest/RevertPrecompiledTouchExactOOG.json.
// We could change this, but for now it's left for legacy reasons
snapshot := evm.StateDB.Snapshot()
var snapshot = evm.StateDB.Snapshot()

// We do an AddBalance of zero here, just in order to trigger a touch.
// This doesn't matter on Mainnet, where all empties are gone at the time of Byzantium,
Expand Down
1 change: 1 addition & 0 deletions core/vm/evm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func TestIsProhibited(t *testing.T) {

// allowed for use
assert.False(t, IsProhibited(common.HexToAddress("0x00000000000000000000000000000000000000ff")))
assert.False(t, IsProhibited(common.HexToAddress("0x00ffffffffffffffffffffffffffffffffffffff")))
assert.False(t, IsProhibited(common.HexToAddress("0x0100000000000000000000000000000000000100")))
assert.False(t, IsProhibited(common.HexToAddress("0x0200000000000000000000000000000000000100")))
assert.False(t, IsProhibited(common.HexToAddress("0x0300000000000000000000000000000000000100")))
Expand Down
4 changes: 2 additions & 2 deletions core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,6 @@ func opCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byt
// Get the arguments from the memory.
args := scope.Memory.GetPtr(int64(inOffset.Uint64()), int64(inSize.Uint64()))

// Note: this code fails to check that value2 is zero, which was a bug when CALLEX was active.
// The CALLEX opcode was de-activated in ApricotPhase2 resolving this issue.
if interpreter.readOnly && !value.IsZero() {
return nil, vmerrs.ErrWriteProtection
}
Expand Down Expand Up @@ -855,6 +853,8 @@ func makeLog(size int) executionFunc {
scope.Contract.Address(),
topics,
d,
// This is a non-consensus field, but assigned here because
// core/state doesn't know the current block number.
interpreter.evm.Context.BlockNumber.Uint64(),
)

Expand Down
1 change: 0 additions & 1 deletion core/vm/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ type StateDB interface {

Suicide(common.Address) bool
HasSuicided(common.Address) bool
Finalise(deleteEmptyObjects bool)

// Exist reports whether the given account exists in state.
// Notably this should also return true for suicided accounts.
Expand Down
7 changes: 0 additions & 7 deletions core/vm/opcodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,6 @@ const (
TSTORE OpCode = 0xb4
)

// unofficial opcodes used for parsing.
const (
PUSH OpCode = 0xb0 + iota
DUP
SWAP
)

// 0xf0 range - closures.
const (
CREATE OpCode = 0xf0
Expand Down
4 changes: 1 addition & 3 deletions eth/gasprice/gasprice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,7 @@ func TestSuggestTipCapSmallTips(t *testing.T) {
Data: []byte{},
})
tx, err = types.SignTx(tx, signer, key)
if err != nil {
t.Fatalf("failed to create tx: %s", err)
}
require.NoError(t, err, "failed to create tx")
b.AddTx(tx)
}
},
Expand Down
1 change: 1 addition & 0 deletions eth/state_accessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ var noopReleaser = tracers.StateReleaseFunc(func() {})
// provided, it would be preferable to start from a fresh state, if we have it
// on disk.
func (eth *Ethereum) StateAtBlock(ctx context.Context, block *types.Block, reexec uint64, base *state.StateDB, readOnly bool, preferDisk bool) (statedb *state.StateDB, release tracers.StateReleaseFunc, err error) {
reexec = 0 // Do not support re-executing historical blocks to grab state
var (
current *types.Block
database state.Database
Expand Down
Loading

0 comments on commit d013ac5

Please sign in to comment.