Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
10 changes: 10 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# - Will execute on entry to the containing directory only if authorized with `direnv allow`
# - Requires a recent version of direnv (https://direnv.net/)
# - For quieter direnv output, set `export DIRENV_LOG_FORMAT=`

# Determine AVALANCHE_VERSION
source ./scripts/versions.sh

# - Starts an avalanchego dev shell
# - Requires nix (https://github.com/DeterminateSystems/nix-installer?tab=readme-ov-file#install-nix)
use flake "github:ava-labs/avalanchego?ref=${AVALANCHE_VERSION}"
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "daily"
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
21 changes: 13 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- run: ./scripts/lint_allowed_eth_imports.sh
shell: bash
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc #v3
with:
version: v1.63
working-directory: .
Expand All @@ -55,6 +55,11 @@ jobs:
- name: Run actionlint
shell: bash
run: scripts/actionlint.sh
- name: Ensure consistent avalanchego version
shell: bash
run: |
./scripts/update_avalanchego_version.sh
git diff --exit-code
test:
name: Golang Unit Tests (${{ matrix.os }})
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -128,11 +133,11 @@ jobs:
with:
go-version-file: "go.mod"
- name: Run e2e tests
run: E2E_SERIAL=1 ./scripts/tests.e2e.sh
shell: bash
- name: Upload tmpnet network dir
uses: actions/upload-artifact@v4
if: always()
uses: ava-labs/avalanchego/.github/actions/run-monitored-tmpnet-cmd@3a6bfac46f43ac2d7cc1e3fc8576ff6a8594bafa
with:
name: tmpnet-data
path: ~/.tmpnet/networks/1000
run: ./scripts/tests.e2e.sh
run_env: E2E_SERIAL=1
prometheus_username: ${{ secrets.PROMETHEUS_ID || '' }}
prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }}
loki_username: ${{ secrets.LOKI_ID || '' }}
loki_password: ${{ secrets.LOKI_PASSWORD || '' }}
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@1b549b9259bda1cb5ddde3b41741a82a2d15a841 #v3.28.13
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -55,7 +55,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3
uses: github/codeql-action/autobuild@1b549b9259bda1cb5ddde3b41741a82a2d15a841 #v3.28.13

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -69,4 +69,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@1b549b9259bda1cb5ddde3b41741a82a2d15a841 #v3.28.13
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ build/

# Used for e2e testing
avalanchego

.direnv
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@ Now that AvalancheGo depends on the local version of Coreth, we can build with t

Note: the C-Chain originally ran in a separate process from the main AvalancheGo process and communicated with it over a local gRPC connection. When this was the case, AvalancheGo's build script would download Coreth, compile it, and place the binary into the `avalanchego/build/plugins` directory.

### Optional Dev Shell

Some activities, such as collecting metrics and logs from the nodes targeted by an e2e
test run, require binary dependencies. One way of making these dependencies available is
to use a nix shell which will give access to the dependencies expected by the test
tooling:

