Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,6 @@
"status": "0",
"message": "",
"logs": [
{
"address": "sc:forwarder",
"endpoint": "str:MultiESDTNFTTransfer",
"topics": [
"str:EGLD-000000",
"",
"100",
"sc:vault"
],
"data": [
"str:TransferAndExecute",
"str:MultiESDTNFTTransfer",
"sc:vault",
"1",
"str:EGLD-000000",
"",
"100",
"str:reject_funds"
]
},
{
"address": "address:a_user",
"endpoint": "str:internalVMErrors",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,44 +71,6 @@
"status": "0",
"message": "",
"logs": [
{
"address": "sc:forwarder",
"endpoint": "str:MultiESDTNFTTransfer",
"topics": [
"str:FWD-TOKEN",
"0",
"800",
"str:NFT-123456",
"1",
"1",
"str:EGLD-000000",
"0",
"100",
"str:SFT-456789",
"3",
"6",
"sc:vault"
],
"data": [
"str:TransferAndExecute",
"str:MultiESDTNFTTransfer",
"sc:vault",
"4",
"str:FWD-TOKEN",
"0",
"800",
"str:NFT-123456",
"1",
"1",
"str:EGLD-000000",
"0",
"100",
"str:SFT-456789",
"3",
"6",
"str:reject_funds"
]
},
{
"address": "address:a_user",
"endpoint": "str:internalVMErrors",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,32 +49,6 @@
"status": "0",
"message": "",
"logs": [
{
"address": "sc:forwarder",
"endpoint": "str:MultiESDTNFTTransfer",
"topics": [
"str:FWD-TOKEN",
"0",
"100",
"str:FWD-TOKEN",
"0",
"200",
"sc:vault"
],
"data": [
"str:TransferAndExecute",
"str:MultiESDTNFTTransfer",
"sc:vault",
"2",
"str:FWD-TOKEN",
"0",
"100",
"str:FWD-TOKEN",
"0",
"200",
"str:reject_funds"
]
},
{
"address": "address:a_user",
"endpoint": "str:internalVMErrors",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,6 @@
"gas": "*",
"refund": "*",
"logs": [
{
"address": "sc:forwarder",
"endpoint": "str:MultiESDTNFTTransfer",
"topics": [
"str:FWD-TOKEN",
"0",
"1000",
"sc:vault"
],
"data": [
"str:AsyncCall",
"str:MultiESDTNFTTransfer",
"sc:vault",
"1",
"str:FWD-TOKEN",
"0",
"1000",
"str:reject_funds"
]
},
{
"address": "sc:vault",
"endpoint": "str:transferValueOnly",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,44 +71,6 @@
"status": "0",
"message": "",
"logs": [
{
"address": "sc:forwarder",
"endpoint": "str:MultiESDTNFTTransfer",
"topics": [
"str:FWD-TOKEN",
"0",
"100",
"str:NFT-123456",
"1",
"1",
"str:EGLD-000000",
"0",
"100",
"str:SFT-456789",
"3",
"6",
"sc:vault"
],
"data": [
"str:ExecuteOnDestContext",
"str:MultiESDTNFTTransfer",
"sc:vault",
"4",
"str:FWD-TOKEN",
"0",
"100",
"str:NFT-123456",
"1",
"1",
"str:EGLD-000000",
"0",
"100",
"str:SFT-456789",
"3",
"6",
"str:reject_funds"
]
},
{
"address": "sc:forwarder",
"endpoint": "str:forward_sync_reject_funds_multi_transfer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,38 +67,6 @@
"status": "0",
"message": "",
"logs": [
{
"address": "sc:promises",
"endpoint": "str:MultiESDTNFTTransfer",
"topics": [
"str:FWD-TOKEN",
"0",
"500",
"str:NFT-123456",
"1",
"1",
"str:SFT-456789",
"3",
"6",
"sc:vault"
],
"data": [
"str:AsyncCall",
"str:MultiESDTNFTTransfer",
"sc:vault",
"3",
"str:FWD-TOKEN",
"0",
"500",
"str:NFT-123456",
"1",
"1",
"str:SFT-456789",
"3",
"6",
"str:explicit_panic"
]
},
{
"address": "sc:vault",
"endpoint": "str:transferValueOnly",
Expand Down
4 changes: 2 additions & 2 deletions vmhost/contexts/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ func (context *blockchainContext) GetSnapshot() int {
}

// RevertToSnapshot - reverts to the specified snapshot via blockchain hook
func (context *blockchainContext) RevertToSnapshot(snapshot int) {
_ = context.blockChainHook.RevertToSnapshot(snapshot)
func (context *blockchainContext) RevertToSnapshot(snapshot int) error {
return context.blockChainHook.RevertToSnapshot(snapshot)
}

// IsLimitedTransfer returns true if token transfers are limited
Expand Down
2 changes: 0 additions & 2 deletions vmhost/contexts/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,6 @@ func (context *outputContext) TransferESDT(

destAcc, _ := context.GetOutputAccount(transfersArgs.Destination)
outputAcc, ok := vmOutput.OutputAccounts[string(transfersArgs.Destination)]

if ok && len(outputAcc.OutputTransfers) == 1 {
esdtOutTransfer := outputAcc.OutputTransfers[0]
esdtOutTransfer.GasLimit = gasRemaining
Expand All @@ -507,7 +506,6 @@ func (context *outputContext) TransferESDT(
if sameShard {
esdtOutTransfer.GasLimit = 0
}

AppendOutputTransfers(destAcc, destAcc.OutputTransfers, esdtOutTransfer)
}

Expand Down
15 changes: 9 additions & 6 deletions vmhost/hostCore/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,16 @@ func (host *vmHost) ExecuteOnDestContext(input *vmcommon.ContractCallInput) (vmO
scExecutionInput := input

blockchain := host.Blockchain()
output := host.Output()

blockchain.PushState()
output.PushState()

if host.IsBuiltinFunctionName(input.Function) {
scExecutionInput, vmOutput, err = host.handleBuiltinFunctionCall(input)
if err != nil {
blockchain.PopSetActiveState()
output.PopSetActiveState()
host.Runtime().AddError(err, input.Function)
vmOutput = host.Output().CreateVMOutputInCaseOfError(err)
isChildComplete = true
Expand All @@ -313,8 +316,10 @@ func (host *vmHost) ExecuteOnDestContext(input *vmcommon.ContractCallInput) (vmO

if err != nil {
blockchain.PopSetActiveState()
output.PopSetActiveState()
} else {
blockchain.PopDiscard()
output.PopDiscard()
}

return
Expand Down Expand Up @@ -598,7 +603,7 @@ func (host *vmHost) ExecuteOnSameContext(input *vmcommon.ContractCallInput) erro

var err error

defer host.finishExecuteOnSameContext(err)
defer func() { host.finishExecuteOnSameContext(err) }()

// Perform a value transfer to the called SC. If the execution fails, this
// transfer will not persist.
Expand Down Expand Up @@ -1267,8 +1272,6 @@ func (host *vmHost) callFunctionAndExecuteAsync() (bool, error) {
runtime := host.Runtime()
async := host.Async()

// TODO refactor this, and apply this condition in other places where a
// function is called
if runtime.FunctionName() != "" {
err := host.verifyAllowedFunctionCall()
if err != nil {
Expand Down Expand Up @@ -1306,11 +1309,11 @@ func (host *vmHost) callFunctionAndExecuteAsync() (bool, error) {
err = async.Save()
return false, err
}
} else {
return false, executor.ErrInvalidFunction

return true, nil
}

return true, nil
return false, executor.ErrInvalidFunction
}

func (host *vmHost) verifyAllowedFunctionCall() error {
Expand Down
3 changes: 1 addition & 2 deletions vmhost/hosttest/execution_gas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1653,8 +1653,7 @@ func testGasUsedESDTTransferThenExecuteAsyncCallChildFails(t *testing.T, isLegac
verify.Ok().
GasRemaining(expectedGasRemaining).
GasUsed(test.ParentAddress, expectedGasUsedByParent).
GasUsed(test.ChildAddress, 0).
Transfers(expectedTransfers...)
GasUsed(test.ChildAddress, 0)

parentESDTBalance, _ := parentAccount.GetTokenBalanceUint64(test.ESDTTestTokenName, 0)
require.Equal(t, initialESDTTokenBalance, parentESDTBalance)
Expand Down
2 changes: 1 addition & 1 deletion vmhost/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ type BlockchainContext interface {
GetUserAccount(address []byte) (vmcommon.UserAccountHandler, error)
ProcessBuiltInFunction(input *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error)
GetSnapshot() int
RevertToSnapshot(snapshot int)
RevertToSnapshot(snapshot int) error
ClearCompiledCodes()
ExecuteSmartContractCallOnOtherVM(input *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error)
}
Expand Down
5 changes: 3 additions & 2 deletions vmhost/mock/blockchainContextMock.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ func (b *BlockchainContextMock) GetSnapshot() int {
}

// RevertToSnapshot -
func (b *BlockchainContextMock) RevertToSnapshot(_ int) {
func (b *BlockchainContextMock) RevertToSnapshot(_ int) error {
return nil
}

// IsLimitedTransfer -
Expand All @@ -237,6 +238,6 @@ func (b *BlockchainContextMock) ClearCompiledCodes() {
}

// ExecuteSmartContractCallOnOtherVM -
func (b *BlockchainContextMock) ExecuteSmartContractCallOnOtherVM(input *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error) {
func (b *BlockchainContextMock) ExecuteSmartContractCallOnOtherVM(_ *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error) {
return nil, nil
}
Loading
Loading