diff --git a/go.mod b/go.mod index 988e7ef1b806..9a6606c55109 100644 --- a/go.mod +++ b/go.mod @@ -21,8 +21,8 @@ require ( github.com/DataDog/zstd v1.5.2 github.com/StephenButtolph/canoto v0.17.3 github.com/antithesishq/antithesis-sdk-go v0.3.8 - github.com/ava-labs/coreth v0.16.0-rc.0 - github.com/ava-labs/libevm v1.13.15-0.20251016142715-1bccf4f2ddb2 + github.com/ava-labs/coreth v0.16.1-0.20251114233600-7b5fd1ab025a + github.com/ava-labs/libevm v1.13.15-0.20251114170401-749b6cefda28 github.com/ava-labs/subnet-evm v0.8.1-db-metrics-fix github.com/btcsuite/btcd/btcutil v1.1.3 github.com/cespare/xxhash/v2 v2.3.0 @@ -86,6 +86,13 @@ require ( k8s.io/utils v0.0.0-20230726121419-3b25d923346b ) +require ( + github.com/arr4n/sink v0.0.0-20250610120507-bd1b0fbb19fa // indirect + github.com/ava-labs/strevm v0.0.0-20251114233539-0a61685c723b // indirect + github.com/dustin/go-humanize v1.0.0 // indirect + github.com/google/go-cmp v0.7.0 // indirect +) + require ( github.com/Microsoft/go-winio v0.6.1 // indirect github.com/VictoriaMetrics/fastcache v1.12.1 // indirect diff --git a/go.sum b/go.sum index 3dd0e624038f..8a9b3cfb28e9 100644 --- a/go.sum +++ b/go.sum @@ -71,14 +71,18 @@ github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmV github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/ava-labs/coreth v0.16.0-rc.0 h1:nPvkDbxaH8N9f/wQe7B+IGMhPISMuW5CU0cDYuU8iCw= -github.com/ava-labs/coreth v0.16.0-rc.0/go.mod h1:uGr1C7BP0+dWhvsIouhuH0yCyI8YDgS6sfEFIExs0iI= +github.com/arr4n/sink v0.0.0-20250610120507-bd1b0fbb19fa h1:7d3Bkbr8pwxrPnK7AbJzI7Qi0DmLAHIgXmPT26D186w= +github.com/arr4n/sink v0.0.0-20250610120507-bd1b0fbb19fa/go.mod h1:TFbsruhH4SB/VO/ONKgNrgBeTLDkpr+uydstjIVyFFQ= +github.com/ava-labs/coreth v0.16.1-0.20251114233600-7b5fd1ab025a h1:IDqMd4qzxHlq+8H5MCIgg9o53Sg8+0KUHAvk3VTeDpU= +github.com/ava-labs/coreth v0.16.1-0.20251114233600-7b5fd1ab025a/go.mod h1:ttlUGB+A3zN2G+6k5Xx+5BgBWwUk0pfYEemB1em9z6s= github.com/ava-labs/firewood-go-ethhash/ffi v0.0.13 h1:obPwnVCkF5+B2f8WbTepHj0ZgiW21vKUgFCtATuAYNY= github.com/ava-labs/firewood-go-ethhash/ffi v0.0.13/go.mod h1:gsGr1ICjokI9CyPaaRHMqDoDCaT1VguC/IyOTx6rJ14= -github.com/ava-labs/libevm v1.13.15-0.20251016142715-1bccf4f2ddb2 h1:hQ15IJxY7WOKqeJqCXawsiXh0NZTzmoQOemkWHz7rr4= -github.com/ava-labs/libevm v1.13.15-0.20251016142715-1bccf4f2ddb2/go.mod h1:DqSotSn4Dx/UJV+d3svfW8raR+cH7+Ohl9BpsQ5HlGU= +github.com/ava-labs/libevm v1.13.15-0.20251114170401-749b6cefda28 h1:7WTOLtDzlI+L1cU2PLc++xPxliDzfkJWkaxpXYmuaZM= +github.com/ava-labs/libevm v1.13.15-0.20251114170401-749b6cefda28/go.mod h1:DqSotSn4Dx/UJV+d3svfW8raR+cH7+Ohl9BpsQ5HlGU= github.com/ava-labs/simplex v0.0.0-20250919142550-9cdfff10fd19 h1:S6oFasZsplNmw8B2S8cMJQMa62nT5ZKGzZRdCpd+5qQ= github.com/ava-labs/simplex v0.0.0-20250919142550-9cdfff10fd19/go.mod h1:GVzumIo3zR23/qGRN2AdnVkIPHcKMq/D89EGWZfMGQ0= +github.com/ava-labs/strevm v0.0.0-20251114233539-0a61685c723b h1:769mlxR0zAfCeleq0PGLk5P9p+UghjJJ6PU68qhfzpo= +github.com/ava-labs/strevm v0.0.0-20251114233539-0a61685c723b/go.mod h1:HKy8UC/JTPzTYA3RGPv/DHps3fGlWG1ODsq9GdI1WSk= github.com/ava-labs/subnet-evm v0.8.1-db-metrics-fix h1:hESwxfeJQTI0FtQYP3/npWGh+4ifj5I3ehYcqzE41zI= github.com/ava-labs/subnet-evm v0.8.1-db-metrics-fix/go.mod h1:7Jypx176jtNk7Yzz8upQ2K9lcIUp2QaVVudUiWj/L1s= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= @@ -197,6 +201,7 @@ github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127 h1:qwcF+vdFrvPSEUDSX5R github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127/go.mod h1:QMWlm50DNe14hD7t24KEqZuUdC9sOTy8W6XbCU1mlw4= github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y= github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8aVqWbuLRMHItjPUyqdj+HWPvnQe8V8y1nDpIbM= +github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= diff --git a/node/node.go b/node/node.go index 2bf4e09058f4..e847a6515a6b 100644 --- a/node/node.go +++ b/node/node.go @@ -86,7 +86,7 @@ import ( databasefactory "github.com/ava-labs/avalanchego/database/factory" avmconfig "github.com/ava-labs/avalanchego/vms/avm/config" platformconfig "github.com/ava-labs/avalanchego/vms/platformvm/config" - coreth "github.com/ava-labs/coreth/plugin/factory" + coreth "github.com/ava-labs/coreth/sae/factory" ) const ( diff --git a/utils/constants/vm_ids.go b/utils/constants/vm_ids.go index 949ac93fe1c2..c2aa43afb2cc 100644 --- a/utils/constants/vm_ids.go +++ b/utils/constants/vm_ids.go @@ -19,6 +19,7 @@ var ( EVMID = ids.ID{'e', 'v', 'm'} SubnetEVMID = ids.ID{'s', 'u', 'b', 'n', 'e', 't', 'e', 'v', 'm'} XSVMID = ids.ID{'x', 's', 'v', 'm'} + StrEVMID = ids.ID{'s', 't', 'r', 'e', 'v', 'm'} ) // VMName returns the name of the VM with the provided ID. If a human readable diff --git a/wallet/chain/c/wallet.go b/wallet/chain/c/wallet.go index b03db2126a9d..4b207e5eea2b 100644 --- a/wallet/chain/c/wallet.go +++ b/wallet/chain/c/wallet.go @@ -196,7 +196,7 @@ func (w *wallet) baseFee(options []common.Option) (*big.Int, error) { } ctx := ops.Context() - return w.ethClient.EstimateBaseFee(ctx) + return w.ethClient.SuggestGasPrice(ctx) } // TODO: Upstream this function into coreth. diff --git a/wallet/subnet/primary/examples/add-permissioned-subnet-validator/main.go b/wallet/subnet/primary/examples/add-permissioned-subnet-validator/main.go index c65bc46d633b..4da04df4e43b 100644 --- a/wallet/subnet/primary/examples/add-permissioned-subnet-validator/main.go +++ b/wallet/subnet/primary/examples/add-permissioned-subnet-validator/main.go @@ -21,7 +21,7 @@ func main() { key := genesis.EWOQKey uri := primary.LocalAPIURI kc := secp256k1fx.NewKeychain(key) - subnetIDStr := "29uVeLPJB1eQJkzRemU8g8wZDw5uJRqpab5U2mX9euieVwiEbL" + subnetIDStr := "BKBZ6xXTnT86B4L5fp8rvtcmNSpvtNz8En9jG61ywV2uWyeHy" startTime := time.Now().Add(time.Minute) duration := 2 * 7 * 24 * time.Hour // 2 weeks weight := units.Schmeckle diff --git a/wallet/subnet/primary/examples/create-chain/main.go b/wallet/subnet/primary/examples/create-chain/main.go index 7664a45325bc..4cdd99165f45 100644 --- a/wallet/subnet/primary/examples/create-chain/main.go +++ b/wallet/subnet/primary/examples/create-chain/main.go @@ -5,44 +5,52 @@ package main import ( "context" + "encoding/json" "log" - "math" + "math/big" "time" + "github.com/ava-labs/coreth/core" + "github.com/ava-labs/coreth/params" + "github.com/ava-labs/libevm/core/types" + "github.com/ava-labs/libevm/crypto" + "github.com/holiman/uint256" + "github.com/ava-labs/avalanchego/genesis" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/vms/secp256k1fx" "github.com/ava-labs/avalanchego/wallet/subnet/primary" - - xsgenesis "github.com/ava-labs/avalanchego/vms/example/xsvm/genesis" ) func main() { key := genesis.EWOQKey uri := primary.LocalAPIURI kc := secp256k1fx.NewKeychain(key) - subnetIDStr := "29uVeLPJB1eQJkzRemU8g8wZDw5uJRqpab5U2mX9euieVwiEbL" - genesis := &xsgenesis.Genesis{ - Timestamp: time.Now().Unix(), - Allocations: []xsgenesis.Allocation{ - { - Address: genesis.EWOQKey.Address(), - Balance: math.MaxUint64, + subnetIDStr := "BKBZ6xXTnT86B4L5fp8rvtcmNSpvtNz8En9jG61ywV2uWyeHy" + + eoa := crypto.PubkeyToAddress(*key.PublicKey().ToECDSA()) + genesis := &core.Genesis{ + Config: params.TestChainConfig, + Timestamp: 1749420951, + Difficulty: big.NewInt(0), // required by geth + Alloc: types.GenesisAlloc{ + eoa: { + Balance: new(uint256.Int).Not(uint256.NewInt(0)).ToBig(), }, }, } - vmID := constants.XSVMID - name := "let there" - - subnetID, err := ids.FromString(subnetIDStr) + genesisBytes, err := json.Marshal(genesis) if err != nil { - log.Fatalf("failed to parse subnet ID: %s\n", err) + log.Fatalf("failed to marshal genesis: %s\n", err) } - genesisBytes, err := xsgenesis.Codec.Marshal(xsgenesis.CodecVersion, genesis) + vmID := constants.StrEVMID + name := "gofast" + + subnetID, err := ids.FromString(subnetIDStr) if err != nil { - log.Fatalf("failed to create genesis bytes: %s\n", err) + log.Fatalf("failed to parse subnet ID: %s\n", err) } ctx := context.Background() diff --git a/wallet/subnet/primary/examples/spam-evm/main.go b/wallet/subnet/primary/examples/spam-evm/main.go new file mode 100644 index 000000000000..36df7daad6ac --- /dev/null +++ b/wallet/subnet/primary/examples/spam-evm/main.go @@ -0,0 +1,89 @@ +// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +package main + +import ( + "context" + "errors" + "log" + "math/big" + "time" + + "github.com/ava-labs/libevm/core/types" + "github.com/ava-labs/libevm/crypto" + "github.com/ava-labs/libevm/ethclient" + "github.com/ava-labs/libevm/params" + + "github.com/ava-labs/avalanchego/genesis" + "github.com/ava-labs/avalanchego/wallet/subnet/primary" + + ethereum "github.com/ava-labs/libevm" +) + +// maxFeePerGas is the fee that transactions issued by this test will pay. +const maxFeePerGas = 1000 * params.GWei + +var gasPrice = big.NewInt(maxFeePerGas) + +func main() { + ctx := context.Background() + const ( + chainUUID = "C" + uri = primary.LocalAPIURI + "/ext/bc/" + chainUUID + "/rpc" + ) + c, err := ethclient.DialContext(ctx, uri) + if err != nil { + log.Fatal(err) + } + + chainID, err := c.ChainID(ctx) + if err != nil { + log.Fatal(err) + } + signer := types.NewLondonSigner(chainID) + + key := genesis.EWOQKey + ecdsaKey := key.ToECDSA() + eoa := crypto.PubkeyToAddress(ecdsaKey.PublicKey) + nonce, err := c.NonceAt(context.Background(), eoa, nil) + if err != nil { + log.Fatal(err) + } + + for { + tx := types.NewTx(&types.LegacyTx{ + Nonce: nonce, + GasPrice: gasPrice, + Gas: 1_000_000, // params.TxGas, + To: &eoa, + }) + + tx, err = types.SignTx(tx, signer, ecdsaKey) + if err != nil { + log.Fatal(err) + } + + txHash := tx.Hash() + log.Printf("sending tx %s with nonce %d\n", txHash, nonce) + + err = c.SendTransaction(ctx, tx) + if err != nil { + log.Fatal(err) + } + + for { + _, err = c.TransactionReceipt(ctx, txHash) + if err == nil { + break // Transaction was confirmed + } + if !errors.Is(err, ethereum.NotFound) { + log.Fatal(err) // Unexpected error + } + + time.Sleep(100 * time.Millisecond) + } + + nonce++ + } +} diff --git a/wallet/subnet/primary/wallet.go b/wallet/subnet/primary/wallet.go index 52951121c328..00f020075f0e 100644 --- a/wallet/subnet/primary/wallet.go +++ b/wallet/subnet/primary/wallet.go @@ -5,6 +5,7 @@ package primary import ( "context" + "fmt" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/utils/constants" @@ -88,18 +89,18 @@ func MakeWallet( avaxAddrs := avaxKeychain.Addresses() avaxState, err := FetchState(ctx, uri, avaxAddrs) if err != nil { - return nil, err + return nil, fmt.Errorf("fetching avax state: %w", err) } ethAddrs := ethKeychain.EthAddresses() ethState, err := FetchEthState(ctx, uri, ethAddrs) if err != nil { - return nil, err + return nil, fmt.Errorf("fetching eth state: %w", err) } owners, err := platformvm.GetOwners(avaxState.PClient, ctx, config.SubnetIDs, config.ValidationIDs) if err != nil { - return nil, err + return nil, fmt.Errorf("fetching p-chain owners: %w", err) } pUTXOs := common.NewChainUTXOs(constants.PlatformChainID, avaxState.UTXOs)