Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.

Commit b64caa6

Browse files
Darioush Jalaliceyonurrichardpringlecuiweiyuanqdm12
authored
merge master into libevm branch (#739)
Co-authored-by: Ceyhun Onur <[email protected]> Co-authored-by: Richard Pringle <[email protected]> Co-authored-by: cuiweiyuan <[email protected]> Co-authored-by: Quentin McGaw <[email protected]> Co-authored-by: Arran Schlosberg <[email protected]>
1 parent a7f7061 commit b64caa6

File tree

115 files changed

+3713
-3510
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+3713
-3510
lines changed

.github/CONTRIBUTING.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,36 @@ Please make sure your contributions adhere to our coding guidelines:
3333
Before you submit a feature request, please check and make sure that it isn't
3434
possible through some other means.
3535

36+
## Mocks
37+
38+
Mocks are auto-generated using [mockgen](https://pkg.go.dev/go.uber.org/mock/mockgen) and `//go:generate` commands in the code.
39+
40+
* To **re-generate all mocks**, use the command below from the root of the project:
41+
42+
```sh
43+
go generate -run "go.uber.org/mock/mockgen" ./...
44+
```
45+
46+
* To **add** an interface that needs a corresponding mock generated:
47+
* if the file `mocks_generate_test.go` exists in the package where the interface is located, either:
48+
* modify its `//go:generate go run go.uber.org/mock/mockgen` to generate a mock for your interface (preferred); or
49+
* add another `//go:generate go run go.uber.org/mock/mockgen` to generate a mock for your interface according to specific mock generation settings
50+
* if the file `mocks_generate_test.go` does not exist in the package where the interface is located, create it with content (adapt as needed):
51+
52+
```go
53+
// Copyright (C) 2025-2025, Ava Labs, Inc. All rights reserved.
54+
// See the file LICENSE for licensing terms.
55+
56+
package mypackage
57+
58+
//go:generate go run go.uber.org/mock/mockgen -package=${GOPACKAGE} -destination=mocks_test.go . YourInterface
59+
```
60+
61+
Notes:
62+
1. Ideally generate all mocks to `mocks_test.go` for the package you need to use the mocks for and do not export mocks to other packages. This reduces package dependencies, reduces production code pollution and forces to have locally defined narrow interfaces.
63+
1. Prefer using reflect mode to generate mocks than source mode, unless you need a mock for an unexported interface, which should be rare.
64+
* To **remove** an interface from having a corresponding mock generated:
65+
1. Edit the `mocks_generate_test.go` file in the directory where the interface is defined
66+
1. If the `//go:generate` mockgen command line:
67+
* generates a mock file for multiple interfaces, remove your interface from the line
68+
* generates a mock file only for the interface, remove the entire line. If the file is empty, remove `mocks_generate_test.go` as well.

.github/pull_request_template.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
## How this works
44

55
## How this was tested
6+
7+
## Need to be documented?
8+
9+
## Need to update RELEASES.md?

.github/workflows/ci.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ jobs:
3232
- uses: actions/setup-go@v5
3333
with:
3434
go-version: "~1.22.8"
35-
check-latest: true
3635
- name: change avalanchego dep
3736
if: ${{ github.event_name == 'workflow_dispatch' }}
3837
run: |
@@ -74,7 +73,6 @@ jobs:
7473
- uses: actions/setup-go@v5
7574
with:
7675
go-version: "~1.22.8"
77-
check-latest: true
7876
- name: change avalanchego dep
7977
if: ${{ github.event_name == 'workflow_dispatch' }}
8078
run: |
@@ -86,6 +84,17 @@ jobs:
8684
run: echo "TIMEOUT=1200s" >> "$GITHUB_ENV"
8785
- run: go mod download
8886
shell: bash
87+
- name: go mod tidy
88+
run: |
89+
go mod tidy
90+
git diff --exit-code
91+
- name: Mocks are up to date
92+
shell: bash
93+
run: |
94+
grep -lr -E '^// Code generated by MockGen\. DO NOT EDIT\.$' . | xargs -r rm
95+
go generate -run "go.uber.org/mock/mockgen" ./...
96+
git add --intent-to-add --all
97+
git diff --exit-code
8998
- run: ./scripts/build.sh evm
9099
shell: bash
91100
- run: ./scripts/build_test.sh
@@ -113,7 +122,6 @@ jobs:
113122
- uses: actions/setup-go@v5
114123
with:
115124
go-version: "~1.22.8"
116-
check-latest: true
117125
- name: Run e2e tests
118126
run: E2E_SERIAL=1 ./scripts/tests.e2e.sh
119127
shell: bash

.github/workflows/sync-subnet-evm-branch.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@ jobs:
1717
- uses: actions/setup-go@v5
1818
with:
1919
go-version: "~1.22.8"
20-
check-latest: true

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[Avalanche](https://docs.avax.network/intro) is a network composed of multiple blockchains.
44
Each blockchain is an instance of a Virtual Machine (VM), much like an object in an object-oriented language is an instance of a class.
55
That is, the VM defines the behavior of the blockchain.
6-
Coreth (from core Ethereum) is the [Virtual Machine (VM)](https://docs.avax.network/learn/avalanche/virtual-machines) that defines the Contract Chain (C-Chain).
6+
Coreth (from core Ethereum) is the [Virtual Machine (VM)](https://docs.avax.network/learn/virtual-machines) that defines the Contract Chain (C-Chain).
77
This chain implements the Ethereum Virtual Machine and supports Solidity smart contracts as well as most other Ethereum client functionality.
88

99
## Building

RELEASES.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Release Notes
22

3+
## [v0.14.1](https://github.com/ava-labs/coreth/releases/tag/v0.14.1)
4+
- Remove API eth_getAssetBalance that was used to query ANT balances (deprecated since v0.10.0)
5+
- Remove legacy gossip handler and metrics (deprecated since v0.10.0)
6+
- Refactored trie_prefetcher.go to be structurally similar to [upstream](https://github.com/ethereum/go-ethereum/tree/v1.13.14).
7+
8+
## [v0.14.0](https://github.com/ava-labs/coreth/releases/tag/v0.14.0)
9+
- Minor version update to correspond to avalanchego v1.12.0 / Etna.
10+
- Remove unused historical opcodes CALLEX, BALANCEMC
11+
- Remove unused pre-AP2 handling of genesis contract
12+
- Fix to track tx size in block building
13+
- Test fixes
14+
- Update go version to 1.22
15+
316
## [v0.13.8](https://github.com/ava-labs/coreth/releases/tag/v0.13.8)
417
- Update geth dependency to v1.13.14
518
- eupgrade: lowering the base fee to 1 nAVAX

accounts/abi/bind/util_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func TestWaitDeployedCornerCases(t *testing.T) {
142142

143143
// Create a transaction that is not mined.
144144
tx = types.NewContractCreation(1, big.NewInt(0), 3000000, gasPrice, common.FromHex(code))
145-
tx, _ = types.SignTx(tx, types.LatestSigner(params.TestChainConfig), testKey)
145+
tx, _ = types.SignTx(tx, types.LatestSignerForChainID(big.NewInt(1337)), testKey)
146146

147147
go func() {
148148
contextCanceled := errors.New("context canceled")
@@ -151,6 +151,8 @@ func TestWaitDeployedCornerCases(t *testing.T) {
151151
}
152152
}()
153153

154-
backend.Client().SendTransaction(ctx, tx)
154+
if err := backend.Client().SendTransaction(ctx, tx); err != nil {
155+
t.Fatalf("Failed to send transaction: %s", err)
156+
}
155157
cancel()
156158
}

consensus/dummy/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The dynamic fee algorithm aims to adjust the base fee to handle network congesti
1818

1919
- EIP-1559 is intended for Ethereum where a block is produced roughly every 10s
2020
- C-Chain typically produces blocks every 2 seconds, but the dynamic fee algorithm needs to handle the case that the network quiesces and there are no blocks for a long period of time
21-
- Since C-Chain produces blocks at a different cadence, it adapts EIP-1559 to sum the amount of gas consumed within a 10 second interval instead of using only the amount of gas consumed in the parent block
21+
- Since C-Chain produces blocks at a different cadence, it adapts EIP-1559 to sum the amount of gas consumed within a 10-second interval instead of using only the amount of gas consumed in the parent block
2222

2323
## Consensus Engine Callbacks
2424

core/blockchain.go

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ func (c *CacheConfig) triedbConfig() *triedb.Config {
179179
config := &triedb.Config{Preimages: c.Preimages}
180180
if c.StateScheme == rawdb.HashScheme || c.StateScheme == "" {
181181
config.DBOverride = hashdb.Config{
182-
CleanCacheSize: c.TrieCleanLimit * 1024 * 1024,
183-
StatsPrefix: trieCleanCacheStatsNamespace,
184-
ReferenceRoot: true, // Automatically reference root nodes when an update is made
182+
CleanCacheSize: c.TrieCleanLimit * 1024 * 1024,
183+
StatsPrefix: trieCleanCacheStatsNamespace,
184+
ReferenceRootAtomicallyOnUpdate: true, // Automatically reference root nodes when an update is made
185185
}.BackendConstructor
186186
}
187187
if c.StateScheme == rawdb.PathScheme {
@@ -1282,16 +1282,6 @@ func (bc *BlockChain) insertBlock(block *types.Block, writes bool) error {
12821282
blockContentValidationTimer.Inc(time.Since(substart).Milliseconds())
12831283

12841284
// No validation errors for the block
1285-
var activeState *state.StateDB
1286-
defer func() {
1287-
// The chain importer is starting and stopping trie prefetchers. If a bad
1288-
// block or other error is hit however, an early return may not properly
1289-
// terminate the background threads. This defer ensures that we clean up
1290-
// and dangling prefetcher, without deferring each and holding on live refs.
1291-
if activeState != nil {
1292-
activeState.StopPrefetcher()
1293-
}
1294-
}()
12951285

12961286
// Retrieve the parent block to determine which root to build state on
12971287
substart = time.Now()
@@ -1310,8 +1300,8 @@ func (bc *BlockChain) insertBlock(block *types.Block, writes bool) error {
13101300
blockStateInitTimer.Inc(time.Since(substart).Milliseconds())
13111301

13121302
// Enable prefetching to pull in trie node paths while processing transactions
1313-
statedb.StartPrefetcher("chain", bc.cacheConfig.TriePrefetcherParallelism)
1314-
activeState = statedb
1303+
statedb.StartPrefetcher("chain", state.WithConcurrentWorkers(bc.cacheConfig.TriePrefetcherParallelism))
1304+
defer statedb.StopPrefetcher()
13151305

13161306
// Process block using the parent state as reference point
13171307
pstart := time.Now()
@@ -1669,10 +1659,8 @@ func (bc *BlockChain) reprocessBlock(parent *types.Block, current *types.Block)
16691659
}
16701660

16711661
// Enable prefetching to pull in trie node paths while processing transactions
1672-
statedb.StartPrefetcher("chain", bc.cacheConfig.TriePrefetcherParallelism)
1673-
defer func() {
1674-
statedb.StopPrefetcher()
1675-
}()
1662+
statedb.StartPrefetcher("chain", state.WithConcurrentWorkers(bc.cacheConfig.TriePrefetcherParallelism))
1663+
defer statedb.StopPrefetcher()
16761664

16771665
// Process previously stored block
16781666
receipts, _, usedGas, err := bc.processor.Process(current, parent.Header(), statedb, vm.Config{})

core/state/pruner/pruner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const (
5252
// stateBloomFilePrefix is the filename prefix of state bloom filter.
5353
stateBloomFilePrefix = "statebloom"
5454

55-
// stateBloomFilePrefix is the filename suffix of state bloom filter.
55+
// stateBloomFileSuffix is the filename suffix of state bloom filter.
5656
stateBloomFileSuffix = "bf.gz"
5757

5858
// stateBloomFileTempSuffix is the filename suffix of state bloom filter

0 commit comments

Comments
 (0)