diff options
author | StephenButtolph <[email protected]> | 2020-08-20 01:09:52 -0400 |
---|---|---|
committer | StephenButtolph <[email protected]> | 2020-08-20 01:09:52 -0400 |
commit | 4e5a71321d1c7024f1108c75ea4e749ce7cbf706 (patch) | |
tree | 9a6eada58cc3d2c08b2874f141eb13fec5090800 /plugin/evm | |
parent | 1c078567367ef45884da079cecc09a71d1761b01 (diff) | |
parent | a054d19f05a31a0421d6fe1bc534da46921481d5 (diff) |
Merge branch 'ecstasy-transfer' of github.com:ava-labs/coreth into ecstasy-transfer
Diffstat (limited to 'plugin/evm')
-rw-r--r-- | plugin/evm/export_tx.go | 2 | ||||
-rw-r--r-- | plugin/evm/vm.go | 11 |
2 files changed, 10 insertions, 3 deletions
diff --git a/plugin/evm/export_tx.go b/plugin/evm/export_tx.go index 423c754..4f47a16 100644 --- a/plugin/evm/export_tx.go +++ b/plugin/evm/export_tx.go @@ -8,6 +8,7 @@ import ( "math/big" "github.com/ava-labs/coreth/core/state" + "github.com/ava-labs/go-ethereum/log" "github.com/ava-labs/gecko/database" "github.com/ava-labs/gecko/ids" @@ -149,6 +150,7 @@ func (vm *VM) newExportTx( func (tx *UnsignedExportTx) EVMStateTransfer(state *state.StateDB) error { for _, from := range tx.Ins { + log.Info("consume", "in", from.Address, "amount", from.Amount, "nonce", from.Nonce, "nonce0", state.GetNonce(from.Address)) amount := new(big.Int).Mul( new(big.Int).SetUint64(from.Amount), x2cRate) if state.GetBalance(from.Address).Cmp(amount) < 0 { diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index f439f59..87487ff 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -246,7 +246,10 @@ func (vm *VM) Initialize( chain.SetOnFinalizeAndAssemble(func(state *state.StateDB, txs []*types.Transaction) ([]byte, error) { select { case atx := <-vm.pendingAtomicTxs: - atx.UnsignedTx.(UnsignedAtomicTx).EVMStateTransfer(state) + if err := atx.UnsignedTx.(UnsignedAtomicTx).EVMStateTransfer(state); err != nil { + vm.newBlockChan <- nil + return nil, err + } raw, _ := vm.codec.Marshal(atx) return raw, nil default: @@ -280,8 +283,7 @@ func (vm *VM) Initialize( return vm.getLastAccepted().ethBlock }) chain.SetOnExtraStateChange(func(block *types.Block, state *state.StateDB) error { - vm.getAtomicTx(block).UnsignedTx.(UnsignedAtomicTx).EVMStateTransfer(state) - return nil + return vm.getAtomicTx(block).UnsignedTx.(UnsignedAtomicTx).EVMStateTransfer(state) }) vm.blockCache = cache.LRU{Size: 2048} vm.blockStatusCache = cache.LRU{Size: 1024} @@ -781,6 +783,9 @@ func (vm *VM) GetSpendableCanonical(keys []*crypto.PrivateKeySECP256K1R, amount } addr := GetEthAddress(key) balance := new(big.Int).Div(state.GetBalance(addr), x2cRate).Uint64() + if balance == 0 { + continue + } if amount < balance { balance = amount } |