Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 4 additions & 5 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: '~1.21.7'
check-latest: true
go-version-file: 'go.mod'
- name: Run static analysis tests
shell: bash
run: scripts/lint.sh
Expand All @@ -38,7 +37,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-14]
os: [ubuntu-22.04, macos-14]
steps:
- name: Git checkout
uses: actions/checkout@v3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ permissions:

jobs:
release:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Git checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
path: avalanche-network-runner
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: '~1.21.7'
go-version-file: 'go.mod'
- name: Set up arm64 cross compiler
run: |
sudo apt-get -y update
Expand Down
3 changes: 2 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# https://golangci-lint.run/usage/configuration/
run:
go: "1.24.7"
timeout: 10m

issues:
Expand All @@ -19,7 +20,7 @@ linters:
- depguard
- errcheck
- errorlint
- exportloopref
- copyloopvar
- goconst
- gocritic
- gofmt
Expand Down
31 changes: 16 additions & 15 deletions api/eth_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (
"math/big"
"sync"

"github.com/ava-labs/coreth/core/types"
"github.com/ava-labs/coreth/ethclient"
"github.com/ava-labs/coreth/interfaces"
"github.com/ethereum/go-ethereum/common"
ethereum "github.com/ava-labs/libevm"
"github.com/ava-labs/libevm/common"
"github.com/ava-labs/libevm/core/types"
)

// Interface compliance
Expand All @@ -23,18 +24,18 @@ type EthClient interface {
BlockByNumber(context.Context, *big.Int) (*types.Block, error)
BlockByHash(context.Context, common.Hash) (*types.Block, error)
BlockNumber(context.Context) (uint64, error)
CallContract(context.Context, interfaces.CallMsg, *big.Int) ([]byte, error)
CallContract(context.Context, ethereum.CallMsg, *big.Int) ([]byte, error)
NonceAt(context.Context, common.Address, *big.Int) (uint64, error)
SuggestGasPrice(context.Context) (*big.Int, error)
AcceptedCodeAt(context.Context, common.Address) ([]byte, error)
AcceptedNonceAt(context.Context, common.Address) (uint64, error)
CodeAt(context.Context, common.Address, *big.Int) ([]byte, error)
EstimateGas(context.Context, interfaces.CallMsg) (uint64, error)
AcceptedCallContract(context.Context, interfaces.CallMsg) ([]byte, error)
EstimateGas(context.Context, ethereum.CallMsg) (uint64, error)
AcceptedCallContract(context.Context, ethereum.CallMsg) ([]byte, error)
HeaderByNumber(context.Context, *big.Int) (*types.Header, error)
SuggestGasTipCap(context.Context) (*big.Int, error)
FilterLogs(context.Context, interfaces.FilterQuery) ([]types.Log, error)
SubscribeFilterLogs(context.Context, interfaces.FilterQuery, chan<- types.Log) (interfaces.Subscription, error)
FilterLogs(context.Context, ethereum.FilterQuery) ([]types.Log, error)
SubscribeFilterLogs(context.Context, ethereum.FilterQuery, chan<- types.Log) (interfaces.Subscription, error)
}

// ethClient websocket ethclient.Client with mutexed api calls and lazy conn (on first call)
Expand All @@ -43,7 +44,7 @@ type ethClient struct {
ipAddr string
chainID string
port uint
client ethclient.Client
client *ethclient.Client
lock sync.Mutex
}

Expand All @@ -67,7 +68,7 @@ func NewEthClientWithChainID(ipAddr string, port uint, chainID string) EthClient

// connect attempts to connect with websocket ethclient API
func (c *ethClient) connect() error {
if c.client == ethclient.Client(nil) {
if c.client == nil {
client, err := ethclient.Dial(fmt.Sprintf("ws://%s:%d/ext/bc/%s/ws", c.ipAddr, c.port, c.chainID))
if err != nil {
return err
Expand All @@ -79,7 +80,7 @@ func (c *ethClient) connect() error {

// Close closes opened connection (if any)
func (c *ethClient) Close() {
if c.client == ethclient.Client(nil) {
if c.client == nil {
return
}
c.lock.Lock()
Expand Down Expand Up @@ -141,7 +142,7 @@ func (c *ethClient) BlockNumber(ctx context.Context) (uint64, error) {
return c.client.BlockNumber(ctx)
}

func (c *ethClient) CallContract(ctx context.Context, msg interfaces.CallMsg, blockNumber *big.Int) ([]byte, error) {
func (c *ethClient) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error) {
c.lock.Lock()
defer c.lock.Unlock()
if err := c.connect(); err != nil {
Expand Down Expand Up @@ -195,7 +196,7 @@ func (c *ethClient) CodeAt(ctx context.Context, account common.Address, blockNum
return c.client.CodeAt(ctx, account, blockNumber)
}

func (c *ethClient) EstimateGas(ctx context.Context, msg interfaces.CallMsg) (uint64, error) {
func (c *ethClient) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, error) {
c.lock.Lock()
defer c.lock.Unlock()
if err := c.connect(); err != nil {
Expand All @@ -204,7 +205,7 @@ func (c *ethClient) EstimateGas(ctx context.Context, msg interfaces.CallMsg) (ui
return c.client.EstimateGas(ctx, msg)
}

func (c *ethClient) AcceptedCallContract(ctx context.Context, call interfaces.CallMsg) ([]byte, error) {
func (c *ethClient) AcceptedCallContract(ctx context.Context, call ethereum.CallMsg) ([]byte, error) {
c.lock.Lock()
defer c.lock.Unlock()
if err := c.connect(); err != nil {
Expand All @@ -231,7 +232,7 @@ func (c *ethClient) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
return c.client.SuggestGasTipCap(ctx)
}

func (c *ethClient) FilterLogs(ctx context.Context, query interfaces.FilterQuery) ([]types.Log, error) {
func (c *ethClient) FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error) {
c.lock.Lock()
defer c.lock.Unlock()
if err := c.connect(); err != nil {
Expand All @@ -240,7 +241,7 @@ func (c *ethClient) FilterLogs(ctx context.Context, query interfaces.FilterQuery
return c.client.FilterLogs(ctx, query)
}

func (c *ethClient) SubscribeFilterLogs(ctx context.Context, query interfaces.FilterQuery, ch chan<- types.Log) (interfaces.Subscription, error) {
func (c *ethClient) SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (interfaces.Subscription, error) {
c.lock.Lock()
defer c.lock.Unlock()
if err := c.connect(); err != nil {
Expand Down
Loading