Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.

Commit 73cd6e3

Browse files
author
Darioush Jalali
authored
avoid import of params from plugin/evm/atomic (#743)
1 parent 6493558 commit 73cd6e3

File tree

7 files changed

+25
-20
lines changed

7 files changed

+25
-20
lines changed

params/avalanche_params.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package params
66
import (
77
"math/big"
88

9-
"github.com/ava-labs/avalanchego/utils/units"
109
"github.com/ava-labs/coreth/predicate"
1110
)
1211

@@ -17,8 +16,6 @@ const (
1716
LaunchMinGasPrice int64 = 470 * GWei
1817
ApricotPhase1MinGasPrice int64 = 225 * GWei
1918

20-
AvalancheAtomicTxFee = units.MilliAvax
21-
2219
ApricotPhase1GasLimit uint64 = 8_000_000
2320
CortinaGasLimit uint64 = 15_000_000
2421

@@ -37,9 +34,6 @@ const (
3734
// After Durango, the extra data past the dynamic fee rollup window represents predicate results.
3835
DynamicFeeExtraDataSize = predicate.DynamicFeeExtraDataSize
3936
RollupWindow uint64 = 10
40-
41-
// The base cost to charge per atomic transaction. Added in Apricot Phase 5.
42-
AtomicTxBaseCost uint64 = 10_000
4337
)
4438

4539
// The atomic gas limit specifies the maximum amount of gas that can be consumed by the atomic

plugin/evm/atomic/export_tx.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"fmt"
1010
"math/big"
1111

12-
"github.com/ava-labs/coreth/params"
1312
"github.com/ava-labs/coreth/params/extras"
1413
"github.com/holiman/uint256"
1514

@@ -143,7 +142,7 @@ func (utx *UnsignedExportTx) GasUsed(fixedFee bool) (uint64, error) {
143142
return 0, err
144143
}
145144
if fixedFee {
146-
cost, err = math.Add64(cost, params.AtomicTxBaseCost)
145+
cost, err = math.Add64(cost, AtomicTxBaseCost)
147146
if err != nil {
148147
return 0, err
149148
}
@@ -208,7 +207,7 @@ func (utx *UnsignedExportTx) SemanticVerify(
208207
fc.Produce(ctx.AVAXAssetID, txFee)
209208
// Apply fees to export transactions before Apricot Phase 3
210209
default:
211-
fc.Produce(ctx.AVAXAssetID, params.AvalancheAtomicTxFee)
210+
fc.Produce(ctx.AVAXAssetID, AvalancheAtomicTxFee)
212211
}
213212
for _, out := range utx.ExportedOutputs {
214213
fc.Produce(out.AssetID(), out.Output().Amount())
@@ -347,7 +346,7 @@ func NewExportTx(
347346
avaxIns, avaxSigners, err = GetSpendableAVAXWithFee(ctx, state, keys, avaxNeeded, cost, baseFee)
348347
default:
349348
var newAvaxNeeded uint64
350-
newAvaxNeeded, err = math.Add64(avaxNeeded, params.AvalancheAtomicTxFee)
349+
newAvaxNeeded, err = math.Add64(avaxNeeded, AvalancheAtomicTxFee)
351350
if err != nil {
352351
return nil, errOverflowExport
353352
}

plugin/evm/atomic/import_tx.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"math/big"
1111
"slices"
1212

13-
"github.com/ava-labs/coreth/params"
1413
"github.com/ava-labs/coreth/params/extras"
1514
"github.com/holiman/uint256"
1615

@@ -151,7 +150,7 @@ func (utx *UnsignedImportTx) GasUsed(fixedFee bool) (uint64, error) {
151150
}
152151
}
153152
if fixedFee {
154-
cost, err = math.Add64(cost, params.AtomicTxBaseCost)
153+
cost, err = math.Add64(cost, AtomicTxBaseCost)
155154
if err != nil {
156155
return 0, err
157156
}
@@ -216,7 +215,7 @@ func (utx *UnsignedImportTx) SemanticVerify(
216215

217216
// Apply fees to import transactions as of Apricot Phase 2
218217
case rules.IsApricotPhase2:
219-
fc.Produce(ctx.AVAXAssetID, params.AvalancheAtomicTxFee)
218+
fc.Produce(ctx.AVAXAssetID, AvalancheAtomicTxFee)
220219
}
221220
for _, out := range utx.Outs {
222221
fc.Produce(out.AssetID, out.Amount)
@@ -378,8 +377,8 @@ func NewImportTx(
378377
return nil, err
379378
}
380379
case rules.IsApricotPhase2:
381-
txFeeWithoutChange = params.AvalancheAtomicTxFee
382-
txFeeWithChange = params.AvalancheAtomicTxFee
380+
txFeeWithoutChange = AvalancheAtomicTxFee
381+
txFeeWithChange = AvalancheAtomicTxFee
383382
}
384383

385384
// AVAX output

plugin/evm/atomic/params.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// (c) 2025 Ava Labs, Inc. All rights reserved.
2+
// See the file LICENSE for licensing terms.
3+
4+
package atomic
5+
6+
import "github.com/ava-labs/avalanchego/utils/units"
7+
8+
const (
9+
AvalancheAtomicTxFee = units.MilliAvax
10+
11+
// The base cost to charge per atomic transaction. Added in Apricot Phase 5.
12+
AtomicTxBaseCost uint64 = 10_000
13+
)

plugin/evm/import_tx_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func TestImportTxVerify(t *testing.T) {
105105
Outs: []atomic.EVMOutput{
106106
{
107107
Address: testEthAddrs[0],
108-
Amount: importAmount - params.AvalancheAtomicTxFee,
108+
Amount: importAmount - atomic.AvalancheAtomicTxFee,
109109
AssetID: ctx.AVAXAssetID,
110110
},
111111
{

plugin/evm/imports_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ func TestMustNotImport(t *testing.T) {
5454
// Importing these packages configures libevm globally and it is not
5555
// possible to do so for both coreth and subnet-evm, where the client may
5656
// wish to connect to multiple chains.
57-
"plugin/evm/atomic": {"core", "core/vm"},
58-
"plugin/evm/client": {"core", "core/vm"},
59-
"plugin/evm/config": {"core", "core/vm"},
57+
"plugin/evm/atomic": {"core", "core/vm", "params"},
58+
"plugin/evm/client": {"core", "core/vm", "params"},
59+
"plugin/evm/config": {"core", "core/vm", "params"},
6060
}
6161

6262
for packageName, forbiddenImports := range mustNotImport {

plugin/evm/vm_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ func TestIssueAtomicTxs(t *testing.T) {
644644
t.Fatal("Expected logs to be non-nil")
645645
}
646646

647-
exportTx, err := vm.newExportTx(vm.ctx.AVAXAssetID, importAmount-(2*params.AvalancheAtomicTxFee), vm.ctx.XChainID, testShortIDAddrs[0], initialBaseFee, []*secp256k1.PrivateKey{testKeys[0]})
647+
exportTx, err := vm.newExportTx(vm.ctx.AVAXAssetID, importAmount-(2*atomic.AvalancheAtomicTxFee), vm.ctx.XChainID, testShortIDAddrs[0], initialBaseFee, []*secp256k1.PrivateKey{testKeys[0]})
648648
if err != nil {
649649
t.Fatal(err)
650650
}

0 commit comments

Comments
 (0)