diff --git a/.envrc b/.envrc new file mode 100644 index 0000000000..2d576c8ac3 --- /dev/null +++ b/.envrc @@ -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}" diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b444581e62..ee80e2a8b4 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,3 +9,7 @@ updates: directory: "/" # Location of package manifests schedule: interval: "daily" + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: weekly diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 61fb449742..b3ef706bac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: . @@ -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 }} @@ -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 || '' }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index b15565a708..7ee172307e 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -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. @@ -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 @@ -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 diff --git a/.gitignore b/.gitignore index a93619ce95..05c143bd4e 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,5 @@ build/ # Used for e2e testing avalanchego + +.direnv diff --git a/README.md b/README.md index 08ea17aa62..dd72daeda0 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/accounts/abi/bind/util_test.go b/accounts/abi/bind/util_test.go index 874e91314a..5de577c083 100644 --- a/accounts/abi/bind/util_test.go +++ b/accounts/abi/bind/util_test.go @@ -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") @@ -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() @@ -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 { @@ -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") diff --git a/core/genesis.go b/core/genesis.go index 465d503ef6..37c0405267 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -296,7 +296,9 @@ func (g *Genesis) toBlock(db ethdb.Database, triedb *triedb.Database) *types.Blo } } - statedb.Commit(0, false) + if _, err := statedb.Commit(0, false); err != nil { + panic(fmt.Sprintf("unable to commit genesis block to statedb: %v", err)) + } // Commit newly generated states into disk if it's not empty. if root != types.EmptyRootHash { if err := triedb.Commit(root, true); err != nil { diff --git a/go.mod b/go.mod index 7ea125295f..051b9d2a93 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 @@ -107,7 +108,7 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/status-im/keycard-go v0.2.0 // indirect github.com/subosito/gotenv v1.3.0 // indirect - github.com/supranational/blst v0.3.13 // indirect + github.com/supranational/blst v0.3.14 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect diff --git a/go.sum b/go.sum index 7e07f33b2f..27987ede3e 100644 --- a/go.sum +++ b/go.sum @@ -49,6 +49,8 @@ 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= @@ -56,8 +58,8 @@ 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= @@ -525,8 +527,8 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.3.0 h1:mjC+YW8QpAdXibNi+vNWgzmgBH4+5l5dCXv8cNysBLI= github.com/subosito/gotenv v1.3.0/go.mod h1:YzJjq/33h7nrwdY+iHMhEOEEbW0ovIz0tB6t6PwAXzs= -github.com/supranational/blst v0.3.13 h1:AYeSxdOMacwu7FBmpfloBz5pbFXDmJL33RuwnKtmTjk= -github.com/supranational/blst v0.3.13/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= +github.com/supranational/blst v0.3.14 h1:xNMoHRJOTwMn63ip6qoWJ2Ymgvj7E2b9jY2FAwY+qRo= +github.com/supranational/blst v0.3.14/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a h1:1ur3QoCqvE5fl+nylMaIr9PVV1w343YRDtsy+Rwu7XI= github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= diff --git a/internal/ethapi/api.coreth.go b/internal/ethapi/api.coreth.go index 0efa461a5e..6948105214 100644 --- a/internal/ethapi/api.coreth.go +++ b/internal/ethapi/api.coreth.go @@ -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) ) @@ -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, diff --git a/internal/ethapi/api.coreth_test.go b/internal/ethapi/api.coreth_test.go index 1ad453e0db..8c919d04dc 100644 --- a/internal/ethapi/api.coreth_test.go +++ b/internal/ethapi/api.coreth_test.go @@ -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" ) @@ -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) { @@ -35,6 +39,14 @@ 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, @@ -42,6 +54,10 @@ func TestSuggestPriceOptions(t *testing.T) { 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 @@ -52,6 +68,7 @@ func TestSuggestPriceOptions(t *testing.T) { estimateBaseFee *big.Int suggestGasTipCap *big.Int cfg PriceOptionConfig + chainCfg *params.ChainConfig want *PriceOptions }{ { @@ -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, @@ -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), @@ -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, @@ -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{ @@ -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, @@ -160,6 +202,7 @@ func TestSuggestPriceOptions(t *testing.T) { estimateBaseFee: test.estimateBaseFee, suggestGasTipCap: test.suggestGasTipCap, cfg: test.cfg, + chainCfg: test.chainCfg, } api := NewEthereumAPI(backend) diff --git a/metrics/prometheus/enabled_test.go b/metrics/prometheus/enabled_test.go new file mode 100644 index 0000000000..ed967e0ece --- /dev/null +++ b/metrics/prometheus/enabled_test.go @@ -0,0 +1,29 @@ +// (c) 2021-2025, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +package prometheus_test + +import ( + "testing" + + // NOTE: This test assumes that there are no imported packages that might + // change the default value of [metrics.Enabled]. It is therefore in package + // `prometheus_test` in case any other tests modify the variable. If any + // imports here or in the implementation do actually do so then this test + // may have false negatives. + "github.com/stretchr/testify/assert" + + "github.com/ava-labs/libevm/metrics" +) + +func TestMetricsEnabledByDefault(t *testing.T) { + assert.True(t, metrics.Enabled, "libevm/metrics.Enabled") + + switch m := metrics.NewCounter().(type) { + case metrics.NilCounter: + t.Errorf("metrics.NewCounter() got %T; want %T", m, new(metrics.StandardCounter)) + case *metrics.StandardCounter: + default: + t.Errorf("metrics.NewCounter() got unknown type %T", m) + } +} diff --git a/metrics/prometheus/prometheus_test.go b/metrics/prometheus/prometheus_test.go index 5cce784a3f..4263abed7d 100644 --- a/metrics/prometheus/prometheus_test.go +++ b/metrics/prometheus/prometheus_test.go @@ -1,4 +1,4 @@ -// (c) 2021-2025, Ava Labs, Inc. All rights reserved. +// (c) 2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. package prometheus diff --git a/scripts/dev_shell.sh b/scripts/dev_shell.sh new file mode 100755 index 0000000000..e0ac26a7bc --- /dev/null +++ b/scripts/dev_shell.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# Copyright (C) 2025, Ava Labs, Inc. All rights reserved. + +set -euo pipefail + +# Requires nix to be installed. The determinate systems installer is recommended: +# +# https://github.com/DeterminateSystems/nix-installer?tab=readme-ov-file#install-nix +# + +# Load AVALANCHE_VERSION +SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=/scripts/constants.sh +source "$SCRIPT_DIR"/versions.sh + +# Start a dev shell with the avalanchego flake +FLAKE="github:ava-labs/avalanchego?ref=${AVALANCHE_VERSION}" +echo "Starting nix shell for ${FLAKE}" +nix develop "${FLAKE}" "${@}" diff --git a/scripts/known_flakes.txt b/scripts/known_flakes.txt index 0f324a6714..260e38e647 100644 --- a/scripts/known_flakes.txt +++ b/scripts/known_flakes.txt @@ -7,6 +7,7 @@ TestResumeSyncAccountsTrieInterrupted TestResyncNewRootAfterDeletes TestTimedUnlock TestTransactionSkipIndexing +TestUpdatedKeyfileContents TestVMShutdownWhileSyncing TestWaitDeployedCornerCases TestWalletNotifications diff --git a/scripts/tests.e2e.sh b/scripts/tests.e2e.sh index 85f5bd3d48..21f52f6408 100755 --- a/scripts/tests.e2e.sh +++ b/scripts/tests.e2e.sh @@ -7,6 +7,7 @@ set -euo pipefail # e.g., # ./scripts/tests.e2e.sh # AVALANCHE_VERSION=v1.10.x ./scripts/tests.e2e.sh +# ./scripts/tests.e2e.sh --start-monitors # All arguments are supplied to ginkgo if ! [[ "$0" =~ scripts/tests.e2e.sh ]]; then echo "must be run from repository root" exit 255 @@ -51,4 +52,4 @@ echo "building avalanchego" ./scripts/build.sh -r echo "running AvalancheGo e2e tests" -E2E_SERIAL=1 ./scripts/tests.e2e.sh --ginkgo.label-filter='c || uses-c' +E2E_SERIAL=1 ./scripts/tests.e2e.sh --ginkgo.label-filter='c || uses-c' "${@}" diff --git a/scripts/update_avalanchego_version.sh b/scripts/update_avalanchego_version.sh new file mode 100755 index 0000000000..892f9d152d --- /dev/null +++ b/scripts/update_avalanchego_version.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +set -euo pipefail + +if ! [[ "$0" =~ scripts/update_avalanchego_version.sh ]]; then + echo "must be run from repository root, but got $0" + exit 255 +fi + +# If version is not provided, the existing version in go.mod is assumed +VERSION="${1:-}" + +if [[ -n "${VERSION}" ]]; then + echo "Ensuring AvalancheGo version $VERSION in go.mod" + go get "github.com/ava-labs/avalanchego@${VERSION}" + go mod tidy +fi + +# Discover AVALANCHE_VERSION +. scripts/versions.sh + +# The full SHA is required for versioning custom actions. +CURL_ARGS=(curl -s) +if [[ -n "${GITHUB_TOKEN:-}" ]]; then + # Using an auth token avoids being rate limited when run in CI + CURL_ARGS+=(-H "Authorization: token ${GITHUB_TOKEN}") +fi +CURL_URL="https://api.github.com/repos/ava-labs/avalanchego/commits/${AVALANCHE_VERSION}" +FULL_AVALANCHE_VERSION="$("${CURL_ARGS[@]}" "${CURL_URL}" | grep '"sha":' | head -n1 | cut -d'"' -f4)" + +# Ensure the custom action version matches the avalanche version +WORKFLOW_PATH=".github/workflows/ci.yml" +CUSTOM_ACTION="ava-labs/avalanchego/.github/actions/run-monitored-tmpnet-cmd" +echo "Ensuring AvalancheGo version ${FULL_AVALANCHE_VERSION} for ${CUSTOM_ACTION} custom action in ${WORKFLOW_PATH} " +sed -i.bak "s|\(uses: ${CUSTOM_ACTION}\)@.*|\1@${FULL_AVALANCHE_VERSION}|g" "${WORKFLOW_PATH}" && rm -f "${WORKFLOW_PATH}.bak"