From 59b1e2545cb3099e3586e5c2c4c60e9b2136e93e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Wed, 16 Jul 2025 11:34:46 +0300 Subject: [PATCH 1/4] Fix detection of ineffective "transfer value only" events. --- server/services/constants.go | 1 + server/services/transactionEventsController.go | 2 +- systemtests/check_with_mesh_cli.py | 1 + version/constants.go | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/server/services/constants.go b/server/services/constants.go index 75f52aa6..c0b15cad 100644 --- a/server/services/constants.go +++ b/server/services/constants.go @@ -48,6 +48,7 @@ var ( transactionEventDataExecuteOnDestContext = "ExecuteOnDestContext" transactionEventDataAsyncCall = "AsyncCall" + transactionEventTransferAndExecute = "TransferAndExecute" ) var ( diff --git a/server/services/transactionEventsController.go b/server/services/transactionEventsController.go index f8841f6f..8b640594 100644 --- a/server/services/transactionEventsController.go +++ b/server/services/transactionEventsController.go @@ -77,7 +77,7 @@ func (controller *transactionEventsController) decideEffectiveEventTransferValue return nil, nil } - if string(event.Data) != transactionEventDataExecuteOnDestContext && string(event.Data) != transactionEventDataAsyncCall { + if string(event.Data) != transactionEventDataExecuteOnDestContext && string(event.Data) != transactionEventDataAsyncCall && string(event.Data) != transactionEventTransferAndExecute { // Ineffective event, since the balance change is already captured by a SCR. return nil, nil } diff --git a/systemtests/check_with_mesh_cli.py b/systemtests/check_with_mesh_cli.py index 90a25aea..939b0766 100644 --- a/systemtests/check_with_mesh_cli.py +++ b/systemtests/check_with_mesh_cli.py @@ -76,6 +76,7 @@ def run_rosetta(configuration: Configuration, shard: int): f"--first-historical-epoch={current_epoch}", f"--num-historical-epochs={configuration.num_historical_epochs}", f"--activation-epoch-spica={configuration.activation_epoch_spica}", + "--log-level=*:DEBUG", "--handle-contracts", "--pprof" ] diff --git a/version/constants.go b/version/constants.go index d84af677..b7edbdc9 100644 --- a/version/constants.go +++ b/version/constants.go @@ -7,5 +7,5 @@ const ( var ( // RosettaMiddlewareVersion is the version of this package (application) - RosettaMiddlewareVersion = "v0.7.0" + RosettaMiddlewareVersion = "v0.7.1" ) From 7d2ee7f70265f8467e46224e2ba9cd27149414e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Wed, 16 Jul 2025 13:06:21 +0300 Subject: [PATCH 2/4] Add unit test. --- .../transactionEventsController_test.go | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/server/services/transactionEventsController_test.go b/server/services/transactionEventsController_test.go index c91e4079..7888f4a7 100644 --- a/server/services/transactionEventsController_test.go +++ b/server/services/transactionEventsController_test.go @@ -235,6 +235,35 @@ func TestTransactionEventsController_ExtractEvents(t *testing.T) { require.Equal(t, "100", events[0].value) }) + t.Run("transferValueOnly, after Sirius, effective (intra-shard TransferAndExecute)", func(t *testing.T) { + topic0 := big.NewInt(100).Bytes() + topic1 := testscommon.TestContractBarShard0.PubKey + + tx := &transaction.ApiTransactionResult{ + Epoch: 43, + Logs: &transaction.ApiLogs{ + Events: []*transaction.Events{ + { + Identifier: "transferValueOnly", + Address: testscommon.TestContractFooShard0.Address, + Topics: [][]byte{ + topic0, + topic1, + }, + Data: []byte("TransferAndExecute"), + }, + }, + }, + } + + events, err := controller.extractEventTransferValueOnly(tx) + require.NoError(t, err) + require.Len(t, events, 1) + require.Equal(t, testscommon.TestContractFooShard0.Address, events[0].sender) + require.Equal(t, testscommon.TestContractBarShard0.Address, events[0].receiver) + require.Equal(t, "100", events[0].value) + }) + t.Run("transferValueOnly, after Sirius, ineffective (cross-shard AsyncCall)", func(t *testing.T) { topic0 := big.NewInt(100).Bytes() topic1 := testscommon.TestContractBarShard1.PubKey From 6c96963aad44fb20e843f8372e921399fa5e41e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Wed, 16 Jul 2025 13:32:33 +0300 Subject: [PATCH 3/4] Fix after review. --- server/services/constants.go | 4 ++-- server/services/transactionEventsController.go | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/server/services/constants.go b/server/services/constants.go index c0b15cad..c8657979 100644 --- a/server/services/constants.go +++ b/server/services/constants.go @@ -29,7 +29,7 @@ var ( durationAlarmThresholdAccountServiceGetAccountBalance = time.Duration(500) * time.Millisecond ) -var ( +const ( transactionEventSignalError = core.SignalErrorOperation transactionEventSCDeploy = core.SCDeployIdentifier transactionEventTransferValueOnly = "transferValueOnly" @@ -51,7 +51,7 @@ var ( transactionEventTransferAndExecute = "TransferAndExecute" ) -var ( +const ( numTopicsOfEventESDTTransfer = 4 numTopicsPerTransferOfEventMultiESDTNFTTransfer = 3 numTopicsOfEventESDTLocalBurn = 3 diff --git a/server/services/transactionEventsController.go b/server/services/transactionEventsController.go index 8b640594..df3196e2 100644 --- a/server/services/transactionEventsController.go +++ b/server/services/transactionEventsController.go @@ -77,7 +77,8 @@ func (controller *transactionEventsController) decideEffectiveEventTransferValue return nil, nil } - if string(event.Data) != transactionEventDataExecuteOnDestContext && string(event.Data) != transactionEventDataAsyncCall && string(event.Data) != transactionEventTransferAndExecute { + eventData := string(event.Data) + if eventData != transactionEventDataExecuteOnDestContext && eventData != transactionEventDataAsyncCall && eventData != transactionEventTransferAndExecute { // Ineffective event, since the balance change is already captured by a SCR. return nil, nil } From ce2a5d2d58e6b2a7cc9c6294c3d8a4bb5092b179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Wed, 16 Jul 2025 13:36:53 +0300 Subject: [PATCH 4/4] Fix after review. --- server/services/constants.go | 2 +- server/services/transactionEventsController.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/services/constants.go b/server/services/constants.go index c8657979..0f890566 100644 --- a/server/services/constants.go +++ b/server/services/constants.go @@ -48,7 +48,7 @@ const ( transactionEventDataExecuteOnDestContext = "ExecuteOnDestContext" transactionEventDataAsyncCall = "AsyncCall" - transactionEventTransferAndExecute = "TransferAndExecute" + transactionEventDataTransferAndExecute = "TransferAndExecute" ) const ( diff --git a/server/services/transactionEventsController.go b/server/services/transactionEventsController.go index df3196e2..20c79811 100644 --- a/server/services/transactionEventsController.go +++ b/server/services/transactionEventsController.go @@ -78,7 +78,7 @@ func (controller *transactionEventsController) decideEffectiveEventTransferValue } eventData := string(event.Data) - if eventData != transactionEventDataExecuteOnDestContext && eventData != transactionEventDataAsyncCall && eventData != transactionEventTransferAndExecute { + if eventData != transactionEventDataExecuteOnDestContext && eventData != transactionEventDataAsyncCall && eventData != transactionEventDataTransferAndExecute { // Ineffective event, since the balance change is already captured by a SCR. return nil, nil }