diff --git a/mock/context/outputContextMock.go b/mock/context/outputContextMock.go index 309249cb5..3a8ffcb34 100644 --- a/mock/context/outputContextMock.go +++ b/mock/context/outputContextMock.go @@ -166,6 +166,10 @@ func (o *OutputContextMock) DeleteFirstReturnData() { // WriteLog mocked method func (o *OutputContextMock) WriteLog(_ []byte, _ [][]byte, _ [][]byte) {} +// WriteLogWithIdentifier mocked method +func (o *OutputContextMock) WriteLogWithIdentifier(_ []byte, _ [][]byte, _ [][]byte, _ []byte) { +} + // TransferValueOnly mocked method func (o *OutputContextMock) TransferValueOnly(_ []byte, _ []byte, _ *big.Int, _ bool) error { return o.TransferResult @@ -177,7 +181,7 @@ func (o *OutputContextMock) Transfer(_ []byte, _ []byte, _ uint64, _ uint64, _ * } // TransferESDT mocked method -func (o *OutputContextMock) TransferESDT(transfersArgs *vmhost.ESDTTransfersArgs, _ *vmcommon.ContractCallInput) (uint64, error) { +func (o *OutputContextMock) TransferESDT(_ *vmhost.ESDTTransfersArgs, _ *vmcommon.ContractCallInput) (uint64, error) { return 0, nil } diff --git a/mock/context/outputContextStub.go b/mock/context/outputContextStub.go index 64b1bf8d0..69f416526 100644 --- a/mock/context/outputContextStub.go +++ b/mock/context/outputContextStub.go @@ -24,6 +24,7 @@ type OutputContextStub struct { GetOutputAccountCalled func(address []byte) (*vmcommon.OutputAccount, bool) DeleteOutputAccountCalled func(address []byte) WriteLogCalled func(address []byte, topics [][]byte, data [][]byte) + WriteLogWithIdentifierCalled func(address []byte, topics [][]byte, data [][]byte, identifier []byte) TransferCalled func(destination []byte, sender []byte, gasLimit uint64, gasLocked uint64, value *big.Int, asyncData []byte, input []byte) error TransferESDTCalled func(transfersArgs *vmhost.ESDTTransfersArgs, input *vmcommon.ContractCallInput) (uint64, error) GetRefundCalled func() uint64 @@ -144,6 +145,13 @@ func (o *OutputContextStub) WriteLog(address []byte, topics [][]byte, data [][]b } } +// WriteLogWithIdentifier mocked method +func (o *OutputContextStub) WriteLogWithIdentifier(address []byte, topics [][]byte, data [][]byte, identifier []byte) { + if o.WriteLogWithIdentifierCalled != nil { + o.WriteLogWithIdentifierCalled(address, topics, data, identifier) + } +} + // TransferValueOnly mocked method func (o *OutputContextStub) TransferValueOnly(destination []byte, sender []byte, value *big.Int, checkPayable bool) error { if o.TransferValueOnlyCalled != nil { diff --git a/test/delegation/v0_2/purchase/purchase_buy_1x.scen.json b/test/delegation/v0_2/purchase/purchase_buy_1x.scen.json index a676f8cc7..d9c5dd102 100644 --- a/test/delegation/v0_2/purchase/purchase_buy_1x.scen.json +++ b/test/delegation/v0_2/purchase/purchase_buy_1x.scen.json @@ -68,8 +68,7 @@ ], "data": [ "str:DirectCall", - "str:purchaseStake", - "str:delegator_1___________________s1" + "str:payment for stake" ] }, { diff --git a/test/delegation/v0_2/purchase/purchase_buy_2x.scen.json b/test/delegation/v0_2/purchase/purchase_buy_2x.scen.json index b67580a83..06b261227 100644 --- a/test/delegation/v0_2/purchase/purchase_buy_2x.scen.json +++ b/test/delegation/v0_2/purchase/purchase_buy_2x.scen.json @@ -68,8 +68,7 @@ ], "data": [ "str:DirectCall", - "str:purchaseStake", - "str:delegator_1___________________s1" + "str:payment for stake" ] }, { @@ -116,8 +115,7 @@ ], "data": [ "str:DirectCall", - "str:purchaseStake", - "str:delegator_1___________________s1" + "str:payment for stake" ] }, { diff --git a/test/delegation/v0_2/unstake/stake_unstake_1.scen.json b/test/delegation/v0_2/unstake/stake_unstake_1.scen.json index b5613e413..86b7bbd68 100644 --- a/test/delegation/v0_2/unstake/stake_unstake_1.scen.json +++ b/test/delegation/v0_2/unstake/stake_unstake_1.scen.json @@ -94,8 +94,7 @@ ], "data": [ "str:DirectCall", - "str:unstake", - "567,000,000,000" + "str:delegation unstake" ] }, { diff --git a/test/delegation/v0_3/test/integration/main/07_activate_pt_2.steps.json b/test/delegation/v0_3/test/integration/main/07_activate_pt_2.steps.json index c57d37e02..a83cdb4b0 100644 --- a/test/delegation/v0_3/test/integration/main/07_activate_pt_2.steps.json +++ b/test/delegation/v0_3/test/integration/main/07_activate_pt_2.steps.json @@ -46,8 +46,7 @@ ], "data": [ "str:DirectCall", - "str:withdrawInactiveStake", - "1,000,000,000" + "str:delegation withdraw inactive stake" ] }, { diff --git a/test/delegation/v0_3/test/integration/main/10_unbond_nodes.steps.json b/test/delegation/v0_3/test/integration/main/10_unbond_nodes.steps.json index fa6d097e4..339611618 100644 --- a/test/delegation/v0_3/test/integration/main/10_unbond_nodes.steps.json +++ b/test/delegation/v0_3/test/integration/main/10_unbond_nodes.steps.json @@ -46,9 +46,21 @@ "sc:delegation" ], "data": [ - "str:AsyncCall", - "str:unBond", - "str:bls_key_5_______________________________________________________________________________________" + "str:BackTransfer", + "0" + ] + }, + { + "address": "sc:auction", + "endpoint": "str:transferValueOnly", + "topics": [ + "111,000,000,000,000", + "sc:delegation" + ], + "data": [ + "str:AsyncCallback", + "str:callBack", + "0x00" ] }, { diff --git a/test/delegation/v0_3/test/integration/main/15_unbond_all.steps.json b/test/delegation/v0_3/test/integration/main/15_unbond_all.steps.json index 8562a9e77..38f2d5111 100644 --- a/test/delegation/v0_3/test/integration/main/15_unbond_all.steps.json +++ b/test/delegation/v0_3/test/integration/main/15_unbond_all.steps.json @@ -46,11 +46,21 @@ "sc:delegation" ], "data": [ - "str:AsyncCall", - "str:unBond", - "str:bls_key_6_______________________________________________________________________________________", - "str:bls_key_3_______________________________________________________________________________________", - "str:bls_key_2_______________________________________________________________________________________" + "str:BackTransfer", + "0" + ] + }, + { + "address": "sc:auction", + "endpoint": "str:transferValueOnly", + "topics": [ + "333,000,000,000,000", + "sc:delegation" + ], + "data": [ + "str:AsyncCallback", + "str:callBack", + "0x00" ] }, { diff --git a/test/delegation/v0_3/test/integration/main/16_withdraw.steps.json b/test/delegation/v0_3/test/integration/main/16_withdraw.steps.json index 844852971..0b0d9bc43 100644 --- a/test/delegation/v0_3/test/integration/main/16_withdraw.steps.json +++ b/test/delegation/v0_3/test/integration/main/16_withdraw.steps.json @@ -27,8 +27,7 @@ ], "data": [ "str:DirectCall", - "str:withdrawInactiveStake", - "1,000,000,000,000" + "str:delegation withdraw inactive stake" ] }, { @@ -105,8 +104,7 @@ ], "data": [ "str:DirectCall", - "str:withdrawInactiveStake", - "113,000,000,000,000" + "str:delegation withdraw inactive stake" ] }, { @@ -183,8 +181,7 @@ ], "data": [ "str:DirectCall", - "str:withdrawInactiveStake", - "284,000,000,000,000" + "str:delegation withdraw inactive stake" ] }, { diff --git a/test/delegation/v0_4_genesis/test/integration/genesis/05_rewards.steps.json b/test/delegation/v0_4_genesis/test/integration/genesis/05_rewards.steps.json index a178dd6f5..e47a32e9a 100644 --- a/test/delegation/v0_4_genesis/test/integration/genesis/05_rewards.steps.json +++ b/test/delegation/v0_4_genesis/test/integration/genesis/05_rewards.steps.json @@ -135,7 +135,7 @@ ], "data": [ "str:DirectCall", - "str:claimRewards" + "str:delegation rewards claim" ] } ], diff --git a/test/delegation/v0_4_genesis/test/integration/rounding_error/rounding_error.scen.json b/test/delegation/v0_4_genesis/test/integration/rounding_error/rounding_error.scen.json index f4fd9d7a8..a82b6b7dc 100644 --- a/test/delegation/v0_4_genesis/test/integration/rounding_error/rounding_error.scen.json +++ b/test/delegation/v0_4_genesis/test/integration/rounding_error/rounding_error.scen.json @@ -128,7 +128,7 @@ ], "data": [ "str:DirectCall", - "str:claimRewards" + "str:delegation rewards claim" ] } ] diff --git a/test/delegation/v0_5_latest_full/scenarios/activate_nodes.scen.json b/test/delegation/v0_5_latest_full/scenarios/activate_nodes.scen.json index 6fcfcf4e9..bbc8821b8 100644 --- a/test/delegation/v0_5_latest_full/scenarios/activate_nodes.scen.json +++ b/test/delegation/v0_5_latest_full/scenarios/activate_nodes.scen.json @@ -273,9 +273,21 @@ "sc:delegation" ], "data": [ - "str:AsyncCall", - "str:unBondNodes", - "str:bls_key_6_______________________________________________________________________________________" + "str:BackTransfer", + "0" + ] + }, + { + "address": "sc:auction", + "endpoint": "str:transferValueOnly", + "topics": [ + "100,000,000,000,000", + "sc:delegation" + ], + "data": [ + "str:AsyncCallback", + "str:callBack", + "0x00" ] }, { diff --git a/test/delegation/v0_5_latest_full/scenarios/unstake_tokens.scen.json b/test/delegation/v0_5_latest_full/scenarios/unstake_tokens.scen.json index 9fabe1389..5f1501447 100644 --- a/test/delegation/v0_5_latest_full/scenarios/unstake_tokens.scen.json +++ b/test/delegation/v0_5_latest_full/scenarios/unstake_tokens.scen.json @@ -150,9 +150,21 @@ "sc:delegation" ], "data": [ - "str:AsyncCall", - "str:unBondTokens", - "1000" + "str:BackTransfer", + "" + ] + }, + { + "address": "sc:auction", + "endpoint": "str:transferValueOnly", + "topics": [ + "1000", + "sc:delegation" + ], + "data": [ + "str:AsyncCallback", + "str:callBack", + "0x00" ] } ], diff --git a/test/dns/scenarios/05_claim.steps.json b/test/dns/scenarios/05_claim.steps.json index 02d25e365..3bc926cc0 100644 --- a/test/dns/scenarios/05_claim.steps.json +++ b/test/dns/scenarios/05_claim.steps.json @@ -25,7 +25,7 @@ ], "data": [ "str:DirectCall", - "str:claim" + "str:dns claim" ] } ], diff --git a/test/features/composability/scenarios-promises/promises_call_async_retrieve_egld.scen.json b/test/features/composability/scenarios-promises/promises_call_async_retrieve_egld.scen.json index 671b24c0c..de22eeabf 100644 --- a/test/features/composability/scenarios-promises/promises_call_async_retrieve_egld.scen.json +++ b/test/features/composability/scenarios-promises/promises_call_async_retrieve_egld.scen.json @@ -75,11 +75,21 @@ "sc:forwarder" ], "data": [ - "str:AsyncCall", - "str:retrieve_funds", - "str:EGLD", - "0", - "1000" + "str:BackTransfer", + "" + ] + }, + { + "address": "sc:vault", + "endpoint": "str:transferValueOnly", + "topics": [ + "1000", + "sc:forwarder" + ], + "data": [ + "str:AsyncCallback", + "str:retrieve_funds_callback", + "0x00" ] }, { diff --git a/test/features/composability/scenarios-promises/promises_call_async_retrieve_esdt.scen.json b/test/features/composability/scenarios-promises/promises_call_async_retrieve_esdt.scen.json index 76489b6f1..be292d045 100644 --- a/test/features/composability/scenarios-promises/promises_call_async_retrieve_esdt.scen.json +++ b/test/features/composability/scenarios-promises/promises_call_async_retrieve_esdt.scen.json @@ -80,7 +80,7 @@ "sc:forwarder" ], "data": [ - "str:AsyncCall", + "str:BackTransfer", "str:ESDTTransfer", "str:TEST-TOKENA", "1000" diff --git a/test/features/composability/scenarios/forw_raw_init_sync_echo.scen.json b/test/features/composability/scenarios/forw_raw_init_sync_echo.scen.json index e5297f945..ce244eefa 100644 --- a/test/features/composability/scenarios/forw_raw_init_sync_echo.scen.json +++ b/test/features/composability/scenarios/forw_raw_init_sync_echo.scen.json @@ -51,7 +51,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DeploySmartContract", "str:echo_arguments", "1", "2" diff --git a/test/features/composability/scenarios/forw_raw_sync_echo.scen.json b/test/features/composability/scenarios/forw_raw_sync_echo.scen.json index b06a6bc8a..de000f757 100644 --- a/test/features/composability/scenarios/forw_raw_sync_echo.scen.json +++ b/test/features/composability/scenarios/forw_raw_sync_echo.scen.json @@ -51,7 +51,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:echo_arguments", "1", "2" @@ -110,7 +110,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:echo_arguments", "1", "2" @@ -139,7 +139,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:echo_arguments", "1", "2" diff --git a/test/features/composability/scenarios/forw_raw_sync_echo_caller.scen.json b/test/features/composability/scenarios/forw_raw_sync_echo_caller.scen.json index a2e0a7640..53ef3c190 100644 --- a/test/features/composability/scenarios/forw_raw_sync_echo_caller.scen.json +++ b/test/features/composability/scenarios/forw_raw_sync_echo_caller.scen.json @@ -48,7 +48,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:echo_caller" ] }, @@ -96,7 +96,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:echo_caller" ] }, @@ -118,7 +118,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:echo_caller" ] }, diff --git a/test/features/composability/scenarios/forw_raw_sync_egld.scen.json b/test/features/composability/scenarios/forw_raw_sync_egld.scen.json index 5f5579953..3b2fe6eac 100644 --- a/test/features/composability/scenarios/forw_raw_sync_egld.scen.json +++ b/test/features/composability/scenarios/forw_raw_sync_egld.scen.json @@ -47,7 +47,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:accept_funds" ] }, @@ -104,7 +104,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:accept_funds" ] }, @@ -137,7 +137,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:accept_funds" ] }, diff --git a/test/features/composability/scenarios/forwarder_call_async_retrieve_egld.scen.json b/test/features/composability/scenarios/forwarder_call_async_retrieve_egld.scen.json index 7537edd04..ee603e98d 100644 --- a/test/features/composability/scenarios/forwarder_call_async_retrieve_egld.scen.json +++ b/test/features/composability/scenarios/forwarder_call_async_retrieve_egld.scen.json @@ -76,11 +76,21 @@ "sc:forwarder" ], "data": [ - "str:AsyncCall", - "str:retrieve_funds", - "str:EGLD", - "0", - "1000" + "str:BackTransfer", + "0" + ] + }, + { + "address": "sc:vault", + "endpoint": "str:transferValueOnly", + "topics": [ + "1000", + "sc:forwarder" + ], + "data": [ + "str:AsyncCallback", + "str:callBack", + "0x00" ] }, { diff --git a/test/features/composability/scenarios/forwarder_call_async_retrieve_esdt.scen.json b/test/features/composability/scenarios/forwarder_call_async_retrieve_esdt.scen.json index af660b7cf..0e386ad6d 100644 --- a/test/features/composability/scenarios/forwarder_call_async_retrieve_esdt.scen.json +++ b/test/features/composability/scenarios/forwarder_call_async_retrieve_esdt.scen.json @@ -81,7 +81,7 @@ "sc:forwarder" ], "data": [ - "str:AsyncCall", + "str:BackTransfer", "str:ESDTTransfer", "str:TEST-TOKENA", "1000" diff --git a/test/features/composability/scenarios/forwarder_call_async_retrieve_nft.scen.json b/test/features/composability/scenarios/forwarder_call_async_retrieve_nft.scen.json index 3362b0960..48a326c28 100644 --- a/test/features/composability/scenarios/forwarder_call_async_retrieve_nft.scen.json +++ b/test/features/composability/scenarios/forwarder_call_async_retrieve_nft.scen.json @@ -88,7 +88,7 @@ "sc:forwarder" ], "data": [ - "str:AsyncCall", + "str:BackTransfer", "str:ESDTNFTTransfer", "str:NFT-000001", "5", diff --git a/test/features/composability/scenarios/forwarder_call_sync_accept_egld.scen.json b/test/features/composability/scenarios/forwarder_call_sync_accept_egld.scen.json index a0648c109..6a0c97d6a 100644 --- a/test/features/composability/scenarios/forwarder_call_sync_accept_egld.scen.json +++ b/test/features/composability/scenarios/forwarder_call_sync_accept_egld.scen.json @@ -46,7 +46,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:accept_funds_echo_payment" ] }, diff --git a/test/features/composability/scenarios/forwarder_call_sync_accept_then_read_egld.scen.json b/test/features/composability/scenarios/forwarder_call_sync_accept_then_read_egld.scen.json index 20dd786e4..5e758f30c 100644 --- a/test/features/composability/scenarios/forwarder_call_sync_accept_then_read_egld.scen.json +++ b/test/features/composability/scenarios/forwarder_call_sync_accept_then_read_egld.scen.json @@ -48,7 +48,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:accept_funds" ] }, @@ -71,7 +71,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:call_counts", "str:accept_funds" ] diff --git a/test/features/composability/scenarios/forwarder_call_sync_accept_then_read_esdt.scen.json b/test/features/composability/scenarios/forwarder_call_sync_accept_then_read_esdt.scen.json index 0d0ba011d..8e93b4e07 100644 --- a/test/features/composability/scenarios/forwarder_call_sync_accept_then_read_esdt.scen.json +++ b/test/features/composability/scenarios/forwarder_call_sync_accept_then_read_esdt.scen.json @@ -87,7 +87,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:call_counts", "str:accept_funds" ] diff --git a/test/features/composability/scenarios/forwarder_call_sync_accept_then_read_nft.scen.json b/test/features/composability/scenarios/forwarder_call_sync_accept_then_read_nft.scen.json index c7745dc87..bdfd4a8d9 100644 --- a/test/features/composability/scenarios/forwarder_call_sync_accept_then_read_nft.scen.json +++ b/test/features/composability/scenarios/forwarder_call_sync_accept_then_read_nft.scen.json @@ -101,7 +101,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:call_counts", "str:accept_funds" ] diff --git a/test/features/composability/scenarios/forwarder_call_sync_retrieve_egld.scen.json b/test/features/composability/scenarios/forwarder_call_sync_retrieve_egld.scen.json index b8e67c365..2174e531e 100644 --- a/test/features/composability/scenarios/forwarder_call_sync_retrieve_egld.scen.json +++ b/test/features/composability/scenarios/forwarder_call_sync_retrieve_egld.scen.json @@ -48,7 +48,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:retrieve_funds", "str:EGLD", "0", @@ -76,11 +76,8 @@ "sc:forwarder" ], "data": [ - "str:ExecuteOnDestContext", - "str:retrieve_funds", - "str:EGLD", - "0", - "1000" + "str:BackTransfer", + "0" ] } ], diff --git a/test/features/composability/scenarios/forwarder_call_sync_retrieve_esdt.scen.json b/test/features/composability/scenarios/forwarder_call_sync_retrieve_esdt.scen.json index 622c58b09..3d36fc7a9 100644 --- a/test/features/composability/scenarios/forwarder_call_sync_retrieve_esdt.scen.json +++ b/test/features/composability/scenarios/forwarder_call_sync_retrieve_esdt.scen.json @@ -51,7 +51,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:retrieve_funds", "str:TEST-TOKENA", "0", @@ -81,7 +81,7 @@ "sc:forwarder" ], "data": [ - "str:ExecuteOnDestContext", + "str:BackTransfer", "str:ESDTTransfer", "str:TEST-TOKENA", "1000" diff --git a/test/features/composability/scenarios/forwarder_call_sync_retrieve_nft.scen.json b/test/features/composability/scenarios/forwarder_call_sync_retrieve_nft.scen.json index 65aa6d891..1174e1370 100644 --- a/test/features/composability/scenarios/forwarder_call_sync_retrieve_nft.scen.json +++ b/test/features/composability/scenarios/forwarder_call_sync_retrieve_nft.scen.json @@ -58,7 +58,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:retrieve_funds", "str:NFT-000001", "5", @@ -88,7 +88,7 @@ "sc:forwarder" ], "data": [ - "str:ExecuteOnDestContext", + "str:BackTransfer", "str:ESDTNFTTransfer", "str:NFT-000001", "5", diff --git a/test/features/composability/scenarios/forwarder_call_transf_exec_accept_egld.scen.json b/test/features/composability/scenarios/forwarder_call_transf_exec_accept_egld.scen.json index ceb1c5333..24eba3d3e 100644 --- a/test/features/composability/scenarios/forwarder_call_transf_exec_accept_egld.scen.json +++ b/test/features/composability/scenarios/forwarder_call_transf_exec_accept_egld.scen.json @@ -46,7 +46,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:accept_funds" ] }, diff --git a/test/features/composability/scenarios/forwarder_call_transf_exec_accept_egld_twice.scen.json b/test/features/composability/scenarios/forwarder_call_transf_exec_accept_egld_twice.scen.json index 9506a63af..12cfb4743 100644 --- a/test/features/composability/scenarios/forwarder_call_transf_exec_accept_egld_twice.scen.json +++ b/test/features/composability/scenarios/forwarder_call_transf_exec_accept_egld_twice.scen.json @@ -46,7 +46,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:accept_funds" ] }, @@ -69,7 +69,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:accept_funds" ] }, diff --git a/test/features/composability/scenarios/forwarder_call_transf_exec_accept_esdt.scen.json b/test/features/composability/scenarios/forwarder_call_transf_exec_accept_esdt.scen.json index 614365bca..80f8d48e0 100644 --- a/test/features/composability/scenarios/forwarder_call_transf_exec_accept_esdt.scen.json +++ b/test/features/composability/scenarios/forwarder_call_transf_exec_accept_esdt.scen.json @@ -56,10 +56,11 @@ "sc:vault" ], "data": [ - "str:DirectCall", + "str:TransferAndExecute", "str:ESDTTransfer", "str:TEST-TOKENA", - "1000" + "1000", + "str:accept_funds" ] }, { diff --git a/test/features/composability/scenarios/forwarder_call_transf_exec_accept_esdt_twice.scen.json b/test/features/composability/scenarios/forwarder_call_transf_exec_accept_esdt_twice.scen.json index f5b6facdd..2bce23a32 100644 --- a/test/features/composability/scenarios/forwarder_call_transf_exec_accept_esdt_twice.scen.json +++ b/test/features/composability/scenarios/forwarder_call_transf_exec_accept_esdt_twice.scen.json @@ -56,10 +56,11 @@ "sc:vault" ], "data": [ - "str:DirectCall", + "str:TransferAndExecute", "str:ESDTTransfer", "str:TEST-TOKENA", - "1000" + "1000", + "str:accept_funds" ] }, { @@ -86,10 +87,11 @@ "sc:vault" ], "data": [ - "str:DirectCall", + "str:TransferAndExecute", "str:ESDTTransfer", "str:TEST-TOKENA", - "1000" + "1000", + "str:accept_funds" ] }, { diff --git a/test/features/composability/scenarios/forwarder_call_transf_exec_accept_multi_transfer.scen.json b/test/features/composability/scenarios/forwarder_call_transf_exec_accept_multi_transfer.scen.json index 7896a3a7d..2c5afabb3 100644 --- a/test/features/composability/scenarios/forwarder_call_transf_exec_accept_multi_transfer.scen.json +++ b/test/features/composability/scenarios/forwarder_call_transf_exec_accept_multi_transfer.scen.json @@ -77,7 +77,7 @@ "sc:vault" ], "data": [ - "str:DirectCall", + "str:TransferAndExecute", "str:MultiESDTNFTTransfer", "sc:vault", "2", @@ -86,7 +86,8 @@ "100", "str:FWD-TOKEN", "0", - "200" + "200", + "str:accept_funds" ] }, { diff --git a/test/features/composability/scenarios/forwarder_call_transf_exec_accept_nft.scen.json b/test/features/composability/scenarios/forwarder_call_transf_exec_accept_nft.scen.json index b76f0f3d7..50be94968 100644 --- a/test/features/composability/scenarios/forwarder_call_transf_exec_accept_nft.scen.json +++ b/test/features/composability/scenarios/forwarder_call_transf_exec_accept_nft.scen.json @@ -64,12 +64,13 @@ "sc:vault" ], "data": [ - "str:DirectCall", + "str:TransferAndExecute", "str:ESDTNFTTransfer", "str:NFT-000001", "5", "1", - "sc:vault" + "sc:vault", + "str:accept_funds" ] }, { diff --git a/test/features/composability/scenarios/forwarder_call_transf_exec_accept_return_values.scen.json b/test/features/composability/scenarios/forwarder_call_transf_exec_accept_return_values.scen.json index e1cb0af7f..ba72b2d07 100644 --- a/test/features/composability/scenarios/forwarder_call_transf_exec_accept_return_values.scen.json +++ b/test/features/composability/scenarios/forwarder_call_transf_exec_accept_return_values.scen.json @@ -51,7 +51,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:accept_funds" ] }, diff --git a/test/features/composability/scenarios/forwarder_call_transf_exec_accept_sft_twice.scen.json b/test/features/composability/scenarios/forwarder_call_transf_exec_accept_sft_twice.scen.json index 6a907dcda..9a4ad571d 100644 --- a/test/features/composability/scenarios/forwarder_call_transf_exec_accept_sft_twice.scen.json +++ b/test/features/composability/scenarios/forwarder_call_transf_exec_accept_sft_twice.scen.json @@ -64,12 +64,13 @@ "sc:vault" ], "data": [ - "str:DirectCall", + "str:TransferAndExecute", "str:ESDTNFTTransfer", "str:NFT-000001", "5", "1", - "sc:vault" + "sc:vault", + "str:accept_funds" ] }, { @@ -96,12 +97,13 @@ "sc:vault" ], "data": [ - "str:DirectCall", + "str:TransferAndExecute", "str:ESDTNFTTransfer", "str:NFT-000001", "5", "1", - "sc:vault" + "sc:vault", + "str:accept_funds" ] }, { diff --git a/test/features/composability/scenarios/forwarder_sync_echo.scen.json b/test/features/composability/scenarios/forwarder_sync_echo.scen.json index 93c4d4bc3..1bf397ac0 100644 --- a/test/features/composability/scenarios/forwarder_sync_echo.scen.json +++ b/test/features/composability/scenarios/forwarder_sync_echo.scen.json @@ -47,7 +47,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:echo_arguments", "1", "2" @@ -100,7 +100,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:echo_arguments", "1", "2" @@ -129,7 +129,7 @@ "sc:vault" ], "data": [ - "str:ExecuteOnDestContext", + "str:DirectCall", "str:echo_arguments", "1", "2" diff --git a/vmhost/common.go b/vmhost/common.go index 4e72ce469..ed19636db 100644 --- a/vmhost/common.go +++ b/vmhost/common.go @@ -225,7 +225,8 @@ type AsyncGeneratedCall struct { } // OldAsyncContext is a structure containing a group of async calls and a callback -// that should be called when all these async calls are resolved +// +// that should be called when all these async calls are resolved type OldAsyncContext struct { Callback string AsyncCalls []*AsyncGeneratedCall @@ -261,9 +262,12 @@ func (ac *AsyncGeneratedCall) IsInterfaceNil() bool { return ac == nil } +// ESDTTransfersArgs defines the structure for ESDTTransferArgs, used in TransferAndExecute type ESDTTransfersArgs struct { Destination []byte OriginalCaller []byte Sender []byte Transfers []*vmcommon.ESDTTransfer + Function string + Arguments [][]byte } diff --git a/vmhost/contexts/asyncLocal.go b/vmhost/contexts/asyncLocal.go index 061019f3c..cda703045 100644 --- a/vmhost/contexts/asyncLocal.go +++ b/vmhost/contexts/asyncLocal.go @@ -103,15 +103,15 @@ func (context *asyncContext) executeAsyncLocalCall(asyncCall *vmhost.AsyncCall) } // ExecuteSyncCallbackAndFinishOutput executes the callback and finishes the output -//TODO rename to executeLocalCallbackAndFinishOutput +// TODO rename to executeLocalCallbackAndFinishOutput func (context *asyncContext) ExecuteSyncCallbackAndFinishOutput( asyncCall *vmhost.AsyncCall, vmOutput *vmcommon.VMOutput, _ *vmcommon.ContractCallInput, gasAccumulated uint64, err error) (bool, *vmcommon.VMOutput) { - callbackVMOutput, isComplete, callbackErr := context.executeSyncCallback(asyncCall, vmOutput, gasAccumulated, err) - context.finishAsyncLocalCallbackExecution(callbackVMOutput, callbackErr, vmOutput.ReturnCode) + callbackVMOutput, isComplete, _ := context.executeSyncCallback(asyncCall, vmOutput, gasAccumulated, err) + context.finishAsyncLocalCallbackExecution() return isComplete, callbackVMOutput } @@ -183,8 +183,8 @@ func (context *asyncContext) executeSyncHalfOfBuiltinFunction(asyncCall *vmhost. if vmOutput.ReturnCode != vmcommon.Ok { asyncCall.Reject() if asyncCall.HasCallback() { - callbackVMOutput, _, callbackErr := context.executeSyncCallback(asyncCall, vmOutput, 0, err) - context.finishAsyncLocalCallbackExecution(callbackVMOutput, callbackErr, 0) + _, _, _ = context.executeSyncCallback(asyncCall, vmOutput, 0, err) + context.finishAsyncLocalCallbackExecution() } } @@ -195,33 +195,9 @@ func (context *asyncContext) executeSyncHalfOfBuiltinFunction(asyncCall *vmhost. return nil } -// TODO(fix) this function -//nolint:all -func (context *asyncContext) finishAsyncLocalCallbackExecution( - vmOutput *vmcommon.VMOutput, - err error, - destinationReturnCode vmcommon.ReturnCode, -) { - +func (context *asyncContext) finishAsyncLocalCallbackExecution() { runtime := context.host.Runtime() - runtime.GetVMInput().GasProvided = 0 - - // if vmOutput == nil { - // vmOutput = output.CreateVMOutputInCaseOfError(err) - // } - - // if setReturnCode { - // if vmOutput.ReturnCode != vmcommon.Ok { - // output.SetReturnCode(vmOutput.ReturnCode) - // } else { - // output.SetReturnCode(destinationReturnCode) - // } - // } - - // output.SetReturnMessage(vmOutput.ReturnMessage) - // output.Finish([]byte(vmOutput.ReturnCode.String())) - // output.Finish(runtime.GetCurrentTxHash()) } func (context *asyncContext) createContractCallInput(asyncCall *vmhost.AsyncCall) (*vmcommon.ContractCallInput, error) { diff --git a/vmhost/contexts/async_test.go b/vmhost/contexts/async_test.go index ac1e3db47..d91fb22ba 100644 --- a/vmhost/contexts/async_test.go +++ b/vmhost/contexts/async_test.go @@ -891,7 +891,7 @@ func TestAsyncContext_FinishSyncExecution_NilError_NilVMOutput(t *testing.T) { host, _, originalVMInput := initializeVMAndWasmerAsyncContextWithAliceAndBob(t) host.Runtime().InitStateFromContractCallInput(originalVMInput) async := makeAsyncContext(t, host, nil) - async.finishAsyncLocalCallbackExecution(nil, nil, 0) + async.finishAsyncLocalCallbackExecution() // The expectedOutput must also contain an OutputAccount corresponding to // Alice, because of a call to host.Output().GetOutputAccount() in @@ -910,8 +910,7 @@ func TestAsyncContext_FinishSyncExecution_Error_NilVMOutput(t *testing.T) { host.Runtime().InitStateFromContractCallInput(originalVMInput) async := makeAsyncContext(t, host, nil) - syncExecErr := vmhost.ErrNotEnoughGas - async.finishAsyncLocalCallbackExecution(nil, syncExecErr, 0) + async.finishAsyncLocalCallbackExecution() expectedOutput := vmhost.MakeEmptyVMOutput() expectedOutput.GasRemaining = host.Metering().GasLeft() @@ -938,8 +937,7 @@ func TestAsyncContext_FinishSyncExecution_ErrorAndVMOutput(t *testing.T) { syncExecOutput := vmhost.MakeEmptyVMOutput() syncExecOutput.ReturnCode = vmcommon.UserError syncExecOutput.ReturnMessage = "user made an error" - syncExecErr := vmhost.ErrSignalError - async.finishAsyncLocalCallbackExecution(syncExecOutput, syncExecErr, 0) + async.finishAsyncLocalCallbackExecution() expectedOutput := vmhost.MakeEmptyVMOutput() expectedOutput.GasRemaining = host.Metering().GasLeft() diff --git a/vmhost/contexts/output.go b/vmhost/contexts/output.go index 4f3577002..e992f68ad 100644 --- a/vmhost/contexts/output.go +++ b/vmhost/contexts/output.go @@ -2,7 +2,6 @@ package contexts import ( "bytes" - "encoding/hex" "errors" "math/big" @@ -11,6 +10,7 @@ import ( "github.com/multiversx/mx-chain-core-go/data/vm" logger "github.com/multiversx/mx-chain-logger-go" vmcommon "github.com/multiversx/mx-chain-vm-common-go" + "github.com/multiversx/mx-chain-vm-common-go/parsers" "github.com/multiversx/mx-chain-vm-go/executor" "github.com/multiversx/mx-chain-vm-go/math" "github.com/multiversx/mx-chain-vm-go/vmhost" @@ -26,6 +26,7 @@ type outputContext struct { stateStack []*vmcommon.VMOutput codeUpdates map[string]struct{} crtTransferIndex uint32 + callArgsParser vmcommon.CallArgsParser } // NewOutputContext creates a new outputContext @@ -38,6 +39,7 @@ func NewOutputContext(host vmhost.VMHost) (*outputContext, error) { host: host, stateStack: make([]*vmcommon.VMOutput, 0), crtTransferIndex: 1, + callArgsParser: parsers.NewCallArgsParser(), } context.InitState() @@ -320,14 +322,6 @@ func (context *outputContext) TransferValueOnly(destination []byte, sender []byt } } - vmInput := context.host.Runtime().GetVMInput() - context.WriteLogWithIdentifier( - sender, - [][]byte{value.Bytes(), destination}, - vmcommon.FormatLogDataForCall("", vmInput.Function, vmInput.Arguments), - []byte("transferValueOnly"), - ) - return nil } @@ -359,7 +353,16 @@ func (context *outputContext) isBackTransferWithoutExecution(sender, destination // Transfer handles any necessary value transfer required and takes // the necessary steps to create accounts and reverses the state in case of an // execution error or failed value transfer. -func (context *outputContext) Transfer(destination []byte, sender []byte, gasLimit uint64, gasLocked uint64, value *big.Int, asyncData []byte, input []byte, callType vm.CallType) error { +func (context *outputContext) Transfer( + destination []byte, + sender []byte, + gasLimit uint64, + gasLocked uint64, + value *big.Int, + asyncData []byte, + input []byte, + callType vm.CallType, +) error { checkPayableIfNotCallback := gasLimit > 0 && callType != vm.AsynchronousCallBack isBackTransfer := context.isBackTransferWithoutExecution(sender, destination, input) checkPayable := checkPayableIfNotCallback || !isBackTransfer @@ -371,6 +374,10 @@ func (context *outputContext) Transfer(destination []byte, sender []byte, gasLim if (callType == vm.AsynchronousCall || callType == vm.AsynchronousCallBack) && len(asyncData) == 0 { return vmcommon.ErrAsyncParams } + executionType := callType + if callType == vm.DirectCall && isBackTransfer { + executionType = vm.ESDTTransferAndExecute + } destAcc, _ := context.GetOutputAccount(destination) outputTransfer := vmcommon.OutputTransfer{ @@ -387,9 +394,46 @@ func (context *outputContext) Transfer(destination []byte, sender []byte, gasLim logOutput.Trace("transfer value added") + function, args, errNotCritical := context.callArgsParser.ParseData(string(input)) + + isSimpleTransfer := errNotCritical != nil || !core.IsSmartContractAddress(destination) || gasLimit == 0 + if !isBackTransfer && isSimpleTransfer { + context.WriteLogWithIdentifier( + sender, + [][]byte{value.Bytes(), destination}, + [][]byte{[]byte(""), input}, + []byte("transferValueOnly"), + ) + return nil + } + + context.WriteLogWithIdentifier( + sender, + [][]byte{value.Bytes(), destination}, + vmcommon.FormatLogDataForCall(getExecutionType(executionType, isBackTransfer), function, args), + []byte("transferValueOnly"), + ) + return nil } +func getExecutionType(callType vm.CallType, isBackTransfer bool) string { + if isBackTransfer { + return "BackTransfer" + } + + switch callType { + case vm.ESDTTransferAndExecute: + return "TransferAndExecute" + case vm.AsynchronousCall: + return "AsyncCall" + case vm.AsynchronousCallBack: + return "AsyncCallBack" + } + + return "" +} + // TransferESDT makes the esdt/nft transfer and exports the data if it is cross shard func (context *outputContext) TransferESDT( transfersArgs *vmhost.ESDTTransfersArgs, @@ -405,11 +449,17 @@ func (context *outputContext) TransferESDT( isExecution := isSmartContract && callInput != nil isBackTransfer := !isExecution && context.isBackTransferWithoutExecution(transfersArgs.Sender, transfersArgs.Destination, nil) - if isExecution || isBackTransfer { - callType = vm.ESDTTransferAndExecute + if callInput != nil { + callType = callInput.CallType + transfersArgs.Function = callInput.Function + transfersArgs.Arguments = callInput.Arguments + } + executionType := callType + if callType == vm.DirectCall && (isExecution || isBackTransfer) { + executionType = vm.ESDTTransferAndExecute } - vmOutput, gasConsumedByTransfer, err := context.host.ExecuteESDTTransfer(transfersArgs, callType) + vmOutput, gasConsumedByTransfer, err := context.host.ExecuteESDTTransfer(transfersArgs, executionType) if err != nil { return 0, err } @@ -436,32 +486,20 @@ func (context *outputContext) TransferESDT( } destAcc, _ := context.GetOutputAccount(transfersArgs.Destination) - outputTransfer := vmcommon.OutputTransfer{ - Index: context.NextOutputTransferIndex(), - Value: big.NewInt(0), - GasLimit: gasRemaining, - GasLocked: 0, - Data: []byte{}, - CallType: vm.DirectCall, - SenderAddress: transfersArgs.Sender, - } - - outputTransfer.Data = context.getOutputTransferDataFromESDTTransfer(transfersArgs.Transfers, vmOutput, sameShard, transfersArgs.Destination) - - if sameShard { - outputTransfer.GasLimit = 0 - } - - if callInput != nil { - scCallData := "@" + hex.EncodeToString([]byte(callInput.Function)) - for _, arg := range callInput.Arguments { - scCallData += "@" + hex.EncodeToString(arg) + outputAcc, ok := vmOutput.OutputAccounts[string(transfersArgs.Destination)] + + if ok && len(outputAcc.OutputTransfers) == 1 { + esdtOutTransfer := outputAcc.OutputTransfers[0] + esdtOutTransfer.GasLimit = gasRemaining + esdtOutTransfer.CallType = callType + if sameShard { + esdtOutTransfer.GasLimit = 0 } - outputTransfer.Data = append(outputTransfer.Data, []byte(scCallData)...) - } - AppendOutputTransfers(destAcc, destAcc.OutputTransfers, outputTransfer) + AppendOutputTransfers(destAcc, destAcc.OutputTransfers, esdtOutTransfer) + } + context.host.CompleteLogEntriesWithCallType(vmOutput, getExecutionType(executionType, isBackTransfer)) context.outputState.Logs = append(context.outputState.Logs, vmOutput.Logs...) return gasRemaining, nil @@ -475,41 +513,6 @@ func AppendOutputTransfers(account *vmcommon.OutputAccount, existingTransfers [] } } -func (context *outputContext) getOutputTransferDataFromESDTTransfer( - transfers []*vmcommon.ESDTTransfer, - vmOutput *vmcommon.VMOutput, - sameShard bool, - destination []byte, -) []byte { - - if len(transfers) == 1 && transfers[0].ESDTTokenNonce == 0 { - return []byte(core.BuiltInFunctionESDTTransfer + "@" + hex.EncodeToString(transfers[0].ESDTTokenName) + "@" + hex.EncodeToString(transfers[0].ESDTValue.Bytes())) - } - - if !sameShard { - outTransfer, ok := vmOutput.OutputAccounts[string(destination)] - if ok && len(outTransfer.OutputTransfers) == 1 { - return outTransfer.OutputTransfers[0].Data - } - } - - if len(transfers) == 1 { - data := []byte(core.BuiltInFunctionESDTNFTTransfer + "@" + - hex.EncodeToString(transfers[0].ESDTTokenName) + "@" + - hex.EncodeToString(big.NewInt(0).SetUint64(transfers[0].ESDTTokenNonce).Bytes()) + "@" + - hex.EncodeToString(transfers[0].ESDTValue.Bytes()) + "@" + - hex.EncodeToString(destination)) - return data - } - - data := core.BuiltInFunctionMultiESDTNFTTransfer + "@" + hex.EncodeToString(destination) + "@" + hex.EncodeToString(big.NewInt(int64(len(transfers))).Bytes()) - for _, transfer := range transfers { - data += "@" + hex.EncodeToString(transfer.ESDTTokenName) + "@" + hex.EncodeToString(big.NewInt(0).SetUint64(transfer.ESDTTokenNonce).Bytes()) + "@" + hex.EncodeToString(transfer.ESDTValue.Bytes()) - } - - return []byte(data) -} - func (context *outputContext) hasSufficientBalance(address []byte, value *big.Int) bool { senderBalance := context.host.Blockchain().GetBalanceBigInt(address) return senderBalance.Cmp(value) >= 0 diff --git a/vmhost/hostCore/execution.go b/vmhost/hostCore/execution.go index af2dc778f..b944b79a4 100644 --- a/vmhost/hostCore/execution.go +++ b/vmhost/hostCore/execution.go @@ -486,6 +486,14 @@ func (host *vmHost) executeOnDestContextNoBuiltinFunction(input *vmcommon.Contra return vmOutput, true, err } } + if len(input.ESDTTransfers) == 0 { + output.WriteLogWithIdentifier( + input.CallerAddr, + [][]byte{input.CallValue.Bytes(), input.RecipientAddr}, + vmcommon.FormatLogDataForCall("", input.Function, input.Arguments), + []byte("transferValueOnly"), + ) + } err = host.execute(input) if err != nil { @@ -598,6 +606,12 @@ func (host *vmHost) ExecuteOnSameContext(input *vmcommon.ContractCallInput) erro runtime.AddError(err, input.Function) return err } + output.WriteLogWithIdentifier( + input.CallerAddr, + [][]byte{input.CallValue.Bytes(), input.RecipientAddr}, + vmcommon.FormatLogDataForCall("ExecuteOnSameContext", input.Function, input.Arguments), + []byte("transferValueOnly"), + ) err = host.execute(input) runtime.AddError(err, input.Function) @@ -957,6 +971,13 @@ func (host *vmHost) ExecuteESDTTransfer(transfersArgs *vmhost.ESDTTransfersArgs, } } + if len(transfersArgs.Function) > 0 { + esdtTransferInput.Arguments = append(esdtTransferInput.Arguments, []byte(transfersArgs.Function)) + } + if len(transfersArgs.Arguments) > 0 { + esdtTransferInput.Arguments = append(esdtTransferInput.Arguments, transfersArgs.Arguments...) + } + vmOutput, err := host.Blockchain().ProcessBuiltInFunction(esdtTransferInput) log.Trace("ESDT transfer", "sender", transfersArgs.Sender, "dest", transfersArgs.Destination) for _, transfer := range transfers { @@ -976,6 +997,8 @@ func (host *vmHost) ExecuteESDTTransfer(transfersArgs *vmhost.ESDTTransfersArgs, return nil, 0, err } + host.addESDTTransferToVMOutputSCIntraShardCall(esdtTransferInput, vmOutput) + gasConsumed := math.SubUint64(esdtTransferInput.GasProvided, vmOutput.GasRemaining) for _, outAcc := range vmOutput.OutputAccounts { for _, transfer := range outAcc.OutputTransfers { diff --git a/vmhost/hostCore/host.go b/vmhost/hostCore/host.go index d98e2ffe7..148567d91 100644 --- a/vmhost/hostCore/host.go +++ b/vmhost/hostCore/host.go @@ -606,7 +606,7 @@ func (host *vmHost) logFromGasTracer(functionName string) { } } -// CompleteLogEntriesWithCallType sets the call type on a logn entry if it's not already filled +// CompleteLogEntriesWithCallType sets the call type on a log entry if it's not already filled func (host *vmHost) CompleteLogEntriesWithCallType(vmOutput *vmcommon.VMOutput, callType string) { for _, logEntry := range vmOutput.Logs { _, containsId := host.transferLogIdentifiers[string(logEntry.Identifier)] diff --git a/vmhost/hosttest/execution_gas_test.go b/vmhost/hosttest/execution_gas_test.go index 553802874..3dfaf90fe 100644 --- a/vmhost/hosttest/execution_gas_test.go +++ b/vmhost/hosttest/execution_gas_test.go @@ -162,13 +162,13 @@ func TestGasUsed_SingleContract_TransferFromChild(t *testing.T) { Identifier: []byte("transferValueOnly"), Address: test.ParentAddress, Topics: [][]byte{big.NewInt(0).Bytes(), test.ChildAddress}, - Data: vmcommon.FormatLogDataForCall("ExecuteOnDestContext", "transferEGLDToParent", [][]byte{}), + Data: vmcommon.FormatLogDataForCall("DirectCall", "transferEGLDToParent", [][]byte{}), }, vmcommon.LogEntry{ Identifier: []byte("transferValueOnly"), Address: test.ChildAddress, Topics: [][]byte{big.NewInt(testConfig.ChildBalance / 2).Bytes(), test.ParentAddress}, - Data: vmcommon.FormatLogDataForCall("ExecuteOnDestContext", "transferEGLDToParent", [][]byte{}), + Data: vmcommon.FormatLogDataForCall("BackTransfer", "", [][]byte{}), }) }) assert.Nil(t, err) @@ -264,7 +264,7 @@ func TestGasUsed_TwoContracts_ExecuteOnSameCtx(t *testing.T) { Identifier: []byte("transferValueOnly"), Address: test.ParentAddress, Topics: [][]byte{big.NewInt(testConfig.ChildBalance / 2).Bytes(), test.ParentAddress}, - Data: vmcommon.FormatLogDataForCall("ExecuteOnSameContext", "transferEGLDToParent", [][]byte{}), + Data: vmcommon.FormatLogDataForCall("BackTransfer", "", [][]byte{}), }) } }) @@ -1445,10 +1445,10 @@ func testGasUsedESDTTransferThenExecuteAsyncCallSuccess(t *testing.T, isLegacy b } /* - ParentAddress.execESDTTransferAndAsyncCall -> ChildAddress.wasteGasOnNewphew (with async with ESDTTransfer) - ChildAddress.wasteGasOnNewphew -> NephewAddress.wasteGas - -> ParentAddress.callBack - ParentAddress.callBack -> ChildAddress.wasteGas +ParentAddress.execESDTTransferAndAsyncCall -> ChildAddress.wasteGasOnNephew (with async with ESDTTransfer) +ChildAddress.wasteGasOnNephew -> NephewAddress.wasteGas +-> ParentAddress.callBack +ParentAddress.callBack -> ChildAddress.wasteGas */ func TestGasUsed_ESDTTransfer_ThenExecuteAsyncCall_ThenExecuteOnDest(t *testing.T) { var parentAccount *worldmock.Account @@ -1523,7 +1523,7 @@ func TestGasUsed_ESDTTransfer_ThenExecuteAsyncCall_ThenExecuteOnDest(t *testing. Identifier: []byte("transferValueOnly"), Address: test.ChildAddress, Topics: [][]byte{{}, test.NephewAddress}, - Data: vmcommon.FormatLogDataForCall("ExecuteOnDestContext", "wasteGas", [][]byte{}), + Data: vmcommon.FormatLogDataForCall("AsyncCall", "wasteGas", [][]byte{}), }, vmcommon.LogEntry{ Identifier: []byte("transferValueOnly"), @@ -1535,7 +1535,7 @@ func TestGasUsed_ESDTTransfer_ThenExecuteAsyncCall_ThenExecuteOnDest(t *testing. Identifier: []byte("transferValueOnly"), Address: test.ParentAddress, Topics: [][]byte{{}, test.ChildAddress}, - Data: vmcommon.FormatLogDataForCall("ExecuteOnDestContext", "wasteGas", [][]byte{}), + Data: vmcommon.FormatLogDataForCall("AsyncCallback", "wasteGas", [][]byte{}), }) parentESDTBalance, _ := parentAccount.GetTokenBalanceUint64(test.ESDTTestTokenName, 0) @@ -1793,7 +1793,7 @@ func testGasUsedESDTTransferInCallback(t *testing.T, isLegacy bool, numOfTransfe Address: test.ChildAddress, Topics: [][]byte{test.ESDTTestTokenName, {}, big.NewInt(int64(testConfig.CallbackESDTTokensToTransfer)).Bytes(), test.ParentAddress}, Data: vmcommon.FormatLogDataForCall( - "AsyncCall", + "BackTransfer", "ESDTTransfer", [][]byte{ test.ESDTTestTokenName, @@ -2070,19 +2070,30 @@ func TestGasUsed_TransferAndExecute_CrossShard(t *testing.T) { expectedTransfer := test.CreateTransferEntry(test.ParentAddress, contracts.GetChildAddressForTransfer(transfer), uint32(transfer+1)). WithData(big.NewInt(int64(transfer)).Bytes()). WithGasLimit(testConfig.GasProvidedToChild). + WithCallType(vm.DirectCall). WithValue(big.NewInt(testConfig.TransferFromParentToChild)) expectedTransfers = append(expectedTransfers, expectedTransfer) - expectedLogs = append(expectedLogs, vmcommon.LogEntry{ - Address: test.ParentAddress, - Topics: [][]byte{ - big.NewInt(testConfig.TransferFromParentToChild).Bytes(), - contracts.GetChildAddressForTransfer(transfer)}, - Data: vmcommon.FormatLogDataForCall( - "DirectCall", - contracts.TransferAndExecuteFuncName, - [][]byte{{byte(noOfTransfers)}}), - Identifier: []byte("transferValueOnly"), - }) + if transfer == 0 { + expectedLog := vmcommon.LogEntry{ + Address: test.ParentAddress, + Topics: [][]byte{ + big.NewInt(testConfig.TransferFromParentToChild).Bytes(), + contracts.GetChildAddressForTransfer(transfer)}, + Data: [][]byte{[]byte("DirectCall"), []byte("")}, + Identifier: []byte("transferValueOnly"), + } + expectedLogs = append(expectedLogs, expectedLog) + } else { + expectedLog := vmcommon.LogEntry{ + Address: test.ParentAddress, + Topics: [][]byte{ + big.NewInt(testConfig.TransferFromParentToChild).Bytes(), + contracts.GetChildAddressForTransfer(transfer)}, + Data: [][]byte{[]byte("DirectCall"), big.NewInt(int64(transfer)).Bytes()}, + Identifier: []byte("transferValueOnly"), + } + expectedLogs = append(expectedLogs, expectedLog) + } } gasRemaining := testConfig.GasProvided - testConfig.GasUsedByParent - uint64(noOfTransfers)*testConfig.GasProvidedToChild diff --git a/vmhost/interface.go b/vmhost/interface.go index d6020f9b3..e7edee399 100644 --- a/vmhost/interface.go +++ b/vmhost/interface.go @@ -231,6 +231,7 @@ type OutputContext interface { GetOutputAccounts() map[string]*vmcommon.OutputAccount DeleteOutputAccount(address []byte) WriteLog(address []byte, topics [][]byte, data [][]byte) + WriteLogWithIdentifier(address []byte, topics [][]byte, data [][]byte, identifier []byte) TransferValueOnly(destination []byte, sender []byte, value *big.Int, checkPayable bool) error Transfer(destination []byte, sender []byte, gasLimit uint64, gasLocked uint64, value *big.Int, asyncData []byte, input []byte, callType vm.CallType) error TransferESDT(transfersArgs *ESDTTransfersArgs, callInput *vmcommon.ContractCallInput) (uint64, error) diff --git a/vmhost/vmhooks/baseOps.go b/vmhost/vmhooks/baseOps.go index 572646cb4..2275d2a17 100644 --- a/vmhost/vmhooks/baseOps.go +++ b/vmhost/vmhooks/baseOps.go @@ -3179,7 +3179,7 @@ func prepareIndirectContractCallInput( } func (context *VMHooksImpl) getArgumentsFromMemory( - host vmhost.VMHost, + _ vmhost.VMHost, numArguments int32, argumentsLengthOffset executor.MemPtr, dataOffset executor.MemPtr, @@ -3225,7 +3225,6 @@ func executeOnDestContextFromAPI(host vmhost.VMHost, input *vmcommon.ContractCal if err != nil { return nil, err } - host.CompleteLogEntriesWithCallType(vmOutput, "ExecuteOnDestContext") err = host.Async().CompleteChildConditional(isChildComplete, nil, 0) if err != nil {