Skip to content

Commit

Permalink
upgrade deps (decred#2926)
Browse files Browse the repository at this point in the history
* clean up old ethereum les wallet code

We couldn't build with Go 1.23 because a dependency was using
//go:linkname in a way that is now restricted.

* update golanci-lint and go-ethereum
  • Loading branch information
buck54321 authored Aug 22, 2024
1 parent 4a33a2a commit 6449ec9
Show file tree
Hide file tree
Showing 32 changed files with 601 additions and 1,788 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: ['1.20', '1.21']
go: ['1.22', '1.23']
steps:
- uses: awalsh128/cache-apt-pkgs-action@1850ee53f6e706525805321a3f2f863dcf73c962 #v1.3.0
- uses: awalsh128/cache-apt-pkgs-action@a6c3917cc929dd0345bfb2d3feaf9101823370ad #v1.4.2
with:
packages: git-restore-mtime libgtk-3-dev libwebkit2gtk-4.0-dev
version: 1.0

- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe #v4.1.0
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 #v5.0.2
with:
go-version: ${{ matrix.go }}

- name: Check out source
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac #v4.0.0
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7
with:
fetch-depth: 0
# Restore original file modification times for test cache reasons
- name: restore timestamps
run: git restore-mtime
- name: Install Linters
run: "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2"
run: "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.60.2"
- name: Use test and module cache
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #v3.3.2
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 #v4.0.2
with:
path: |
~/.cache/go-build
Expand All @@ -52,9 +52,9 @@ jobs:
matrix:
node-version: [18.x, 20.x]
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac #v4.0.0
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7
- name: Use nodejs ${{ matrix.node-version }}
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d #v3.8.1
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b #v4.0.3
with:
node-version: ${{ matrix.node-version }}
- name: npm clean-install
Expand All @@ -71,8 +71,8 @@ jobs:
name: Lint Markdown
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac #v4.0.0
- uses: DavidAnson/markdownlint-cli2-action@3aaa38e446fbd2c288af4291aa0f55d64651050f #v12.0.0
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7
- uses: DavidAnson/markdownlint-cli2-action@b4c9feab76d8025d1e83c653fa3990936df0e6c8 #v16.0.0
continue-on-error: true
with:
globs: |
Expand Down
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ run:
deadline: 10m

output:
format: github-actions,colored-line-number
formats: colored-line-number

linters:
disable-all: true
enable:
- asciicheck
- bidichk
- durationcheck
- exportloopref
- gofmt
- goimports
- gosimple
Expand Down
2 changes: 1 addition & 1 deletion client/asset/btc/btc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1885,7 +1885,7 @@ func rpcFeeRate(ctx context.Context, rr RawRequester, confTarget uint64) (uint64
}

if len(feeResult.Errors) > 0 {
return 0, fmt.Errorf(strings.Join(feeResult.Errors, "; "))
return 0, errors.New(strings.Join(feeResult.Errors, "; "))
}
if feeResult.FeeRate == nil {
return 0, fmt.Errorf("no fee rate available")
Expand Down
3 changes: 1 addition & 2 deletions client/asset/btc/redemption_finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,8 @@ func (r *RedemptionFinder) tryRedemptionRequests(ctx context.Context, startBlock
}

epicFail := func(s string, a ...any) {
errMsg := fmt.Sprintf(s, a...)
for _, req := range reqs {
req.fail(errMsg)
req.fail(s, a...)
}
}

Expand Down
5 changes: 2 additions & 3 deletions client/asset/eth/chaincfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"decred.org/dcrdex/dex"
dexeth "decred.org/dcrdex/dex/networks/eth"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
ethcore "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/params"
Expand Down Expand Up @@ -100,9 +99,9 @@ func ETHConfig(net dex.Network) (c ethconfig.Config, err error) {
switch net {
// Ethereum
case dex.Mainnet:
c.Genesis = core.DefaultGenesisBlock()
c.Genesis = ethcore.DefaultGenesisBlock()
case dex.Testnet:
c.Genesis = core.DefaultSepoliaGenesisBlock()
c.Genesis = ethcore.DefaultSepoliaGenesisBlock()
case dex.Simnet:
c.Genesis, err = readSimnetGenesisFile()
if err != nil {
Expand Down
43 changes: 41 additions & 2 deletions client/asset/eth/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ const (
stateUpdateTick = time.Second * 5
// maxUnindexedTxs is the number of pending txs we will allow to be
// unverified on-chain before we halt broadcasting of new txs.
maxUnindexedTxs = 10
peerCountTicker = 5 * time.Second // no rpc calls here
maxUnindexedTxs = 10
peerCountTicker = 5 * time.Second // no rpc calls here
contractVersionNewest = ^uint32(0)
)

var (
Expand Down Expand Up @@ -6091,3 +6092,41 @@ func getGasEstimates(ctx context.Context, cl, acl ethFetcher, c contractor, ac t

return nil
}

// newTxOpts is a constructor for a TransactOpts.
func newTxOpts(ctx context.Context, from common.Address, val, maxGas uint64, maxFeeRate, gasTipCap *big.Int) *bind.TransactOpts {
// We'll enforce dexeth.MinGasTipCap since the server does, but this isn't
// necessarily a constant for all networks or under all conditions.
minGasWei := dexeth.GweiToWei(dexeth.MinGasTipCap)
if gasTipCap.Cmp(minGasWei) < 0 {
gasTipCap.Set(minGasWei)
}
// This is enforced by concensus. We shouldn't be able to get here with a
// swap tx.
if gasTipCap.Cmp(maxFeeRate) > 0 {
gasTipCap.Set(maxFeeRate)
}
return &bind.TransactOpts{
Context: ctx,
From: from,
Value: dexeth.GweiToWei(val),
GasFeeCap: maxFeeRate,
GasTipCap: gasTipCap,
GasLimit: maxGas,
}
}

func gases(contractVer uint32, versionedGases map[uint32]*dexeth.Gases) *dexeth.Gases {
if contractVer != contractVersionNewest {
return versionedGases[contractVer]
}
var bestVer uint32
var bestGases *dexeth.Gases
for ver, gases := range versionedGases {
if ver >= bestVer {
bestGases = gases
bestVer = ver
}
}
return bestGases
}
9 changes: 7 additions & 2 deletions client/asset/eth/multirpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ import (
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus/misc"
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
"github.com/ethereum/go-ethereum/core/txpool"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rpc"
Expand Down Expand Up @@ -72,6 +73,10 @@ var (
// when given an HTTP(S) provider URL. Can be disabled for testing
// ((*MRPCTest).TestRPC).
forceTryWS = true
// https://github.com/ethereum/go-ethereum/blob/16341e05636fd088aa04a27fca6dc5cda5dbab8f/eth/backend.go#L110-L113
// ultimately results in a minimum fee rate by the filter applied at
// https://github.com/ethereum/go-ethereum/blob/4ebeca19d739a243dc0549bcaf014946cde95c4f/core/tx_pool.go#L626
minGasPrice = ethconfig.Defaults.Miner.GasPrice
)

// TODO: Handle rate limiting? From the docs:
Expand Down Expand Up @@ -1428,7 +1433,7 @@ func (m *multiRPCClient) currentFees(ctx context.Context) (baseFees, tipCap *big
return err
}

baseFees = misc.CalcBaseFee(m.cfg, hdr)
baseFees = eip1559.CalcBaseFee(m.cfg, hdr)

if baseFees.Cmp(minGasPrice) < 0 {
baseFees.Set(minGasPrice)
Expand Down
6 changes: 3 additions & 3 deletions client/asset/eth/multirpc_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"decred.org/dcrdex/dex/encode"
dexeth "decred.org/dcrdex/dex/networks/eth"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus/misc"
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
"github.com/ethereum/go-ethereum/params"
)

Expand Down Expand Up @@ -362,7 +362,7 @@ func (m *MRPCTest) FeeHistory(t *testing.T, net dex.Network, blockTimeSecs, days

tipHeight := tip.Number.Uint64()

baseFees := misc.CalcBaseFee(cl.cfg, tip)
baseFees := eip1559.CalcBaseFee(cl.cfg, tip)

fmt.Printf("##### Tip = %d \n", tipHeight)
fmt.Printf("##### Current base fees: %s \n", fmtFee(baseFees))
Expand All @@ -383,7 +383,7 @@ func (m *MRPCTest) FeeHistory(t *testing.T, net dex.Network, blockTimeSecs, days
fmt.Println("nil base fees for height", height)
continue
}
baseFees = misc.CalcBaseFee(cl.cfg, hdr)
baseFees = eip1559.CalcBaseFee(cl.cfg, hdr)
fmt.Printf("##### Base fees height %d @ %s: %s \n", height, time.Unix(int64(hdr.Time), 0), fmtFee(baseFees))
}
})
Expand Down
Loading

0 comments on commit 6449ec9

Please sign in to comment.