diff --git a/plugin/evm/export_tx.go b/plugin/evm/export_tx.go index bf0a1b2af4..278ca99c1b 100644 --- a/plugin/evm/export_tx.go +++ b/plugin/evm/export_tx.go @@ -16,7 +16,7 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/utils" - "github.com/ava-labs/avalanchego/utils/constants" + "github.com/ava-labs/avalanchego/utils/constant" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" "github.com/ava-labs/avalanchego/utils/math" "github.com/ava-labs/avalanchego/utils/set" @@ -108,7 +108,7 @@ func (utx *UnsignedExportTx) Verify( return err } assetID := out.AssetID() - if assetID != ctx.AVAXAssetID && utx.DestinationChain == constants.PlatformChainID { + if assetID != ctx.AVAXAssetID && utx.DestinationChain == constant.PlatformChainID { return errWrongChainID } if rules.IsBanff && assetID != ctx.AVAXAssetID { diff --git a/plugin/evm/export_tx_test.go b/plugin/evm/export_tx_test.go index 319831c7d7..afa3ed039b 100644 --- a/plugin/evm/export_tx_test.go +++ b/plugin/evm/export_tx_test.go @@ -12,13 +12,14 @@ import ( "github.com/ava-labs/avalanchego/chains/atomic" "github.com/ava-labs/avalanchego/ids" engCommon "github.com/ava-labs/avalanchego/snow/engine/common" - "github.com/ava-labs/avalanchego/utils/constants" + "github.com/ava-labs/avalanchego/utils/constant" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" "github.com/ava-labs/avalanchego/utils/units" "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/secp256k1fx" - "github.com/ava-labs/coreth/params" "github.com/ethereum/go-ethereum/common" + + "github.com/ava-labs/coreth/params" ) // createExportTxOptions adds funds to shared memory, imports them, and returns a list of export transactions @@ -544,7 +545,7 @@ func TestExportTxSemanticVerify(t *testing.T) { name: "P-chain before AP5", tx: func() *Tx { validExportTx := *validAVAXExportTx - validExportTx.DestinationChain = constants.PlatformChainID + validExportTx.DestinationChain = constant.PlatformChainID return &Tx{UnsignedAtomicTx: &validExportTx} }(), signers: [][]*secp256k1.PrivateKey{ @@ -558,7 +559,7 @@ func TestExportTxSemanticVerify(t *testing.T) { name: "P-chain after AP5", tx: func() *Tx { validExportTx := *validAVAXExportTx - validExportTx.DestinationChain = constants.PlatformChainID + validExportTx.DestinationChain = constant.PlatformChainID return &Tx{UnsignedAtomicTx: &validExportTx} }(), signers: [][]*secp256k1.PrivateKey{ @@ -586,7 +587,7 @@ func TestExportTxSemanticVerify(t *testing.T) { name: "P-chain multi-coin before AP5", tx: func() *Tx { validExportTx := *validExportTx - validExportTx.DestinationChain = constants.PlatformChainID + validExportTx.DestinationChain = constant.PlatformChainID return &Tx{UnsignedAtomicTx: &validExportTx} }(), signers: [][]*secp256k1.PrivateKey{ @@ -602,7 +603,7 @@ func TestExportTxSemanticVerify(t *testing.T) { name: "P-chain multi-coin after AP5", tx: func() *Tx { validExportTx := *validExportTx - validExportTx.DestinationChain = constants.PlatformChainID + validExportTx.DestinationChain = constant.PlatformChainID return &Tx{UnsignedAtomicTx: &validExportTx} }(), signers: [][]*secp256k1.PrivateKey{ diff --git a/plugin/evm/formatting.go b/plugin/evm/formatting.go index ba9cea589f..816415d60c 100644 --- a/plugin/evm/formatting.go +++ b/plugin/evm/formatting.go @@ -6,12 +6,13 @@ package evm import ( "fmt" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/utils/constants" + "github.com/ava-labs/avalanchego/utils/constant" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" "github.com/ava-labs/avalanchego/utils/formatting/address" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" ) // ParseServiceAddress get address ID from address string, being it either localized (using address manager, @@ -50,7 +51,7 @@ func (vm *VM) FormatAddress(chainID ids.ID, addr ids.ShortID) (string, error) { if err != nil { return "", err } - hrp := constants.GetHRP(vm.ctx.NetworkID) + hrp := constant.GetHRP(vm.ctx.NetworkID) return address.Format(chainIDAlias, hrp, addr.Bytes()) } diff --git a/plugin/evm/import_tx_test.go b/plugin/evm/import_tx_test.go index ddcde4a879..b785f757b8 100644 --- a/plugin/evm/import_tx_test.go +++ b/plugin/evm/import_tx_test.go @@ -7,13 +7,14 @@ import ( "math/big" "testing" - "github.com/ava-labs/coreth/params" "github.com/ethereum/go-ethereum/common" + "github.com/ava-labs/coreth/params" + "github.com/ava-labs/avalanchego/chains/atomic" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/utils" - "github.com/ava-labs/avalanchego/utils/constants" + "github.com/ava-labs/avalanchego/utils/constant" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/vms/components/avax" @@ -167,7 +168,7 @@ func TestImportTxVerify(t *testing.T) { "P-chain source before AP5": { generate: func(t *testing.T) UnsignedAtomicTx { tx := *importTx - tx.SourceChain = constants.PlatformChainID + tx.SourceChain = constant.PlatformChainID return &tx }, ctx: ctx, @@ -177,7 +178,7 @@ func TestImportTxVerify(t *testing.T) { "P-chain source after AP5": { generate: func(t *testing.T) UnsignedAtomicTx { tx := *importTx - tx.SourceChain = constants.PlatformChainID + tx.SourceChain = constant.PlatformChainID return &tx }, ctx: ctx, diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index a62245587d..1fea3d98da 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -17,6 +17,7 @@ import ( "time" avalanchegoMetrics "github.com/ava-labs/avalanchego/api/metrics" + "github.com/ava-labs/avalanchego/utils/constant" "github.com/ava-labs/coreth/consensus/dummy" corethConstants "github.com/ava-labs/coreth/constants" @@ -71,7 +72,6 @@ import ( "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/snow/engine/snowman/block" - "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" "github.com/ava-labs/avalanchego/utils/formatting/address" "github.com/ava-labs/avalanchego/utils/logging" @@ -1288,7 +1288,7 @@ func (vm *VM) ParseAddress(addrStr string) (ids.ID, ids.ShortID, error) { return ids.ID{}, ids.ShortID{}, err } - expectedHRP := constants.GetHRP(vm.ctx.NetworkID) + expectedHRP := constant.GetHRP(vm.ctx.NetworkID) if hrp != expectedHRP { return ids.ID{}, ids.ShortID{}, fmt.Errorf("expected hrp %q but got %q", expectedHRP, hrp) diff --git a/plugin/evm/vm_test.go b/plugin/evm/vm_test.go index bd3792df26..66e538ac18 100644 --- a/plugin/evm/vm_test.go +++ b/plugin/evm/vm_test.go @@ -43,7 +43,6 @@ import ( "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/validators" "github.com/ava-labs/avalanchego/utils/cb58" - "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" "github.com/ava-labs/avalanchego/utils/formatting" "github.com/ava-labs/avalanchego/utils/hashing" @@ -159,9 +158,9 @@ func NewContext() *snow.Context { ctx.ValidatorState = &validators.TestState{ GetSubnetIDF: func(_ context.Context, chainID ids.ID) (ids.ID, error) { subnetID, ok := map[ids.ID]ids.ID{ - constants.PlatformChainID: constants.PrimaryNetworkID, - testXChainID: constants.PrimaryNetworkID, - testCChainID: constants.PrimaryNetworkID, + constant.PlatformChainID: constant.PrimaryNetworkID, + testXChainID: constant.PrimaryNetworkID, + testCChainID: constant.PrimaryNetworkID, }[chainID] if !ok { return ids.Empty, errors.New("unknown chain")