You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/CONTRIBUTING.md
+33-39Lines changed: 33 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,53 +1,44 @@
1
1
# Contributing
2
2
3
-
Thank you for considering to help out with the source code! We welcome
4
-
contributions from anyone on the internet, and are grateful for even the
5
-
smallest of fixes!
6
-
7
-
If you'd like to contribute to coreth, please fork, fix, commit and send a
8
-
pull request for the maintainers to review and merge into the main code base. If
9
-
you wish to submit more complex changes though, please check up with the core
10
-
devs first on [Discord](https://chat.avalabs.org) to
11
-
ensure those changes are in line with the general philosophy of the project
12
-
and/or get some early feedback which can make both your efforts much lighter as
13
-
well as our review and merge procedures quick and simple.
3
+
Thank you for considering to help out with the source code! We welcome contributions from anyone on the internet, and are grateful for even the smallest of fixes!
4
+
5
+
If you'd like to contribute to coreth, please fork, fix, commit and send a pull request for the maintainers to review and merge into the main code base. If you wish to submit more complex changes though, please check up with the core devs first on [Discord](https://chat.avalabs.org) to ensure those changes are in line with the general philosophy of the project and/or get some early feedback which can make both your efforts much lighter as well as our review and merge procedures quick and simple.
14
6
15
7
## Coding guidelines
16
8
17
9
Please make sure your contributions adhere to our coding guidelines:
- Pull requests need to be based on and opened against the `master` branch.
17
+
- Pull reuqests should include a detailed description
18
+
-Commits are required to be signed. See the [commit signature verification documentation](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits)
19
+
for information on signing commits.
20
+
- Commit messages should be prefixed with the package(s) they modify.
21
+
- E.g. "eth, rpc: make trace configs optional"
30
22
31
23
## Can I have feature X
32
24
33
-
Before you submit a feature request, please check and make sure that it isn't
34
-
possible through some other means.
25
+
Before you submit a feature request, please check and make sure that it isn't possible through some other means.
35
26
36
27
## Mocks
37
28
38
29
Mocks are auto-generated using [mockgen](https://pkg.go.dev/go.uber.org/mock/mockgen) and `//go:generate` commands in the code.
39
30
40
-
* To **re-generate all mocks**, use the command below from the root of the project:
31
+
- To **re-generate all mocks**, use the task below from the root of the project:
41
32
42
-
```sh
43
-
go generate -run mockgen ./...
44
-
```
33
+
```sh
34
+
task generate-mocks
35
+
```
45
36
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 tool -modfile=tools/go.mod mockgen` to generate a mock for your interface (preferred); or
49
-
* add another `//go:generate go tool -modfile=tools/go.mod 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):
37
+
- To **add** an interface that needs a corresponding mock generated:
38
+
- if the file `mocks_generate_test.go` exists in the package where the interface is located, either:
39
+
- modify its `//go:generate go tool -modfile=tools/go.mod mockgen` to generate a mock for your interface (preferred); or
40
+
- add another `//go:generate go tool -modfile=tools/go.mod mockgen` to generate a mock for your interface according to specific mock generation settings
41
+
- 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
42
52
43
```go
53
44
// Copyright (C) 2025-2025, Ava Labs, Inc. All rights reserved.
@@ -61,29 +52,32 @@ Mocks are auto-generated using [mockgen](https://pkg.go.dev/go.uber.org/mock/moc
61
52
Notes:
62
53
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
54
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:
55
+
-To **remove** an interface from having a corresponding mock generated:
65
56
1. Edit the `mocks_generate_test.go` file in the directory where the interface is defined
66
57
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.
58
+
- generates a mock file for multiple interfaces, remove your interface from the line
59
+
- generates a mock file only for the interface, remove the entire line. If the file is empty, remove `mocks_generate_test.go` as well.
69
60
70
61
## ToolDependencies
71
62
72
63
This project uses `go tool` to manage development tool dependencies in `tools/go.mod`. This isolates tool dependencies from the main application dependencies and provides consistent, version-locked tools across the team.
73
64
74
65
### ManagingTools
75
66
76
-
* To **add a new tool**:
67
+
- To **add a new tool**:
68
+
77
69
```sh
78
70
go get -tool -modfile=tools/go.mod example.com/tool/cmd/toolname@version
79
71
```
80
72
81
-
* To **upgrade a tool**:
73
+
- To **upgrade a tool**:
74
+
82
75
```sh
83
76
go get -tool -modfile=tools/go.mod example.com/tool/cmd/toolname@newversion
- Use `./scripts/dev_shell.sh` to start a nix shell
38
+
- Execute the dependency-requiring command (e.g. `./scripts/tests.e2e.sh --start-collectors`)
39
39
40
40
This repo also defines a `.envrc` file to configure [devenv](https://direnv.net/). With
41
41
`devenv` and `nix` installed, a shell at the root of the repo will automatically start a nix
@@ -50,13 +50,13 @@ The C-Chain supports the following API namespaces:
50
50
-`txpool`
51
51
-`debug`
52
52
53
-
Only the `eth` namespace is enabled by default.
54
-
To enable the other namespaces see the instructions for passing the C-Chain config to AvalancheGo [here.](https://docs.avax.network/nodes/configure/chain-config-flags#enabling-evm-apis)
55
-
Full documentation for the C-Chain's API can be found [here.](https://docs.avax.network/reference/avalanchego/c-chain/api)
53
+
Only the `eth` namespace is enabled by default.
54
+
To enable the other namespaces see the instructions for passing the C-Chain config to AvalancheGo in the [chain-config-flags documentation](https://build.avax.network/docs/nodes/chain-configs/c-chain#api-configuration).
55
+
Full documentation for the C-Chain's API can be found in the [C-Chain API documentation](https://build.avax.network/docs/nodes/chain-configs/c-chain).
56
56
57
57
## Compatibility
58
58
59
-
The C-Chain is compatible with almost all Ethereum tooling, including [Core,](https://docs.avax.network/build/dapp/launch-dapp#through-core)[Metamask,](https://docs.avax.network/build/dapp/launch-dapp#through-metamask)[Remix](https://docs.avax.network/dapps/smart-contract-dev/deploy-with-remix-ide) and [Truffle.](https://docs.avax.network/build/tutorials/smart-contracts/using-truffle-with-the-avalanche-c-chain)
59
+
The C-Chain is compatible with almost all Ethereum tooling, including [Core,](https://docs.avax.network/build/dapp/launch-dapp#through-core)[Metamask,](https://docs.avax.network/build/dapp/launch-dapp#through-metamask)and [Remix](https://docs.avax.network/dapps/smart-contract-dev/deploy-with-remix-ide).
60
60
61
61
## Differences Between Avalanche C-Chain and Ethereum
62
62
@@ -82,15 +82,15 @@ To support these changes, there have been a number of changes to the C-Chain blo
82
82
83
83
### Block Body
84
84
85
-
*`Version`: provides version of the `ExtData` in the block. Currently, this field is always 0.
86
-
*`ExtData`: extra data field within the block body to store atomic transaction bytes.
85
+
-`Version`: provides version of the `ExtData` in the block. Currently, this field is always 0.
86
+
-`ExtData`: extra data field within the block body to store atomic transaction bytes.
87
87
88
88
### Block Header
89
89
90
-
*`ExtDataHash`: the hash of the bytes in the `ExtDataHash` field
91
-
*`BaseFee`: Added by EIP-1559 to represent the base fee of the block (present in Ethereum as of EIP-1559)
92
-
*`ExtDataGasUsed`: amount of gas consumed by the atomic transactions in the block
93
-
*`BlockGasCost`: surcharge for producing a block faster than the target rate
90
+
-`ExtDataHash`: the hash of the bytes in the `ExtDataHash` field
91
+
-`BaseFee`: Added by EIP-1559 to represent the base fee of the block (present in Ethereum as of EIP-1559)
92
+
-`ExtDataGasUsed`: amount of gas consumed by the atomic transactions in the block
93
+
-`BlockGasCost`: surcharge for producing a block faster than the target rate
Copy file name to clipboardExpand all lines: SECURITY.md
+2-3Lines changed: 2 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,16 +5,15 @@ responsible disclosures. Valid reports will be eligible for a reward (terms and
5
5
6
6
## Reporting a Vulnerability
7
7
8
-
**Please do not file a public ticket** mentioning the vulnerability. To disclose a vulnerability submit it through our [Bug Bounty Program](https://hackenproof.com/avalanche).
8
+
**Please do not file a public ticket** mentioning the vulnerability. To disclose a vulnerability submit it through our [Bug Bounty Program](https://immunefi.com/bug-bounty/avalabs/information/).
9
9
10
10
Vulnerabilities must be disclosed to us privately with reasonable time to respond, and avoid compromise of other users and accounts, or loss of funds that are not your own. We do not reward spam or
11
11
social engineering vulnerabilities.
12
12
13
13
Do not test for or validate any security issues in the live Avalanche networks (Mainnet and Fuji testnet), confirm all exploits in a local private testnet.
14
14
15
-
Please refer to the [Bug Bounty Page](https://hackenproof.com/avalanche) for the most up-to-date program rules and scope.
15
+
Please refer to the [Bug Bounty Page](https://immunefi.com/bug-bounty/avalabs/information/) for the most up-to-date program rules and scope.
16
16
17
17
## Supported Versions
18
18
19
19
Please use the [most recently released version](https://github.com/ava-labs/coreth/releases/latest) to perform testing and to validate security issues.
Copy file name to clipboardExpand all lines: cmd/simulator/README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ To confirm that you built successfully, run the simulator and print the version:
24
24
25
25
This should give the following output:
26
26
27
-
```
27
+
```bash
28
28
v0.1.0
29
29
```
30
30
@@ -45,7 +45,7 @@ The `--sybil-protection-enabled=false` flag is only suitable for local testing.
45
45
1. Ignore stake weight on the P-Chain and count each connected peer as having a stake weight of 1
46
46
2. Automatically opts in to validate every Subnet
47
47
48
-
Once you have AvalancheGo running locally, it will be running an HTTP Server on the default port `9650`. This means that the RPC Endpoint for the C-Chain will be http://127.0.0.1:9650/ext/bc/C/rpc and ws://127.0.0.1:9650/ext/bc/C/ws for WebSocket connections.
48
+
Once you have AvalancheGo running locally, it will be running an HTTP Server on the default port `9650`. This means that the RPC Endpoint for the C-Chain will be `http://127.0.0.1:9650/ext/bc/C/rpc` and `ws://127.0.0.1:9650/ext/bc/C/ws` for WebSocket connections.
49
49
50
50
Now, we can run the simulator command to simulate some load on the local C-Chain for 30s:
Copy file name to clipboardExpand all lines: consensus/dummy/README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ The dummy consensus engine is responsible for performing verification on the hea
12
12
13
13
## Dynamic Fees
14
14
15
-
As of Apricot Phase 3, the C-Chain 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.
15
+
As of Apricot Phase 3, the C-Chain 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.
16
16
17
17
The dynamic fee algorithm aims to adjust the base fee to handle network congestion. Coreth 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.
18
18
@@ -30,4 +30,4 @@ The FinalizeAndAssemble callback is used as the final step in building a block w
30
30
31
31
### Finalize
32
32
33
-
Finalize is called as the final step in processing a block [here](../../core/state_processor.go). Finalize adds a callback function in order to process atomic transactions as well. Since either Finalize or FinalizeAndAssemble are called, but not both, when building or verifying/processing a block they need to perform the exact same processing/verification step to ensure that a block produced by the miner where FinalizeAndAssemble is called will be processed and verified in the same way when Finalize gets called.
33
+
Finalize is called as the final step in processing a block in [state_processor.go](../../core/state_processor.go). Finalize adds a callback function in order to process atomic transactions as well. Since either Finalize or FinalizeAndAssemble are called, but not both, when building or verifying/processing a block they need to perform the exact same processing/verification step to ensure that a block produced by the miner where FinalizeAndAssemble is called will be processed and verified in the same way when Finalize gets called.
Copy file name to clipboardExpand all lines: core/README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ The core package maintains the backend for the blockchain, transaction pool, and
6
6
7
7
The [BlockChain](./blockchain.go) struct handles the insertion of blocks into the maintained chain. It maintains a "canonical chain", which is essentially the preferred chain (the chain that ends with the block preferred by the AvalancheGo consensus engine).
8
8
9
-
When the consensus engine verifies blocks as they are ready to be issued into consensus, it calls `Verify()` on the ChainVM Block interface implemented [here](../plugin/evm/block.go). This calls `InsertBlockManual` on the BlockChain struct implemented in this package, which is the first entrypoint of a block into the blockchain.
9
+
When the consensus engine verifies blocks as they are ready to be issued into consensus, it calls `Verify()` on the ChainVM Block interface implemented in [wrapped_block.go](../plugin/evm/wrapped_block.go). This calls `InsertBlockManual` on the BlockChain struct implemented in this package, which is the first entrypoint of a block into the blockchain.
10
10
11
11
InsertBlockManual verifies the block, inserts it into the state manager to track the merkle trie for the block, and adds it to the canonical chain if it extends the currently preferred chain.
12
12
@@ -20,7 +20,7 @@ The transaction pool maintains the set of transactions that need to be issued in
20
20
21
21
## State Manager
22
22
23
-
The State Manager manages the [TrieDB](../trie/database.go). The TrieDB tracks a merkle forest of all of the merkle tries for the last accepted block and processing blocks. When a block is processed, the state transition results in a new merkle trie added to the merkle forest. The State Manager can operate in either archival or pruning mode.
23
+
The State Manager manages references to state roots in the TrieDB implementations (see [`triedb`](../triedb/) for hashdb, pathdb, and firewood implementations). The TrieDB stores trie nodes (the individual components of state tries) in memory and on disk. When a block is processed, the state transition results in a new state root, and the TrieDB updates or inserts the trie nodes that compose this state. The State Manager tracks which state roots are referenced by processing blocks and manages when to commit trie nodes to disk or dereference them. The State Manager can operate in either archival or pruning mode.
0 commit comments