diff --git a/packages/testutil/testdbhash/TestStorageContract.hex b/packages/testutil/testdbhash/TestStorageContract.hex index b72ef8ed3b..7c32e48b06 100644 --- a/packages/testutil/testdbhash/TestStorageContract.hex +++ b/packages/testutil/testdbhash/TestStorageContract.hex @@ -1 +1 @@ -0xf7c89a451c83d8d59b4ec7d6904a8421166463bd4b28feeffe3362313b3ee6d4 +0x5c2f4cc322a2c1f4850d1d2c31cbbdd3fbfa92bd64b1a3f3d1e7f608c74ab8b8 diff --git a/packages/vm/core/accounts/impl.go b/packages/vm/core/accounts/impl.go index c51423b47d..2240c213e8 100644 --- a/packages/vm/core/accounts/impl.go +++ b/packages/vm/core/accounts/impl.go @@ -11,7 +11,6 @@ import ( "github.com/iotaledger/wasp/packages/util" "github.com/iotaledger/wasp/packages/vm" "github.com/iotaledger/wasp/packages/vm/core/errors/coreerrors" - "github.com/iotaledger/wasp/packages/vm/core/evm" "github.com/iotaledger/wasp/packages/vm/gas" ) @@ -71,21 +70,7 @@ func deposit(ctx isc.Sandbox) dict.Dict { func transferAllowanceTo(ctx isc.Sandbox) dict.Dict { ctx.Log().Debugf("accounts.transferAllowanceTo.begin -- %s", ctx.AllowanceAvailable()) targetAccount := ctx.Params().MustGetAgentID(ParamAgentID) - allowance := ctx.AllowanceAvailable().Clone() ctx.TransferAllowedFunds(targetAccount) - if targetAccount.Kind() == isc.AgentIDKindEthereumAddress { - evmAcc := targetAccount.(*isc.EthereumAddressAgentID).EthAddress().Bytes() - // issue an "custom" etherum tx so the funds appear on the explorer - ctx.Call( - evm.Contract.Hname(), - evm.FuncNewL1Deposit.Hname(), - dict.Dict{ - evm.FieldAddress: evmAcc, - evm.FieldAssets: allowance.Bytes(), - }, - nil, - ) - } ctx.Log().Debugf("accounts.transferAllowanceTo.success: target: %s\n%s", targetAccount, ctx.AllowanceAvailable()) return nil } diff --git a/packages/vm/core/evm/emulator/blockchaindb.go b/packages/vm/core/evm/emulator/blockchaindb.go index fbe76f9c91..7dea4369af 100644 --- a/packages/vm/core/evm/emulator/blockchaindb.go +++ b/packages/vm/core/evm/emulator/blockchaindb.go @@ -132,7 +132,7 @@ func (bc *BlockchainDB) GetPendingHeader(timestamp uint64) *types.Header { } } -func (bc *BlockchainDB) GetPendingCumulativeGasUsed() uint64 { +func (bc *BlockchainDB) getPendingCumulativeGasUsed() uint64 { blockNumber := bc.GetPendingBlockNumber() receiptArray := bc.getReceiptArray(blockNumber) n := receiptArray.Len() diff --git a/packages/vm/core/evm/emulator/emulator.go b/packages/vm/core/evm/emulator/emulator.go index 67f653b17b..66183c00fd 100644 --- a/packages/vm/core/evm/emulator/emulator.go +++ b/packages/vm/core/evm/emulator/emulator.go @@ -317,7 +317,7 @@ func (e *EVMEmulator) SendTransaction( if result != nil { gasUsed = result.UsedGas } - cumulativeGasUsed := e.BlockchainDB().GetPendingCumulativeGasUsed() + gasUsed + cumulativeGasUsed := e.BlockchainDB().getPendingCumulativeGasUsed() + gasUsed receipt = &types.Receipt{ Type: tx.Type(), diff --git a/packages/vm/core/evm/evmimpl/impl.go b/packages/vm/core/evm/evmimpl/impl.go index b45e0333ff..bce3184720 100644 --- a/packages/vm/core/evm/evmimpl/impl.go +++ b/packages/vm/core/evm/evmimpl/impl.go @@ -40,8 +40,6 @@ var Processor = evm.Contract.Processor(nil, evm.FuncRegisterERC20ExternalNativeToken.WithHandler(registerERC20ExternalNativeToken), evm.FuncRegisterERC721NFTCollection.WithHandler(restricted(registerERC721NFTCollection)), - evm.FuncNewL1Deposit.WithHandler(newL1Deposit), - // views evm.FuncGetERC20ExternalNativeTokenAddress.WithHandler(viewERC20ExternalNativeTokenAddress), evm.FuncGetChainID.WithHandler(getChainID), @@ -437,32 +435,3 @@ func getEVMGasRatio(ctx isc.SandboxBase) util.Ratio32 { gasRatioViewRes := ctx.CallView(governance.Contract.Hname(), governance.ViewGetEVMGasRatio.Hname(), nil) return codec.MustDecodeRatio32(gasRatioViewRes.Get(governance.ParamEVMGasRatio), gas.DefaultEVMGasRatio) } - -func newL1Deposit(ctx isc.Sandbox) dict.Dict { - // can only be called from the accounts contract - ctx.RequireCaller(isc.NewContractAgentID(ctx.ChainID(), accounts.Contract.Hname())) - params := ctx.Params() - addr := common.BytesToAddress(params.MustGetBytes(evm.FieldAddress)) - assets, err := isc.AssetsFromBytes(params.MustGetBytes(evm.FieldAssets)) - ctx.RequireNoError(err, "unable to parse assets from params") - - // create a fake tx so that the deposit is visible by the EVM - value := util.BaseTokensDecimalsToEthereumDecimals(assets.BaseTokens, newEmulatorContext(ctx).BaseTokensDecimals()) - nonce := uint64(0) - tx := types.NewTransaction(nonce, addr, value, 0, util.Big0, assets.Bytes()) - - // create a fake receipt - receipt := &types.Receipt{ - Type: types.LegacyTxType, - CumulativeGasUsed: createBlockchainDB(ctx.State(), ctx.ChainInfo()).GetPendingCumulativeGasUsed(), - GasUsed: 0, - Logs: make([]*types.Log, 0), - } - receipt.Bloom = types.CreateBloom(types.Receipts{receipt}) - - ctx.Privileged().OnWriteReceipt(func(evmPartition kv.KVStore) { - createBlockchainDB(evmPartition, ctx.ChainInfo()).AddTransaction(tx, receipt) - }) - - return nil -} diff --git a/packages/vm/core/evm/evmnames/evmnames.go b/packages/vm/core/evm/evmnames/evmnames.go index 4ccf601c1d..fe505e1054 100644 --- a/packages/vm/core/evm/evmnames/evmnames.go +++ b/packages/vm/core/evm/evmnames/evmnames.go @@ -17,13 +17,10 @@ const ( FuncGetERC20ExternalNativeTokenAddress = "getERC20ExternalNativeTokenAddress" FuncRegisterERC721NFTCollection = "registerERC721NFTCollection" - FuncNewL1Deposit = "newL1Deposit" - FieldTransaction = "t" FieldCallMsg = "c" FieldChainID = "chid" FieldAddress = "a" - FieldAssets = "s" FieldKey = "k" FieldAgentID = "i" FieldTransactionIndex = "ti" diff --git a/packages/vm/core/evm/evmtest/evm_test.go b/packages/vm/core/evm/evmtest/evm_test.go index dd51437fd1..f848bcbf2f 100644 --- a/packages/vm/core/evm/evmtest/evm_test.go +++ b/packages/vm/core/evm/evmtest/evm_test.go @@ -2041,23 +2041,3 @@ func TestEmitEventAndRevert(t *testing.T) { require.ErrorContains(t, err, "execution reverted") require.Empty(t, res.EVMReceipt.Logs) } - -func TestL1DepositEVM(t *testing.T) { - env := InitEVM(t) - // ensure that after a deposit to an EVM account, there is a tx/receipt for it to be auditable on the EVM side - _, ethAddr := env.Chain.NewEthereumAccountWithL2Funds() - bal, err := env.Chain.EVM().Balance(ethAddr, nil) - require.NoError(t, err) - - // previous block must only have 1 tx, that corresponds to the deposit to ethAddr - block, err := env.Chain.EVM().BlockByNumber(big.NewInt(int64(env.getBlockNumber()))) - require.NoError(t, err) - blockTxs := block.Transactions() - require.Len(t, blockTxs, 1) - tx := blockTxs[0] - require.True(t, ethAddr == *tx.To()) - require.Zero(t, tx.Value().Cmp(bal)) - - rec := env.Chain.EVM().TransactionReceipt(tx.Hash()) - require.NotNil(t, rec) -} diff --git a/packages/vm/core/evm/interface.go b/packages/vm/core/evm/interface.go index 69f9cee331..876a4c00b2 100644 --- a/packages/vm/core/evm/interface.go +++ b/packages/vm/core/evm/interface.go @@ -27,8 +27,6 @@ var ( FuncRegisterERC20ExternalNativeToken = coreutil.Func(evmnames.FuncRegisterERC20ExternalNativeToken) FuncGetERC20ExternalNativeTokenAddress = coreutil.ViewFunc(evmnames.FuncGetERC20ExternalNativeTokenAddress) FuncRegisterERC721NFTCollection = coreutil.Func(evmnames.FuncRegisterERC721NFTCollection) - - FuncNewL1Deposit = coreutil.Func(evmnames.FuncNewL1Deposit) ) const ( @@ -36,7 +34,6 @@ const ( FieldCallMsg = evmnames.FieldCallMsg FieldChainID = evmnames.FieldChainID FieldAddress = evmnames.FieldAddress - FieldAssets = evmnames.FieldAssets FieldKey = evmnames.FieldKey FieldAgentID = evmnames.FieldAgentID FieldTransactionIndex = evmnames.FieldTransactionIndex