- Install [nix](https://nixos.org/). The [determinate systems
installer](https://github.com/DeterminateSystems/nix-installer?tab=readme-ov-file#install-nix)
is recommended.
- Use `./scripts/dev_shell.sh` to start a nix shell
- Execute the dependency-requiring command (e.g. `./scripts/tests.e2e.sh --start-collectors`)

This repo also defines a `.envrc` file to configure [devenv](https://direnv.net/). With
`devenv` and `nix` installed, a shell at the root of the repo will automatically start a nix
dev shell.

## API

The C-Chain supports the following API namespaces:
Expand Down
12 changes: 6 additions & 6 deletions accounts/abi/bind/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"github.com/ava-labs/libevm/common"
"github.com/ava-labs/libevm/core/types"
"github.com/ava-labs/libevm/crypto"
"github.com/stretchr/testify/require"
)

var testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
Expand Down Expand Up @@ -77,11 +78,11 @@ func TestWaitDeployed(t *testing.T) {
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(params.GWei))

tx := types.NewContractCreation(0, big.NewInt(0), test.gas, gasPrice, common.FromHex(test.code))
tx, _ = types.SignTx(tx, types.LatestSignerForChainID(big.NewInt(1337)), testKey)
tx, err := types.SignTx(tx, types.LatestSignerForChainID(big.NewInt(1337)), testKey)
require.NoError(t, err, "types.SignTx")

// Wait for it to get mined in the background.
var (
err error
address common.Address
mined = make(chan struct{})
ctx = context.Background()
Expand Down Expand Up @@ -126,9 +127,7 @@ func TestWaitDeployedCornerCases(t *testing.T) {
code := "6060604052600a8060106000396000f360606040526008565b00"
tx := types.NewTransaction(0, common.HexToAddress("0x01"), big.NewInt(0), 3000000, gasPrice, common.FromHex(code))
tx, err := types.SignTx(tx, types.LatestSignerForChainID(big.NewInt(1337)), testKey)
if err != nil {
t.Fatalf("Failed to sign transaction: %s", err)
}
require.NoError(t, err, "types.SignTx")
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
if err := backend.Client().SendTransaction(ctx, tx); err != nil {
Expand All @@ -142,7 +141,8 @@ func TestWaitDeployedCornerCases(t *testing.T) {

// Create a transaction that is not mined.
tx = types.NewContractCreation(1, big.NewInt(0), 3000000, gasPrice, common.FromHex(code))
tx, _ = types.SignTx(tx, types.LatestSignerForChainID(big.NewInt(1337)), testKey)
tx, err = types.SignTx(tx, types.LatestSignerForChainID(big.NewInt(1337)), testKey)
require.NoError(t, err, "types.SignTx")

go func() {
contextCanceled := errors.New("context canceled")
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.23.6

require (
github.com/VictoriaMetrics/fastcache v1.12.1
github.com/ava-labs/avalanchego v1.12.3-name-fortuna.0.0.20250326131842-1e9f474dee74
github.com/ava-labs/avalanchego v1.13.1-0.20250327151600-3a6bfac46f43
github.com/ava-labs/libevm v1.13.14-0.2.0.rc.4
github.com/davecgh/go-spew v1.1.1
github.com/deckarep/golang-set/v2 v2.1.0
Expand Down Expand Up @@ -41,6 +41,7 @@ require (
require (
github.com/DataDog/zstd v1.5.2 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/StephenButtolph/canoto v0.15.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,17 @@ github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKz
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0=
github.com/StephenButtolph/canoto v0.15.0 h1:3iGdyTSQZ7/y09WaJCe0O/HIi53ZyTrnmVzfCqt64mM=
github.com/StephenButtolph/canoto v0.15.0/go.mod h1:IcnAHC6nJUfQFVR9y60ko2ecUqqHHSB6UwI9NnBFZnE=
github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40=
github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/ava-labs/avalanchego v1.12.3-name-fortuna.0.0.20250326131842-1e9f474dee74 h1:3GYL5JGp8vsC3donZHU/Q/ylOdDjX4IRka87hBEVs6Q=
github.com/ava-labs/avalanchego v1.12.3-name-fortuna.0.0.20250326131842-1e9f474dee74/go.mod h1:mcl8JQ5kJKmh1s0/+y/5NJirgwA2nR67h6iHfL5Dklk=
github.com/ava-labs/avalanchego v1.13.1-0.20250327151600-3a6bfac46f43 h1:N7C2AEHTSme0+MMa6n0TPDD11VbTqSNeT4eG2UKg610=
github.com/ava-labs/avalanchego v1.13.1-0.20250327151600-3a6bfac46f43/go.mod h1:jSJtHEp/1AGaruY53bQhDxbc/8UXh0n01yNTlggX3wk=
github.com/ava-labs/libevm v1.13.14-0.2.0.rc.4 h1:wnq3x3OE8DnBTBeKFjiywRO/MfnEXWjoSgnZtTQ1LS8=
github.com/ava-labs/libevm v1.13.14-0.2.0.rc.4/go.mod h1:+Iol+sVQ1KyoBsHf3veyrBmHCXr3xXRWq6ZXkgVfNLU=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
Expand Down
20 changes: 15 additions & 5 deletions internal/ethapi/api.coreth.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@ import (
"fmt"
"math/big"

"github.com/ava-labs/coreth/params"
"github.com/ava-labs/coreth/plugin/evm/upgrade/acp176"
"github.com/ava-labs/coreth/plugin/evm/upgrade/etna"
"github.com/ava-labs/libevm/common/hexutil"
"github.com/ava-labs/libevm/common/math"
)

const (
minBaseFee = etna.MinBaseFee // 1 nAVAX
minGasTip = 1 // 1 wei

minGasTip = 1 // 1 wei
feeDenominator = 100
)

var (
bigMinBaseFee = big.NewInt(minBaseFee)
bigMinGasTip = big.NewInt(minGasTip)
bigFeeDenominator = big.NewInt(feeDenominator)
)
Expand Down Expand Up @@ -63,12 +62,23 @@ func (s *EthereumAPI) SuggestPriceOptions(ctx context.Context) (*PriceOptions, e
return nil, nil
}

// Find min base fee based on chain config
// TODO: This can be removed after Fortuna is activated
time := s.b.CurrentHeader().Time
chainConfig := params.GetExtra(s.b.ChainConfig())
minBaseFee := new(big.Int)
if chainConfig.IsFortuna(time) {
minBaseFee.SetUint64(acp176.MinGasPrice)
} else {
minBaseFee.SetUint64(etna.MinBaseFee)
}

cfg := s.b.PriceOptionsConfig()
bigSlowFeePercent := new(big.Int).SetUint64(cfg.SlowFeePercentage)
bigFastFeePercent := new(big.Int).SetUint64(cfg.FastFeePercentage)

baseFees := calculateFeeSpeeds(
bigMinBaseFee,
minBaseFee,
baseFee,
big.NewInt(int64(cfg.MaxBaseFee)),
bigSlowFeePercent,
Expand Down
47 changes: 45 additions & 2 deletions internal/ethapi/api.coreth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import (
"testing"

"github.com/ava-labs/coreth/params"
"github.com/ava-labs/coreth/plugin/evm/upgrade/acp176"
"github.com/ava-labs/coreth/plugin/evm/upgrade/etna"
"github.com/ava-labs/libevm/common"
"github.com/ava-labs/libevm/common/hexutil"
"github.com/ava-labs/libevm/core/types"
"github.com/stretchr/testify/require"
)

Expand All @@ -20,7 +23,8 @@ type testSuggestPriceOptionsBackend struct {
estimateBaseFee *big.Int
suggestGasTipCap *big.Int

cfg PriceOptionConfig
cfg PriceOptionConfig
chainCfg *params.ChainConfig
}

func (b *testSuggestPriceOptionsBackend) EstimateBaseFee(context.Context) (*big.Int, error) {
Expand All @@ -35,13 +39,25 @@ func (b *testSuggestPriceOptionsBackend) PriceOptionsConfig() PriceOptionConfig
return b.cfg
}

func (b *testSuggestPriceOptionsBackend) ChainConfig() *params.ChainConfig {
return b.chainCfg
}

func (b *testSuggestPriceOptionsBackend) CurrentHeader() *types.Header {
return &types.Header{Time: 1}
}

func TestSuggestPriceOptions(t *testing.T) {
testCfg := PriceOptionConfig{
SlowFeePercentage: 95,
FastFeePercentage: 105,
MaxBaseFee: 100 * params.GWei,
MaxTip: 20 * params.GWei,
}
minBaseFee := etna.MinBaseFee
bigMinBaseFee := big.NewInt(int64(minBaseFee))
fortunaMinBaseFee := acp176.MinGasPrice
bigFortunaMinBaseFee := big.NewInt(int64(fortunaMinBaseFee))
slowFeeNumerator := testCfg.SlowFeePercentage
fastFeeNumerator := testCfg.FastFeePercentage
maxNormalGasTip := testCfg.MaxTip
Expand All @@ -52,6 +68,7 @@ func TestSuggestPriceOptions(t *testing.T) {
estimateBaseFee *big.Int
suggestGasTipCap *big.Int
cfg PriceOptionConfig
chainCfg *params.ChainConfig
want *PriceOptions
}{
{
Expand All @@ -67,10 +84,11 @@ func TestSuggestPriceOptions(t *testing.T) {
want: nil,
},
{
name: "minimum_values",
name: "minimum_values_etna",
estimateBaseFee: bigMinBaseFee,
suggestGasTipCap: bigMinGasTip,
cfg: testCfg,
chainCfg: params.TestEtnaChainConfig,
want: &PriceOptions{
Slow: newPrice(
minGasTip,
Expand All @@ -86,6 +104,27 @@ func TestSuggestPriceOptions(t *testing.T) {
),
},
},
{
name: "minimum_values_fortuna",
estimateBaseFee: bigFortunaMinBaseFee,
suggestGasTipCap: bigMinGasTip,
cfg: testCfg,
chainCfg: params.TestFortunaChainConfig,
want: &PriceOptions{
Slow: newPrice(
minGasTip,
uint64(fortunaMinBaseFee+minGasTip),
),
Normal: newPrice(
minGasTip,
uint64(fortunaMinBaseFee+minGasTip),
),
Fast: newPrice(
minGasTip,
(fastFeeNumerator*uint64(fortunaMinBaseFee)/feeDenominator)+(fastFeeNumerator*uint64(minGasTip)/feeDenominator),
),
},
},
{
name: "maximum_values_1_slow_perc_2_fast_perc",
estimateBaseFee: new(big.Int).SetUint64(maxNormalBaseFee),
Expand All @@ -96,6 +135,7 @@ func TestSuggestPriceOptions(t *testing.T) {
MaxBaseFee: 100 * params.GWei,
MaxTip: 20 * params.GWei,
},
chainCfg: params.TestEtnaChainConfig,
want: &PriceOptions{
Slow: newPrice(
20*params.GWei,
Expand All @@ -114,6 +154,7 @@ func TestSuggestPriceOptions(t *testing.T) {
{
name: "maximum_values",
cfg: testCfg,
chainCfg: params.TestEtnaChainConfig,
estimateBaseFee: new(big.Int).SetUint64(maxNormalBaseFee),
suggestGasTipCap: new(big.Int).SetUint64(maxNormalGasTip),
want: &PriceOptions{
Expand All @@ -136,6 +177,7 @@ func TestSuggestPriceOptions(t *testing.T) {
estimateBaseFee: big.NewInt(2 * int64(maxNormalBaseFee)),
suggestGasTipCap: big.NewInt(2 * int64(maxNormalGasTip)),
cfg: testCfg,
chainCfg: params.TestEtnaChainConfig,
want: &PriceOptions{
Slow: newPrice(
(slowFeeNumerator*maxNormalGasTip)/feeDenominator,
Expand All @@ -160,6 +202,7 @@ func TestSuggestPriceOptions(t *testing.T) {
estimateBaseFee: test.estimateBaseFee,
suggestGasTipCap: test.suggestGasTipCap,
cfg: test.cfg,
chainCfg: test.chainCfg,
}
api := NewEthereumAPI(backend)

Expand Down
Loading
Loading