aboutsummaryrefslogtreecommitdiff
path: root/plugin/evm
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/evm')
-rw-r--r--plugin/evm/export_tx_test.go2
-rw-r--r--plugin/evm/import_tx_test.go4
-rw-r--r--plugin/evm/tx.go4
-rw-r--r--plugin/evm/user.go5
-rw-r--r--plugin/evm/vm.go29
-rw-r--r--plugin/evm/vm_test.go18
6 files changed, 15 insertions, 47 deletions
diff --git a/plugin/evm/export_tx_test.go b/plugin/evm/export_tx_test.go
index 319c6dd..6fdf3a2 100644
--- a/plugin/evm/export_tx_test.go
+++ b/plugin/evm/export_tx_test.go
@@ -76,7 +76,7 @@ func TestExportTxVerify(t *testing.T) {
// Test Valid Export Tx
if err := exportTx.Verify(testXChainID, ctx, testTxFee, testAvaxAssetID); err != nil {
- t.Fatalf("Failed to verify valid ExportTx: %w", err)
+ t.Fatalf("Failed to verify valid ExportTx: %s", err)
}
exportTx.syntacticallyVerified = false
diff --git a/plugin/evm/import_tx_test.go b/plugin/evm/import_tx_test.go
index 52a8fa7..b0f2875 100644
--- a/plugin/evm/import_tx_test.go
+++ b/plugin/evm/import_tx_test.go
@@ -77,7 +77,7 @@ func TestImportTxVerify(t *testing.T) {
// Test Valid ImportTx
if err := importTx.Verify(testXChainID, ctx, testTxFee, testAvaxAssetID); err != nil {
- t.Fatalf("Failed to verify ImportTx: %w", err)
+ t.Fatalf("Failed to verify ImportTx: %s", err)
}
importTx.syntacticallyVerified = false
@@ -268,7 +268,7 @@ func TestImportTxSemanticVerify(t *testing.T) {
}
if err := unsignedImportTx.Accept(vm.ctx, nil); err != nil {
- t.Fatalf("Accept failed due to: %w", err)
+ t.Fatalf("Accept failed due to: %s", err)
}
if err := unsignedImportTx.EVMStateTransfer(vm, state); err != nil {
diff --git a/plugin/evm/tx.go b/plugin/evm/tx.go
index 3a2f820..e44eefe 100644
--- a/plugin/evm/tx.go
+++ b/plugin/evm/tx.go
@@ -23,10 +23,6 @@ import (
"github.com/ethereum/go-ethereum/common"
)
-// Max size of memo field
-// Don't change without also changing avm.maxMemoSize
-const maxMemoSize = 256
-
var (
errWrongBlockchainID = errors.New("wrong blockchain ID provided")
errWrongNetworkID = errors.New("tx was issued with a different network ID")
diff --git a/plugin/evm/user.go b/plugin/evm/user.go
index 152156d..0ab1863 100644
--- a/plugin/evm/user.go
+++ b/plugin/evm/user.go
@@ -18,9 +18,8 @@ import (
var addressesKey = ids.Empty[:]
var (
- errDBNil = errors.New("db uninitialized")
- errKeyNil = errors.New("key uninitialized")
- errEmptyAddress = errors.New("address is empty")
+ errDBNil = errors.New("db uninitialized")
+ errKeyNil = errors.New("key uninitialized")
)
type user struct {
diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go
index 2ab4028..c191720 100644
--- a/plugin/evm/vm.go
+++ b/plugin/evm/vm.go
@@ -57,10 +57,6 @@ import (
)
var (
- zeroAddr = common.Address{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- }
x2cRate = big.NewInt(1000000000)
)
@@ -83,10 +79,6 @@ const (
bdTimerStateLong
)
-const (
- addressSep = "-"
-)
-
var (
txFee = units.MilliAvax
@@ -99,21 +91,14 @@ var (
errInvalidAddr = errors.New("invalid hex address")
errTooManyAtomicTx = errors.New("too many pending atomic txs")
errAssetIDMismatch = errors.New("asset IDs in the input don't match the utxo")
- errWrongNumberOfCredentials = errors.New("should have the same number of credentials as inputs")
- errNoInputs = errors.New("tx has no inputs")
errNoImportInputs = errors.New("tx has no imported inputs")
errInputsNotSortedUnique = errors.New("inputs not sorted and unique")
errPublicKeySignatureMismatch = errors.New("signature doesn't match public key")
errSignatureInputsMismatch = errors.New("number of inputs does not match number of signatures")
- errUnknownAsset = errors.New("unknown asset ID")
- errNoFunds = errors.New("no spendable funds were found")
errWrongChainID = errors.New("tx has wrong chain ID")
errInsufficientFunds = errors.New("insufficient funds")
errNoExportOutputs = errors.New("tx has no export outputs")
errOutputsNotSorted = errors.New("tx outputs not sorted")
- errNoImportOutputs = errors.New("tx has no outputs to import")
- errNoExportInputs = errors.New("tx has no inputs to export")
- errInputsNotSortedAndUnique = errors.New("inputs not sorted and unique")
errOverflowExport = errors.New("overflow when computing export amount + txFee")
errInvalidNonce = errors.New("invalid nonce")
)
@@ -457,8 +442,8 @@ func (vm *VM) ParseBlock(b []byte) (snowman.Block, error) {
}
blockHash := ethBlock.Hash()
// Coinbase must be zero on C-Chain
- if bytes.Compare(blockHash.Bytes(), vm.genesisHash.Bytes()) != 0 &&
- bytes.Compare(ethBlock.Coinbase().Bytes(), coreth.BlackholeAddr.Bytes()) != 0 {
+ if !bytes.Equal(blockHash.Bytes(), vm.genesisHash.Bytes()) &&
+ !bytes.Equal(ethBlock.Coinbase().Bytes(), coreth.BlackholeAddr.Bytes()) {
return nil, errInvalidBlock
}
block := &Block{
@@ -715,16 +700,6 @@ func (vm *VM) getBlock(id ids.ID) *Block {
return block
}
-func (vm *VM) issueRemoteTxs(txs []*types.Transaction) error {
- errs := vm.chain.AddRemoteTxs(txs)
- for _, err := range errs {
- if err != nil {
- return err
- }
- }
- return vm.tryBlockGen()
-}
-
func (vm *VM) writeBackMetadata() {
vm.metalock.Lock()
defer vm.metalock.Unlock()
diff --git a/plugin/evm/vm_test.go b/plugin/evm/vm_test.go
index 1117d0d..d58fdda 100644
--- a/plugin/evm/vm_test.go
+++ b/plugin/evm/vm_test.go
@@ -27,14 +27,12 @@ var (
testXChainID = ids.ID([32]byte{'t', 'e', 's', 't', 'x'})
nonExistentID = ids.ID([32]byte{'F'})
testTxFee = uint64(1000)
- startBalance = uint64(50000)
testKeys []*crypto.PrivateKeySECP256K1R
testEthAddrs []common.Address // testEthAddrs[i] corresponds to testKeys[i]
testShortIDAddrs []ids.ShortID
- testAvaxAssetID = [32]byte{1, 2, 3}
- username = "Johns"
- password = "CjasdjhiPeirbSenfeI13" // #nosec G101
- ethChainID uint32 = 43112
+ testAvaxAssetID = [32]byte{1, 2, 3}
+ username = "Johns"
+ password = "CjasdjhiPeirbSenfeI13" // #nosec G101
)
func init() {
@@ -63,7 +61,7 @@ func BuildGenesisTest(t *testing.T) []byte {
genesis := &core.Genesis{}
if err := json.Unmarshal([]byte(genesisJSON), genesis); err != nil {
- t.Fatalf("Problem unmarshaling genesis JSON: %w", err)
+ t.Fatalf("Problem unmarshaling genesis JSON: %s", err)
}
genesisReply, err := ss.BuildGenesis(nil, genesis)
if err != nil {
@@ -79,10 +77,10 @@ func NewContext() *snow.Context {
ctx.AVAXAssetID = testAvaxAssetID
ctx.XChainID = ids.Empty.Prefix(0)
aliaser := ctx.BCLookup.(*ids.Aliaser)
- aliaser.Alias(testCChainID, "C")
- aliaser.Alias(testCChainID, testCChainID.String())
- aliaser.Alias(testXChainID, "X")
- aliaser.Alias(testXChainID, testXChainID.String())
+ _ = aliaser.Alias(testCChainID, "C")
+ _ = aliaser.Alias(testCChainID, testCChainID.String())
+ _ = aliaser.Alias(testXChainID, "X")
+ _ = aliaser.Alias(testXChainID, testXChainID.String())
// SNLookup might be required here???
return ctx