Skip to content

Commit

Permalink
Rosetta Etna upgrade - Dynamic fee suggestions (#248)
Browse files Browse the repository at this point in the history
* update to etna fuji rc

* dynamic fee calculation

* CI fix

* lint

* new tx types parsing

* calculate fee in metadata step

* avalanchego 1.12.0

* test fixes

* lint

* lint

* lint

* review changes

* mock fee state

* skip L1 deactivation change utxos

* nits

* go version minor upgrade
  • Loading branch information
rajranjan0608 authored Dec 12, 2024
1 parent 4817571 commit 8cce4b1
Show file tree
Hide file tree
Showing 19 changed files with 445 additions and 210 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@ on:
pull_request:

env:
go_version: '~1.21.7'
go_version: '~1.22.10'

jobs:
Build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions/setup-go@v2
with:
go-version: ${{ env.go_version }}
- run: make build
Test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: ${{ env.go_version }}
- run: make test
Lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: golangci/golangci-lint-action@v2
- uses: actions/checkout@v4
- uses: golangci/golangci-lint-action@v6
with:
version: v1.56.1
version: v1.62.2
check_mockgen:
name: Up-to-date mocks
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ linters-settings:
gosec:
excludes:
- G107 # Url provided to HTTP request as taint input https://securego.io/docs/rules/g107
- G115 # TODO: use typesafe conversion for uint64 -> int64
importas:
# Do not allow unaliased imports of aliased packages.
no-unaliased: false
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ------------------------------------------------------------------------------
# Build avalanche
# ------------------------------------------------------------------------------
FROM golang:1.21.12 AS avalanche
FROM golang:1.22.10 AS avalanche

ARG AVALANCHE_VERSION

Expand All @@ -16,7 +16,7 @@ RUN git checkout $AVALANCHE_VERSION && \
# ------------------------------------------------------------------------------
# Build avalanche rosetta
# ------------------------------------------------------------------------------
FROM golang:1.21.12 AS rosetta
FROM golang:1.22.10 AS rosetta

ARG ROSETTA_VERSION

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ------------------------------------------------------------------------------
# Build avalanche
# ------------------------------------------------------------------------------
FROM arm64v8/golang:1.21.7-bullseye AS avalanche
FROM arm64v8/golang:1.22.10-bullseye AS avalanche

ARG AVALANCHE_VERSION

Expand All @@ -16,7 +16,7 @@ RUN git checkout $AVALANCHE_VERSION && \
# ------------------------------------------------------------------------------
# Build avalanche rosetta
# ------------------------------------------------------------------------------
FROM arm64v8/golang:1.21.7-bullseye AS rosetta
FROM arm64v8/golang:1.22.10-bullseye AS rosetta

ARG ROSETTA_VERSION

Expand Down
2 changes: 1 addition & 1 deletion client/info_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ import (
type InfoClient interface {
GetBlockchainID(context.Context, string, ...rpc.Option) (ids.ID, error)
IsBootstrapped(context.Context, string, ...rpc.Option) (bool, error)
Peers(context.Context, ...rpc.Option) ([]info.Peer, error)
Peers(context.Context, []ids.NodeID, ...rpc.Option) ([]info.Peer, error)
}
44 changes: 34 additions & 10 deletions client/mock_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions client/pchainclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ package client
import (
"context"
"strings"
"time"

"github.com/ava-labs/avalanchego/api"
"github.com/ava-labs/avalanchego/api/info"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/indexer"
"github.com/ava-labs/avalanchego/utils/rpc"
"github.com/ava-labs/avalanchego/vms/avm"
"github.com/ava-labs/avalanchego/vms/components/gas"
"github.com/ava-labs/avalanchego/vms/platformvm"
"github.com/ava-labs/avalanchego/vms/platformvm/signer"

Expand Down Expand Up @@ -61,6 +63,7 @@ type PChainClient interface {
IssueTx(ctx context.Context, tx []byte, options ...rpc.Option) (ids.ID, error)
GetStake(ctx context.Context, addrs []ids.ShortID, validatorsOnly bool, options ...rpc.Option) (map[ids.ID]uint64, [][]byte, error)
GetCurrentValidators(ctx context.Context, subnetID ids.ID, nodeIDs []ids.NodeID, options ...rpc.Option) ([]platformvm.ClientPermissionlessValidator, error)
GetFeeState(ctx context.Context, options ...rpc.Option) (gas.State, gas.Price, time.Time, error)

// avm.Client methods
GetAssetDescription(ctx context.Context, assetID string, options ...rpc.Option) (*avm.GetAssetDescriptionReply, error)
Expand Down
11 changes: 8 additions & 3 deletions constants/network.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package constants

import (
"github.com/ava-labs/avalanchego/upgrade"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/coreth/params"
)

const (
Expand All @@ -16,6 +16,11 @@ const (
)

var (
MainnetAP5Activation = *params.AvalancheMainnetChainConfig.ApricotPhase5BlockTimestamp
FujiAP5Activation = *params.AvalancheFujiChainConfig.ApricotPhase5BlockTimestamp
mainnetUpgrades = upgrade.GetConfig(constants.MainnetID)
fujiUpgrades = upgrade.GetConfig(constants.FujiID)
)

var (
MainnetAP5Activation = uint64(mainnetUpgrades.ApricotPhase5Time.Unix())
FujiAP5Activation = uint64(fujiUpgrades.ApricotPhase5Time.Unix())
)
45 changes: 22 additions & 23 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
module github.com/ava-labs/avalanche-rosetta

go 1.21.12
go 1.22.10

require (
github.com/ava-labs/avalanchego v1.11.9
github.com/ava-labs/coreth v0.13.6-rc.1
github.com/ava-labs/avalanchego v1.12.0
github.com/ava-labs/coreth v0.13.9-rc.1
github.com/coinbase/rosetta-sdk-go v0.6.5
github.com/ethereum/go-ethereum v1.13.8
github.com/stretchr/testify v1.8.4
github.com/ethereum/go-ethereum v1.13.14
github.com/stretchr/testify v1.9.0
go.uber.org/mock v0.4.0
golang.org/x/crypto v0.21.0
golang.org/x/sync v0.6.0
golang.org/x/crypto v0.26.0
golang.org/x/sync v0.8.0
)

require (
Expand All @@ -23,7 +23,7 @@ require (
github.com/btcsuite/btcd/btcutil v1.1.3 // indirect
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cockroachdb/errors v1.9.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 // indirect
Expand All @@ -41,14 +41,13 @@ require (
github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127 // indirect
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect
github.com/getsentry/sentry-go v0.18.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
Expand All @@ -59,11 +58,11 @@ require (
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/gorilla/rpc v1.2.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
github.com/hashicorp/go-bexpr v0.1.10 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 // indirect
github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/klauspost/compress v1.15.15 // indirect
Expand All @@ -82,19 +81,19 @@ require (
github.com/pires/go-proxyproto v0.6.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rs/cors v1.7.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/segmentio/fasthash v1.0.3 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/status-im/keycard-go v0.2.0 // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/supranational/blst v0.3.13 // 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
Expand All @@ -110,18 +109,18 @@ require (
go.opentelemetry.io/otel/sdk v1.22.0 // indirect
go.opentelemetry.io/otel/trace v1.22.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
go.uber.org/multierr v1.10.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/exp v0.0.0-20231127185646-65229373498e // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/time v0.3.0 // indirect
gonum.org/v1/gonum v0.11.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/grpc v1.62.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed // indirect
google.golang.org/grpc v1.66.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit 8cce4b1

Please sign in to comment.