Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
shell: bash
- uses: actions/setup-go@v3
with:
go-version: "1.20"
go-version: "1.19"
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
Expand All @@ -33,7 +33,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: "1.20"
go-version: "1.19"
- run: go mod download
shell: bash
- run: ./scripts/build.sh ./build/subnetevm
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.20"
go-version: "1.19"
- name: Use Node.js
uses: actions/setup-node@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ARG AVALANCHE_VERSION

# ============= Compilation Stage ================
FROM golang:1.20.1-buster AS builder
FROM golang:1.19.6-buster AS builder
RUN apt-get update && apt-get install -y --no-install-recommends bash=5.0-4 make=4.2.1-1.2 gcc=4:8.3.0-1 musl-dev=1.1.21-2 ca-certificates=20200601~deb10u2 linux-headers-amd64

WORKDIR /build
Expand Down
9 changes: 4 additions & 5 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,11 @@ type SimulatedBackend struct {
// and uses a simulated blockchain for testing purposes.
// A simulated backend always uses chainID 1337.
func NewSimulatedBackendWithDatabase(database ethdb.Database, alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBackend {
cpcfg := params.SimulatedTestChainConfig
if cpcfg.FeeConfig.GasLimit.Uint64() != gasLimit {
cpcfg.FeeConfig.GasLimit = big.NewInt(int64(gasLimit))
}
copyConfig := *params.TestChainConfig
copyConfig.ChainID = big.NewInt(1337)
copyConfig.FeeConfig.GasLimit = big.NewInt(int64(gasLimit))
genesis := core.Genesis{
Config: params.SimulatedTestChainConfig,
Config: &copyConfig,
GasLimit: gasLimit,
Alloc: alloc,
}
Expand Down
8 changes: 0 additions & 8 deletions accounts/abi/bind/backends/simulated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,6 @@ func TestNewSimulatedBackend(t *testing.T) {
sim := simTestBackend(testAddr)
defer sim.Close()

if sim.config != params.SimulatedTestChainConfig {
t.Errorf("expected sim config to equal params.AllEthashProtocolChanges, got %v", sim.config)
}

if sim.blockchain.Config() != params.SimulatedTestChainConfig {
t.Errorf("expected sim blockchain config to equal params.AllEthashProtocolChanges, got %v", sim.config)
}

stateDB, _ := sim.blockchain.State()
bal := stateDB.GetBalance(testAddr)
if bal.Cmp(expectedBal) != 0 {
Expand Down
1 change: 1 addition & 0 deletions accounts/keystore/account_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ var (
}
)

// waitWatcherStart waits up to 1s for the keystore watcher to start.
func waitWatcherStart(ks *KeyStore) bool {
// On systems where file watch is not supported, just return "ok".
if !ks.cache.watcher.enabled() {
Expand Down
4 changes: 1 addition & 3 deletions core/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/crypto"
"github.com/stretchr/testify/require"
)

func BenchmarkInsertChain_empty_memdb(b *testing.B) {
Expand Down Expand Up @@ -175,8 +174,7 @@ func benchInsertChain(b *testing.B, disk bool, gen func(int, *BlockGen)) {

// Time the insertion of the new chain.
// State and blocks are stored in the same DB.
chainman, err := NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewCoinbaseFaker(), vm.Config{}, common.Hash{}, false)
require.NoError(b, err)
chainman, _ := NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewCoinbaseFaker(), vm.Config{}, common.Hash{}, false)
defer chainman.Stop()
b.ReportAllocs()
b.ResetTimer()
Expand Down
1 change: 0 additions & 1 deletion core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ func NewBlockChain(
if cacheConfig == nil {
return nil, errCacheConfigNotSpecified
}

// Open trie database with provided config
triedb := trie.NewDatabaseWithConfig(db, &trie.Config{
Cache: cacheConfig.TrieCleanLimit,
Expand Down
14 changes: 6 additions & 8 deletions core/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,8 @@ func TestTrieCleanJournal(t *testing.T) {
// Ensure that key1 has some funds in the genesis block.
genesisBalance := big.NewInt(1000000)
gspec := &Genesis{
Config: &params.ChainConfig{HomesteadBlock: new(big.Int), FeeConfig: params.DefaultFeeConfig},
Alloc: GenesisAlloc{addr1: {Balance: genesisBalance}},
GasLimit: params.DefaultFeeConfig.GasLimit.Uint64(),
Config: &params.ChainConfig{HomesteadBlock: new(big.Int)},
Alloc: GenesisAlloc{addr1: {Balance: genesisBalance}},
}

blockchain, err := create(chainDB, gspec, common.Hash{})
Expand Down Expand Up @@ -639,9 +638,8 @@ func TestTransactionIndices(t *testing.T) {
addr2 = crypto.PubkeyToAddress(key2.PublicKey)
funds = big.NewInt(10000000000000)
gspec = &Genesis{
Config: &params.ChainConfig{HomesteadBlock: new(big.Int), FeeConfig: params.DefaultFeeConfig},
Alloc: GenesisAlloc{addr1: {Balance: funds}},
GasLimit: params.DefaultFeeConfig.GasLimit.Uint64(),
Config: &params.ChainConfig{HomesteadBlock: new(big.Int)},
Alloc: GenesisAlloc{addr1: {Balance: funds}},
}
signer = types.LatestSigner(gspec.Config)
)
Expand Down Expand Up @@ -1077,8 +1075,7 @@ func TestEIP3651(t *testing.T) {
addr2 = crypto.PubkeyToAddress(key2.PublicKey)
funds = new(big.Int).Mul(common.Big1, big.NewInt(params.Ether))
gspec = &Genesis{
Config: params.TestChainConfig,
GasLimit: params.TestChainConfig.FeeConfig.GasLimit.Uint64(),
Config: params.TestChainConfig,
Alloc: GenesisAlloc{
addr1: {Balance: funds},
addr2: {Balance: funds},
Expand Down Expand Up @@ -1110,6 +1107,7 @@ func TestEIP3651(t *testing.T) {
Balance: big.NewInt(0),
},
},
GasLimit: params.TestChainConfig.FeeConfig.GasLimit.Uint64(),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep the consistent order, Config, Alloc, GasLimit

}
)

Expand Down
6 changes: 1 addition & 5 deletions core/chain_makers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,7 @@ func ExampleGenerateChain() {
}

// Import the chain. This runs all block validation rules.
blockchain, err := NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewCoinbaseFaker(), vm.Config{}, common.Hash{}, false)
if err != nil {
fmt.Printf("could not create blockchain: %v\n", err)
return
}
blockchain, _ := NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewCoinbaseFaker(), vm.Config{}, common.Hash{}, false)
defer blockchain.Stop()

if i, err := blockchain.InsertChain(chain); err != nil {
Expand Down
8 changes: 7 additions & 1 deletion core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ func SetupGenesisBlock(
if genesis.Config.IsSubnetEVM(genesis.Timestamp) {
gasLimitConfig := genesis.Config.FeeConfig.GasLimit.Uint64()
if gasLimitConfig != genesis.GasLimit {
return nil, common.Hash{}, fmt.Errorf("gas limit in fee config (%d) does not match gas limit in header (%d)", gasLimitConfig, genesis.GasLimit)
return nil, common.Hash{}, fmt.Errorf(
"gas limit in fee config (%d) does not match gas limit in header (%d)",
gasLimitConfig,
genesis.GasLimit,
)
}
// Verify config
if err := genesis.Config.Verify(); err != nil {
Expand Down Expand Up @@ -227,7 +231,9 @@ func SetupGenesisBlock(
return newcfg, common.Hash{}, err
}
storedcfg := rawdb.ReadChainConfig(db, stored)
// If there is no previously stored chain config, write the chain config to disk.
if storedcfg == nil {
// Note: this can happen since we did not previously write the genesis block and chain config in the same batch.
log.Warn("Found genesis block without chain config")
rawdb.WriteChainConfig(db, stored, newcfg)
return newcfg, stored, nil
Expand Down
29 changes: 13 additions & 16 deletions core/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ func TestSetupGenesis(t *testing.T) {
// Advance to block #4, past the SubnetEVM transition block of customg.
genesis := oldcustomg.MustCommit(db)

bc, err := NewBlockChain(db, DefaultCacheConfig, &oldcustomg, dummy.NewFullFaker(), vm.Config{}, genesis.Hash(), false)
require.NoError(t, err)
bc, _ := NewBlockChain(db, DefaultCacheConfig, &oldcustomg, dummy.NewFullFaker(), vm.Config{}, genesis.Hash(), false)
defer bc.Stop()

blocks, _, _ := GenerateChain(oldcustomg.Config, genesis, dummy.NewFullFaker(), db, 4, 25, nil)
Expand Down Expand Up @@ -238,23 +237,21 @@ func TestStatefulPrecompilesConfigure(t *testing.T) {
// regression test for precompile activation after header block
func TestPrecompileActivationAfterHeaderBlock(t *testing.T) {
db := rawdb.NewMemoryDatabase()
copyCfg := *params.TestChainConfig
customg := Genesis{
Config: &copyCfg,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this copy seems unnecessary

Config: params.TestChainConfig,
Alloc: GenesisAlloc{
{1}: {Balance: big.NewInt(1), Storage: map[common.Hash]common.Hash{{1}: {1}}},
},
GasLimit: params.TestChainConfig.FeeConfig.GasLimit.Uint64(),
}
bc, err := NewBlockChain(db, DefaultCacheConfig, &customg, dummy.NewFullFaker(), vm.Config{}, common.Hash{}, false)
require.NoError(t, err)
bc, _ := NewBlockChain(db, DefaultCacheConfig, &customg, dummy.NewFullFaker(), vm.Config{}, common.Hash{}, false)
defer bc.Stop()

// Advance header to block #4, past the ContractDeployerAllowListConfig.
_, blocks, _, _ := GenerateChainWithGenesis(&customg, dummy.NewFullFaker(), 4, 25, nil)

require := require.New(t)
_, err = bc.InsertChain(blocks)
_, err := bc.InsertChain(blocks)
require.NoError(err)

// accept up to block #2
Expand All @@ -267,24 +264,24 @@ func TestPrecompileActivationAfterHeaderBlock(t *testing.T) {
// header must be bigger than last accepted
require.Greater(block.Time, bc.lastAccepted.Time())

activatedGenesis := customg
contractDeployerTimestamp := utils.NewUint64(51)
contractDeployerConfig := deployerallowlist.NewConfig(contractDeployerTimestamp, nil, nil)
activatedGenesis.Config.UpgradeConfig.PrecompileUpgrades = []params.PrecompileUpgrade{
activatedGenesisConfig := *customg.Config
contractDeployerConfig := deployerallowlist.NewConfig(utils.NewUint64(51), nil, nil)
activatedGenesisConfig.UpgradeConfig.PrecompileUpgrades = []params.PrecompileUpgrade{
{
Config: contractDeployerConfig,
},
}
customg.Config = &activatedGenesisConfig

// assert block is after the activation block
require.Greater(block.Time, *contractDeployerTimestamp)
require.Greater(block.Time, *contractDeployerConfig.Timestamp())
// assert last accepted block is before the activation block
require.Less(bc.lastAccepted.Time(), *contractDeployerTimestamp)
require.Less(bc.lastAccepted.Time(), *contractDeployerConfig.Timestamp())

// This should not return any error since the last accepted block is before the activation block.
config, _, err := setupGenesisBlock(db, trie.NewDatabase(db), &activatedGenesis, bc.lastAccepted.Hash())
config, _, err := setupGenesisBlock(db, trie.NewDatabase(db), &customg, bc.lastAccepted.Hash())
require.NoError(err)
if !reflect.DeepEqual(config, activatedGenesis.Config) {
t.Errorf("returned %v\nwant %v", config, activatedGenesis.Config)
if !reflect.DeepEqual(config, customg.Config) {
t.Errorf("returned %v\nwant %v", config, customg.Config)
}
}
1 change: 1 addition & 0 deletions core/headerchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func TestHeaderInsertion(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer chain.Stop()
// chain A: G->A1->A2...A128
chainA, _, _ := GenerateChain(params.TestChainConfig, types.NewBlockWithHeader(genesis.Header()), dummy.NewCoinbaseFaker(), db, 128, 10, func(i int, b *BlockGen) {
b.SetCoinbase(common.Address{0: byte(10), 19: byte(i)})
Expand Down
5 changes: 2 additions & 3 deletions core/rlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ func getBlock(transactions int, uncles int, dataSize int) *types.Block {
address = crypto.PubkeyToAddress(key.PublicKey)
funds = big.NewInt(50000 * 225000000000 * 200)
gspec = &Genesis{
Config: params.TestChainConfig,
Alloc: GenesisAlloc{address: {Balance: funds}},
GasLimit: params.TestChainConfig.FeeConfig.GasLimit.Uint64(),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need this gas limit

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the tests are passing without it I don't know why we should specify it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm seems we never actually run those checks. this still seems wrong to not specify GasLimit. but let's skip this until this starts failing.

Config: params.TestChainConfig,
Alloc: GenesisAlloc{address: {Balance: funds}},
}
)
// We need to generate as many blocks +1 as uncles
Expand Down
7 changes: 3 additions & 4 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,13 @@ type StateDB struct {

// Per-transaction access list
accessList *accessList

// Transient storage
transientStorage transientStorage

// Ordered storage slots to be used in predicate verification as set in the tx access list.
// Only set in PrepareAccessList, and un-modified through execution.
predicateStorageSlots map[common.Address][]byte

// Transient storage
transientStorage transientStorage

// Journal of state modifications. This is the backbone of
// Snapshot and RevertToSnapshot.
journal *journal
Expand Down
4 changes: 1 addition & 3 deletions core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ func TestStateProcessorErrors(t *testing.T) {
gspec = &Genesis{
Config: &params.ChainConfig{
ChainID: big.NewInt(1),
FeeConfig: params.DefaultFeeConfig,
HomesteadBlock: big.NewInt(0),
EIP150Block: big.NewInt(0),
EIP150Hash: common.Hash{},
Expand All @@ -236,7 +235,6 @@ func TestStateProcessorErrors(t *testing.T) {
Nonce: 0,
},
},
GasLimit: params.TestChainConfig.FeeConfig.GasLimit.Uint64(),
}
blockchain, _ = NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewCoinbaseFaker(), vm.Config{}, common.Hash{}, false)
)
Expand Down Expand Up @@ -407,7 +405,7 @@ func TestBadTxAllowListBlock(t *testing.T) {
Nonce: 0,
},
},
GasLimit: params.TestChainConfig.FeeConfig.GasLimit.Uint64(),
GasLimit: config.FeeConfig.GasLimit.Uint64(),
}
blockchain, _ = NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewCoinbaseFaker(), vm.Config{}, common.Hash{}, false)
)
Expand Down
3 changes: 1 addition & 2 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
predicateutils "github.com/ava-labs/subnet-evm/utils/predicate"
"github.com/ava-labs/subnet-evm/vmerrs"
"github.com/ethereum/go-ethereum/common"

cmath "github.com/ethereum/go-ethereum/common/math"
)

Expand Down Expand Up @@ -353,6 +352,7 @@ func (st *StateTransition) preCheck() error {
}
}
}

// Make sure that transaction gasFeeCap is greater than the baseFee (post london)
if st.evm.ChainConfig().IsSubnetEVM(st.evm.Context.Time) {
// Skip the checks if gas fields are zero and baseFee was explicitly disabled (eth_call)
Expand Down Expand Up @@ -406,7 +406,6 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
if err := st.preCheck(); err != nil {
return nil, err
}

if st.evm.Config.Debug {
st.evm.Config.Tracer.CaptureTxStart(st.initialGas)
defer func() {
Expand Down
Loading