Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cortina 5: Ava-labs/core-eth v0.12.4-rc4 (avalanchego 1.10.5) #85

Merged
merged 11 commits into from
Feb 22, 2024
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
strategy:
matrix:
go: ['1.19']
os: [macos-11.0, ubuntu-20.04]
os: [macos-11.0, ubuntu-20.04, windows-latest]
steps:
- name: check out
if: ${{ github.event_name != 'workflow_dispatch' }}
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ============= Compilation Stage ================
FROM golang:1.18.5-buster AS builder
FROM golang:1.19.10-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

Expand Down
6 changes: 3 additions & 3 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ func NewSimulatedBackendWithChainConfig(alloc core.GenesisAlloc, gasLimit uint64
// 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, addr common.Address) *SimulatedBackend {
cpcfg := params.TestChainConfig
cpcfg.ChainID = big.NewInt(1337)
copyConfig := *params.TestChainConfig
copyConfig.ChainID = big.NewInt(1337)
genesis := core.Genesis{
Config: cpcfg,
Config: &copyConfig,
GasLimit: gasLimit,
Alloc: alloc,
InitialAdmin: addr,
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.TestChainConfig {
t.Errorf("expected sim config to equal params.AllEthashProtocolChanges, got %v", sim.config)
}

if sim.blockchain.Config() != params.TestChainConfig {
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
18 changes: 9 additions & 9 deletions accounts/abi/bind/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ var (
if err != nil {
return *outstruct, err
}
{{range $i, $t := .Normalized.Outputs}}
{{range $i, $t := .Normalized.Outputs}}
outstruct.{{.Name}} = *abi.ConvertType(out[{{$i}}], new({{bindtype .Type $structs}})).(*{{bindtype .Type $structs}}){{end}}

return *outstruct, err
Expand All @@ -345,7 +345,7 @@ var (
}
{{range $i, $t := .Normalized.Outputs}}
out{{$i}} := *abi.ConvertType(out[{{$i}}], new({{bindtype .Type $structs}})).(*{{bindtype .Type $structs}}){{end}}

return {{range $i, $t := .Normalized.Outputs}}out{{$i}}, {{end}} err
{{end}}
}
Expand Down Expand Up @@ -388,7 +388,7 @@ var (
}
{{end}}

{{if .Fallback}}
{{if .Fallback}}
// Fallback is a paid mutator transaction binding the contract fallback function.
//
// Solidity: {{.Fallback.Original.String}}
Expand All @@ -402,16 +402,16 @@ var (
func (_{{$contract.Type}} *{{$contract.Type}}Session) Fallback(calldata []byte) (*types.Transaction, error) {
return _{{$contract.Type}}.Contract.Fallback(&_{{$contract.Type}}.TransactOpts, calldata)
}

// Fallback is a paid mutator transaction binding the contract fallback function.
//
//
// Solidity: {{.Fallback.Original.String}}
func (_{{$contract.Type}} *{{$contract.Type}}TransactorSession) Fallback(calldata []byte) (*types.Transaction, error) {
return _{{$contract.Type}}.Contract.Fallback(&_{{$contract.Type}}.TransactOpts, calldata)
}
{{end}}

{{if .Receive}}
{{if .Receive}}
// Receive is a paid mutator transaction binding the contract receive function.
//
// Solidity: {{.Receive.Original.String}}
Expand All @@ -425,9 +425,9 @@ var (
func (_{{$contract.Type}} *{{$contract.Type}}Session) Receive() (*types.Transaction, error) {
return _{{$contract.Type}}.Contract.Receive(&_{{$contract.Type}}.TransactOpts)
}

// Receive is a paid mutator transaction binding the contract receive function.
//
//
// Solidity: {{.Receive.Original.String}}
func (_{{$contract.Type}} *{{$contract.Type}}TransactorSession) Receive() (*types.Transaction, error) {
return _{{$contract.Type}}.Contract.Receive(&_{{$contract.Type}}.TransactOpts)
Expand Down Expand Up @@ -576,6 +576,6 @@ var (
return event, nil
}

{{end}}
{{end}}
{{end}}
`
2 changes: 1 addition & 1 deletion accounts/abi/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type Error struct {
str string

// Sig contains the string signature according to the ABI spec.
// e.g. error foo(uint32 a, int b) = "foo(uint32,int256)"
// e.g. error foo(uint32 a, int b) = "foo(uint32,int256)"
// Please note that "int" is substitute for its canonical representation "int256"
Sig string

Expand Down
32 changes: 17 additions & 15 deletions core/blockchain_log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@ import (
"github.com/stretchr/testify/require"
)

/*
Example contract to test event emission:

pragma solidity >=0.7.0 <0.9.0;
contract Callable {
event Called();
function Call() public { emit Called(); }
}
*/
const callableAbi = "[{\"anonymous\":false,\"inputs\":[],\"name\":\"Called\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"Call\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"

const callableBin = "6080604052348015600f57600080fd5b5060998061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c806334e2292114602d575b600080fd5b60336035565b005b7f81fab7a4a0aa961db47eefc81f143a5220e8c8495260dd65b1356f1d19d3c7b860405160405180910390a156fea2646970667358221220029436d24f3ac598ceca41d4d712e13ced6d70727f4cdc580667de66d2f51d8b64736f6c63430008010033"

func TestEmitLogsCorrectness(t *testing.T) {
func TestAcceptedLogsSubscription(t *testing.T) {
/*
Example contract to test event emission:

pragma solidity >=0.7.0 <0.9.0;
contract Callable {
event Called();
function Call() public { emit Called(); }
}
*/

const (
callableABI = "[{\"anonymous\":false,\"inputs\":[],\"name\":\"Called\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"Call\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"
callableBin = "6080604052348015600f57600080fd5b5060998061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c806334e2292114602d575b600080fd5b60336035565b005b7f81fab7a4a0aa961db47eefc81f143a5220e8c8495260dd65b1356f1d19d3c7b860405160405180910390a156fea2646970667358221220029436d24f3ac598ceca41d4d712e13ced6d70727f4cdc580667de66d2f51d8b64736f6c63430008010033"
)
var (
require = require.New(t)
engine = dummy.NewFaker()
Expand All @@ -48,7 +49,7 @@ func TestEmitLogsCorrectness(t *testing.T) {
signer = types.LatestSigner(gspec.Config)
)

parsed, err := abi.JSON(strings.NewReader(callableAbi))
parsed, err := abi.JSON(strings.NewReader(callableABI))
require.NoError(err)

packedFunction, err := parsed.Pack("Call")
Expand All @@ -74,6 +75,7 @@ func TestEmitLogsCorrectness(t *testing.T) {

chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), DefaultCacheConfig, gspec, engine, vm.Config{}, common.Hash{}, false)
require.NoError(err)
defer chain.Stop()

// Create Log Subscriber
logsCh := make(chan []*types.Log, 10)
Expand Down
1 change: 1 addition & 0 deletions core/blockchain_repair_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ func testRepair(t *testing.T, tt *rewindTest, snapshots bool) {
if err != nil {
t.Fatalf("Failed to create chain: %v", err)
}
defer chain.Stop()
lastAcceptedHash := chain.GetBlockByNumber(0).Hash()

// If sidechain blocks are needed, make a light chain and import it
Expand Down
12 changes: 9 additions & 3 deletions core/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,14 @@ func TestBlockChainOfflinePruningUngracefulShutdown(t *testing.T) {
return blockchain, nil
}

tempDir := t.TempDir()
if err := blockchain.CleanBlockRootsAboveLastAccepted(); err != nil {
return nil, err
}
// get the target root to prune to before stopping the blockchain
targetRoot := blockchain.LastAcceptedBlock().Root()
blockchain.Stop()

tempDir := t.TempDir()
prunerConfig := pruner.Config{
Datadir: tempDir,
BloomSize: 256,
Expand All @@ -371,16 +374,15 @@ func TestBlockChainOfflinePruningUngracefulShutdown(t *testing.T) {
return nil, fmt.Errorf("offline pruning failed (%s, %d): %w", tempDir, 256, err)
}

targetRoot := blockchain.LastAcceptedBlock().Root()
if err := pruner.Prune(targetRoot); err != nil {
return nil, fmt.Errorf("failed to prune blockchain with target root: %s due to: %w", targetRoot, err)
}
// Re-initialize the blockchain after pruning
return createBlockChain(db, pruningConfig, gspec, lastAcceptedHash)
}
for _, tt := range tests {
tt := tt
t.Run(tt.Name, func(t *testing.T) {
tt := tt
t.Parallel()
tt.testFunc(t, create)
})
Expand Down Expand Up @@ -465,6 +467,7 @@ func testRepopulateMissingTriesParallel(t *testing.T, parallelism int) {
if err != nil {
t.Fatal(err)
}
defer blockchain.Stop()

for _, block := range chain {
if !blockchain.HasState(block.Root()) {
Expand Down Expand Up @@ -951,6 +954,7 @@ func testCreateThenDelete(t *testing.T, config *params.ChainConfig) {
if err != nil {
t.Fatalf("failed to create tester chain: %v", err)
}
defer chain.Stop()
// Import the blocks
for _, block := range blocks {
if _, err := chain.InsertChain([]*types.Block{block}); err != nil {
Expand Down Expand Up @@ -1037,6 +1041,7 @@ func TestTransientStorageReset(t *testing.T) {
if err != nil {
t.Fatalf("failed to create tester chain: %v", err)
}
defer chain.Stop()
// Import the blocks
if _, err := chain.InsertChain(blocks); err != nil {
t.Fatalf("failed to insert into chain: %v", err)
Expand Down Expand Up @@ -1125,6 +1130,7 @@ func TestEIP3651(t *testing.T) {
if err != nil {
t.Fatalf("failed to create tester chain: %v", err)
}
defer chain.Stop()
if n, err := chain.InsertChain(blocks); err != nil {
t.Fatalf("block %d: failed to insert into chain: %v", n, err)
}
Expand Down
2 changes: 2 additions & 0 deletions core/headerchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ 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.NewFaker(), db, 128, 10, func(i int, b *BlockGen) {
b.SetCoinbase(common.Address{0: byte(10), 19: byte(i)})
Expand Down
22 changes: 22 additions & 0 deletions core/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// (c) 2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package core

import (
"testing"

"go.uber.org/goleak"
)

// TestMain uses goleak to verify tests in this package do not leak unexpected
// goroutines.
func TestMain(m *testing.M) {
opts := []goleak.Option{
// No good way to shut down these goroutines:
goleak.IgnoreTopFunction("github.com/ava-labs/coreth/core/state/snapshot.(*diskLayer).generate"),
goleak.IgnoreTopFunction("github.com/ava-labs/coreth/metrics.(*meterArbiter).tick"),
goleak.IgnoreTopFunction("github.com/syndtr/goleveldb/leveldb.(*DB).mpoolDrain"),
}
goleak.VerifyTestMain(m, opts...)
}
1 change: 0 additions & 1 deletion core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ func TestStateProcessorErrors(t *testing.T) {
}{
{ // ErrMaxInitCodeSizeExceeded
txs: []*types.Transaction{

mkDynamicCreationTx(0, 500000, common.Big0, big.NewInt(params.ApricotPhase3InitialBaseFee), tooBigInitCode[:]),
},
want: "could not apply tx 0 [0x18a05f40f29ff16d5287f6f88b21c9f3c7fbc268f707251144996294552c4cd6]: max initcode size exceeded: code size 49153 limit 49152",
Expand Down
1 change: 1 addition & 0 deletions core/test_blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ func checkBlockChainState(
if err != nil {
t.Fatalf("Failed to create new blockchain instance: %s", err)
}
defer newBlockChain.Stop()

for i := uint64(1); i <= lastAcceptedBlock.NumberU64(); i++ {
block := bc.GetBlockByNumber(i)
Expand Down
3 changes: 2 additions & 1 deletion core/txpool/txpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ func (bc *testBlockChain) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent)
}

func (bc *testBlockChain) SenderCacher() *core.TxSenderCacher {
return core.NewTxSenderCacher(1)
// Zero threads avoids starting goroutines.
return core.NewTxSenderCacher(0)
}

func (bc *testBlockChain) AdminController() admin.AdminController {
Expand Down
38 changes: 19 additions & 19 deletions core/vm/runtime/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,30 +708,30 @@ func TestColdAccountAccessCost(t *testing.T) {
func TestRuntimeJSTracer(t *testing.T) {
jsTracers := []string{
`{enters: 0, exits: 0, enterGas: 0, gasUsed: 0, steps:0,
step: function() { this.steps++},
fault: function() {},
result: function() {
return [this.enters, this.exits,this.enterGas,this.gasUsed, this.steps].join(",")
},
enter: function(frame) {
this.enters++;
step: function() { this.steps++},
fault: function() {},
result: function() {
return [this.enters, this.exits,this.enterGas,this.gasUsed, this.steps].join(",")
},
enter: function(frame) {
this.enters++;
this.enterGas = frame.getGas();
},
exit: function(res) {
this.exits++;
},
exit: function(res) {
this.exits++;
this.gasUsed = res.getGasUsed();
}}`,
`{enters: 0, exits: 0, enterGas: 0, gasUsed: 0, steps:0,
fault: function() {},
result: function() {
return [this.enters, this.exits,this.enterGas,this.gasUsed, this.steps].join(",")
},
enter: function(frame) {
this.enters++;
fault: function() {},
result: function() {
return [this.enters, this.exits,this.enterGas,this.gasUsed, this.steps].join(",")
},
enter: function(frame) {
this.enters++;
this.enterGas = frame.getGas();
},
exit: function(res) {
this.exits++;
},
exit: function(res) {
this.exits++;
this.gasUsed = res.getGasUsed();
}}`}
tests := []struct {
Expand Down
Loading
Loading