Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge spica relayed into sovereign 31 ian #327

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a11848c
Update Dockerfile
liviuf-ancas Oct 23, 2024
958a5d1
Merge pull request #302 from liviuf-ancas/patch-1
iulianpascalau Oct 29, 2024
aefc89c
Merge branch 'master' of https://github.com/multiversx/mx-chain-es-in…
sstanculeanu Nov 13, 2024
5390238
Merge pull request #305 from multiversx/merge_master_into_rc17next1_2…
sstanculeanu Nov 13, 2024
0a285b4
Merge pull request #276 from multiversx/rc/v1.7.next1
sstanculeanu Nov 13, 2024
956a1f2
relayed v3 indexer integration
miiu96 Nov 18, 2024
86138b4
exclude dynamic meta esdt
miiu96 Nov 22, 2024
9a1f9ea
Merge pull request #307 from multiversx/bug-fix-dynamic-meta-esdts-to…
miiu96 Nov 26, 2024
7f83bb2
revert changes transaction status
miiu96 Dec 5, 2024
d143226
integration test
miiu96 Dec 5, 2024
e6d4a77
empty line
miiu96 Dec 5, 2024
9801073
fixes
miiu96 Dec 5, 2024
756c70a
Merge pull request #316 from multiversx/revert-status-success-for-txs…
miiu96 Dec 6, 2024
93a05cc
Merge branch 'master' into relayed-tx-v3-integration
miiu96 Dec 27, 2024
ceaca49
updated core-go
sstanculeanu Jan 9, 2025
5b15bfa
Merge pull request #318 from multiversx/update-core-go
sstanculeanu Jan 9, 2025
0d2cff5
multiple scrs with refund
miiu96 Jan 15, 2025
62f5c34
had refund
miiu96 Jan 16, 2025
5e055ee
Merge pull request #319 from multiversx/relayed-v3-multiple-scrs-with…
miiu96 Jan 16, 2025
7ad2530
Merge pull request #306 from multiversx/relayed-tx-v3-integration
sstanculeanu Jan 16, 2025
e8de81a
updated core go
sstanculeanu Jan 16, 2025
eb549ea
Merge pull request #321 from multiversx/update_core
sstanculeanu Jan 16, 2025
92a0eb0
extra info error message
miiu96 Jan 22, 2025
c658f09
log error
miiu96 Jan 22, 2025
b9d3793
fixes
miiu96 Jan 23, 2025
345ad47
Merge pull request #324 from multiversx/extra-info-spica-patch-relaye…
sstanculeanu Jan 27, 2025
e90867f
Merge remote-tracking branch 'origin/rc/spica-patch-relayedv3' into m…
axenteoctavian Jan 31, 2025
5d843ef
go mod for sovereign
axenteoctavian Jan 31, 2025
72295e5
integration tests fix from past commit
axenteoctavian Jan 31, 2025
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN apt-get update && apt-get install -y
RUN useradd -m -u 1000 appuser
USER appuser

COPY --from=builder /multiversx/cmd/elasticindexer /multiversx
COPY --from=builder --chown=appuser /multiversx/cmd/elasticindexer /multiversx

EXPOSE 22111

Expand Down
6 changes: 4 additions & 2 deletions client/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ type Item struct {
Type string `json:"type"`
Reason string `json:"reason"`
Cause struct {
Type string `json:"type"`
Reason string `json:"reason"`
Type string `json:"type"`
Reason string `json:"reason"`
ScriptStack []string `json:"script_stack"`
Script string `json:"script"`
} `json:"caused_by"`
} `json:"error"`
}
4 changes: 2 additions & 2 deletions client/elasticClientCommon.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ func extractErrorFromBulkBodyResponseBytes(bodyBytes []byte) error {
}

count++
errorsString += fmt.Sprintf(`{ "index": "%s", "id": "%s", "statusCode": %d, "errorType": "%s", "reason": "%s", "causedBy": { "type": "%s", "reason": "%s" }}\n`,
selectedItem.Index, selectedItem.ID, selectedItem.Status, selectedItem.Error.Type, selectedItem.Error.Reason, selectedItem.Error.Cause.Type, selectedItem.Error.Cause.Reason)
errorsString += fmt.Sprintf(`{ "index": "%s", "id": "%s", "statusCode": %d, "errorType": "%s", "reason": "%s", "causedBy": { "type": "%s", "reason": "%s", "script_stack":"%s", "script":"%s" }}\n`,
selectedItem.Index, selectedItem.ID, selectedItem.Status, selectedItem.Error.Type, selectedItem.Error.Reason, selectedItem.Error.Cause.Type, selectedItem.Error.Cause.Reason, selectedItem.Error.Cause.ScriptStack, selectedItem.Error.Cause.Script)

if count == numOfErrorsToExtractBulkResponse {
break
Expand Down
1 change: 1 addition & 0 deletions data/scresult.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ type ScResult struct {
SenderAddressBytes []byte `json:"-"`
InitialTxGasUsed uint64 `json:"-"`
InitialTxFee string `json:"-"`
GasRefunded uint64 `json:"-"`
}
7 changes: 5 additions & 2 deletions data/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import (
"github.com/multiversx/mx-chain-core-go/core"
)

const metaESDT = "MetaESDT"
const (
metaESDT = "MetaESDT"
dynamicMetaESDT = "DynamicMetaESDT"
)

// NFTDataUpdate will contain the update information for an NFT or SFT
type NFTDataUpdate struct {
Expand Down Expand Up @@ -129,7 +132,7 @@ func (ti *tokensInfo) GetAll() []*TokenInfo {
func (ti *tokensInfo) GetAllWithoutMetaESDT() []*TokenInfo {
tokens := make([]*TokenInfo, 0)
for _, tokenData := range ti.tokensInfo {
if tokenData.Type == metaESDT {
if tokenData.Type == metaESDT || tokenData.Type == dynamicMetaESDT {
continue
}

Expand Down
14 changes: 8 additions & 6 deletions data/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ type Transaction struct {
GuardianSignature string `json:"guardianSignature,omitempty"`
ErrorEvent bool `json:"errorEvent,omitempty"`
CompletedEvent bool `json:"completedEvent,omitempty"`
RelayedAddr string `json:"relayed,omitempty"`
RelayedAddr string `json:"relayer,omitempty"`
RelayedSignature string `json:"relayerSignature,omitempty"`
HadRefund bool `json:"hadRefund,omitempty"`
ExecutionOrder int `json:"-"`
SmartContractResults []*ScResult `json:"-"`
Hash string `json:"-"`
BlockHash string `json:"-"`
HadRefund bool `json:"-"`
}

// Receipt is a structure containing all the fields that need to be safe for a Receipt
Expand Down Expand Up @@ -88,8 +89,9 @@ type ResponseTransactionDB struct {

// FeeData is the structure that contains data about transaction fee and gas used
type FeeData struct {
FeeNum float64
Fee string
GasUsed uint64
Receiver string
FeeNum float64
Fee string
GasUsed uint64
Receiver string
GasRefunded uint64
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ require (
github.com/gin-contrib/cors v1.4.0
github.com/gin-gonic/gin v1.9.1
github.com/multiversx/mx-chain-communication-go v1.1.0
github.com/multiversx/mx-chain-core-go v1.2.23-0.20241007113300-50ac1ae23824
github.com/multiversx/mx-chain-core-go v1.2.25-0.20250131091121-26781bb55fe9
github.com/multiversx/mx-chain-logger-go v1.0.15
github.com/multiversx/mx-chain-vm-common-go v1.5.17-0.20241008143259-334f3a5bafe0
github.com/multiversx/mx-chain-vm-common-go v1.5.17-0.20241119132002-2fa80c5ec516
github.com/prometheus/client_model v0.4.0
github.com/prometheus/common v0.37.0
github.com/stretchr/testify v1.8.4
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,13 @@ github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
github.com/multiversx/mx-chain-communication-go v1.1.0 h1:J7bX6HoN3HiHY7cUeEjG8AJWgQDDPcY+OPDOsSUOkRE=
github.com/multiversx/mx-chain-communication-go v1.1.0/go.mod h1:WK6bP4pGEHGDDna/AYRIMtl6G9OA0NByI1Lw8PmOnRM=
github.com/multiversx/mx-chain-core-go v1.2.23-0.20241007113300-50ac1ae23824 h1:OHYcWOeTNwSaTMRAfusu6/1zoTWGEtHKPBig4dbRAwM=
github.com/multiversx/mx-chain-core-go v1.2.23-0.20241007113300-50ac1ae23824/go.mod h1:P/YBoFnt25XUaCQ7Q/SD15vhnc9yV5JDhHxyFO9P8Z0=
github.com/multiversx/mx-chain-core-go v1.2.25-0.20250131091121-26781bb55fe9 h1:hm9b1I3ywGV6vOMFX86sZ5jZ7hdIqq1IH8EPNj0Pliw=
github.com/multiversx/mx-chain-core-go v1.2.25-0.20250131091121-26781bb55fe9/go.mod h1:P/YBoFnt25XUaCQ7Q/SD15vhnc9yV5JDhHxyFO9P8Z0=
github.com/multiversx/mx-chain-crypto-go v1.2.12 h1:zWip7rpUS4CGthJxfKn5MZfMfYPjVjIiCID6uX5BSOk=
github.com/multiversx/mx-chain-logger-go v1.0.15 h1:HlNdK8etyJyL9NQ+6mIXyKPEBo+wRqOwi3n+m2QIHXc=
github.com/multiversx/mx-chain-logger-go v1.0.15/go.mod h1:t3PRKaWB1M+i6gUfD27KXgzLJJC+mAQiN+FLlL1yoGQ=
github.com/multiversx/mx-chain-vm-common-go v1.5.17-0.20241008143259-334f3a5bafe0 h1:WpfFe6ueS+nRIq2RzVaeF1/TJStyYH/YLYPCmN8kdDM=
github.com/multiversx/mx-chain-vm-common-go v1.5.17-0.20241008143259-334f3a5bafe0/go.mod h1:IOE+gYAtTEKZJwUr9ZhOnjdf4vFKrZdZ9RVEyuFsEP4=
github.com/multiversx/mx-chain-vm-common-go v1.5.17-0.20241119132002-2fa80c5ec516 h1:PToP1B7aFkXjQBOF5MDCCvsc+ffWVqqBHtmemfCwVA8=
github.com/multiversx/mx-chain-vm-common-go v1.5.17-0.20241119132002-2fa80c5ec516/go.mod h1:C7KVj6/+TAhxDjgY7oAMO5wSj7WbBYIJ5TCMzmxk2w0=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
Expand Down
139 changes: 139 additions & 0 deletions integrationtests/relayedV3_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
//go:build integrationtests

package integrationtests

import (
"context"
"encoding/hex"
"math/big"
"testing"

dataBlock "github.com/multiversx/mx-chain-core-go/data/block"
"github.com/multiversx/mx-chain-core-go/data/outport"
"github.com/multiversx/mx-chain-core-go/data/smartContractResult"
"github.com/multiversx/mx-chain-core-go/data/transaction"
indexerdata "github.com/multiversx/mx-chain-es-indexer-go/process/dataindexer"
"github.com/stretchr/testify/require"
)

func TestRelayedV3TransactionWithMultipleRefunds(t *testing.T) {
setLogLevelDebug()

esClient, err := createESClient(esURL)
require.Nil(t, err)

esProc, err := CreateElasticProcessor(esClient)
require.Nil(t, err)

txHash := []byte("relayedTxV3WithMultipleRefunds")
header := &dataBlock.Header{
Round: 50,
TimeStamp: 5040,
}

body := &dataBlock.Body{
MiniBlocks: dataBlock.MiniBlockSlice{
{
Type: dataBlock.TxBlock,
SenderShardID: 0,
ReceiverShardID: 0,
TxHashes: [][]byte{txHash},
},
},
}

initialTx := &transaction.Transaction{
Nonce: 1000,
SndAddr: decodeAddress("erd1ykqd64fxxpp4wsz0v7sjqem038wfpzlljhx4mhwx8w9lcxmdzcfszrp64a"),
RcvAddr: decodeAddress("erd1qqqqqqqqqqqqqpgqak8zt22wl2ph4tswtyc39namqx6ysa2sd8ss4xmlj3"),
RelayerAddr: decodeAddress("erd10ksryjr065ad5475jcg82pnjfg9j9qtszjsrp24anl6ym7cmeddshwnru8"),
Signature: []byte("d"),
RelayerSignature: []byte("a"),
GasLimit: 500_000_000,
GasPrice: 1000000000,
Value: big.NewInt(0),
Data: []byte("doSomething"),
}

txInfo := &outport.TxInfo{
Transaction: initialTx,
FeeInfo: &outport.FeeInfo{
GasUsed: 180_150_000,
Fee: big.NewInt(2864760000000000),
InitialPaidFee: big.NewInt(2864760000000000),
},
ExecutionOrder: 0,
}

pool := &outport.TransactionPool{
Transactions: map[string]*outport.TxInfo{
hex.EncodeToString(txHash): txInfo,
},
}
err = esProc.SaveTransactions(createOutportBlockWithHeader(body, header, pool, nil, testNumOfShards))
require.Nil(t, err)

ids := []string{hex.EncodeToString(txHash)}
genericResponse := &GenericResponse{}
err = esClient.DoMultiGet(context.Background(), ids, indexerdata.TransactionsIndex, true, genericResponse)
require.Nil(t, err)

require.JSONEq(t,
readExpectedResult("./testdata/relayedTxV3/relayed-v3-no-refund.json"),
string(genericResponse.Docs[0].Source),
)

// execute first SCR with refund
pool = &outport.TransactionPool{
SmartContractResults: map[string]*outport.SCRInfo{
"scrHash": {
SmartContractResult: &smartContractResult.SmartContractResult{
OriginalTxHash: txHash,
},
FeeInfo: &outport.FeeInfo{
GasRefunded: 9_692_000,
Fee: big.NewInt(96920000000000),
},
},
},
}
err = esProc.SaveTransactions(createOutportBlockWithHeader(body, header, pool, nil, testNumOfShards))
require.Nil(t, err)

ids = []string{hex.EncodeToString(txHash)}
genericResponse = &GenericResponse{}
err = esClient.DoMultiGet(context.Background(), ids, indexerdata.TransactionsIndex, true, genericResponse)
require.Nil(t, err)

require.JSONEq(t,
readExpectedResult("./testdata/relayedTxV3/relayed-v3-with-one-refund.json"),
string(genericResponse.Docs[0].Source),
)

// execute second SCR with refund
pool = &outport.TransactionPool{
SmartContractResults: map[string]*outport.SCRInfo{
"scrHash": {
SmartContractResult: &smartContractResult.SmartContractResult{
OriginalTxHash: txHash,
},
FeeInfo: &outport.FeeInfo{
GasRefunded: 9_692_000,
Fee: big.NewInt(96920000000000),
},
},
},
}
err = esProc.SaveTransactions(createOutportBlockWithHeader(body, header, pool, nil, testNumOfShards))
require.Nil(t, err)

ids = []string{hex.EncodeToString(txHash)}
genericResponse = &GenericResponse{}
err = esClient.DoMultiGet(context.Background(), ids, indexerdata.TransactionsIndex, true, genericResponse)
require.Nil(t, err)

require.JSONEq(t,
readExpectedResult("./testdata/relayedTxV3/relayed-v3-with-two-refunds.json"),
string(genericResponse.Docs[0].Source),
)
}
85 changes: 85 additions & 0 deletions integrationtests/scDeploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,88 @@ func TestTransactionWithSCDeploy(t *testing.T) {
string(genericResponse.Docs[0].Source),
)
}

func TestScDeployWithSignalErrorAndCompleteTxEvent(t *testing.T) {
setLogLevelDebug()

esClient, err := createESClient(esURL)
require.Nil(t, err)

esProc, err := CreateElasticProcessor(esClient)
require.Nil(t, err)

txHash := []byte("scDeployHashWithErrorAndCompleteTxEvent")
header := &dataBlock.Header{
Round: 50,
TimeStamp: 5040,
ShardID: 2,
}
body := &dataBlock.Body{
MiniBlocks: dataBlock.MiniBlockSlice{
{
Type: dataBlock.TxBlock,
SenderShardID: 2,
ReceiverShardID: 2,
TxHashes: [][]byte{txHash},
},
},
}
sndAddress := "erd12m3x8jp6dl027pj5f2nw6ght2cyhhjfrs86cdwsa8xn83r375qfqrwpdx0"
tx := &transaction.Transaction{
Nonce: 1,
SndAddr: decodeAddress(sndAddress),
RcvAddr: decodeAddress("erd1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq6gq4hu"),
GasLimit: 1000000000,
GasPrice: 2000000,
Data: []byte("0061736d01000000010d036000006000017f60027f7f00023e0303656e760f6765744e756d417267756d656e7473000103656e760b7369676e616c4572726f72000203656e760e636865636b4e6f5061796d656e74000003030200000503010003060f027f00419980080b7f0041a080080b073705066d656d6f7279020004696e697400030863616c6c4261636b00040a5f5f646174615f656e6403000b5f5f686561705f6261736503010a180212001002100004404180800841191001000b0b0300010b0b210100418080080b1977726f6e67206e756d626572206f6620617267756d656e7473@0500@0502"),
Value: big.NewInt(0),
}

txInfo := &outport.TxInfo{
Transaction: tx,
FeeInfo: &outport.FeeInfo{
GasUsed: 1130820,
Fee: big.NewInt(764698200000000),
InitialPaidFee: big.NewInt(773390000000000),
},
ExecutionOrder: 0,
}

pool := &outport.TransactionPool{
Transactions: map[string]*outport.TxInfo{
hex.EncodeToString(txHash): txInfo,
},
Logs: []*outport.LogData{
{
TxHash: hex.EncodeToString(txHash),
Log: &transaction.Log{
Address: decodeAddress(sndAddress),
Events: []*transaction.Event{
{
Address: decodeAddress(sndAddress),
Identifier: []byte(core.SignalErrorOperation),
Topics: [][]byte{[]byte("h1"), []byte("h1"), []byte("h1")},
},
{
Address: decodeAddress(sndAddress),
Identifier: []byte(core.CompletedTxEventIdentifier),
Topics: [][]byte{[]byte("h2"), []byte("h2"), []byte("h2")},
},
},
},
},
},
}
err = esProc.SaveTransactions(createOutportBlockWithHeader(body, header, pool, nil, testNumOfShards))
require.Nil(t, err)

genericResponse := &GenericResponse{}
ids := []string{hex.EncodeToString(txHash)}
err = esClient.DoMultiGet(context.Background(), ids, indexerData.OperationsIndex, true, genericResponse)
require.Nil(t, err)

require.JSONEq(t,
readExpectedResult("./testdata/scDeploy/tx-deploy-with-error-event.json"),
string(genericResponse.Docs[0].Source),
)
}
28 changes: 28 additions & 0 deletions integrationtests/testdata/relayedTxV3/relayed-v3-no-refund.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"miniBlockHash": "785a251c08b314939528e553ac879dbee0627fbe2b76c0bca601c3f1e7162640",
"nonce": 1000,
"round": 50,
"value": "0",
"valueNum": 0,
"receiver": "erd1qqqqqqqqqqqqqpgqak8zt22wl2ph4tswtyc39namqx6ysa2sd8ss4xmlj3",
"sender": "erd1ykqd64fxxpp4wsz0v7sjqem038wfpzlljhx4mhwx8w9lcxmdzcfszrp64a",
"receiverShard": 0,
"senderShard": 0,
"gasPrice": 1000000000,
"gasLimit": 500000000,
"gasUsed": 180150000,
"fee": "2864760000000000",
"feeNum": 0.00286476,
"initialPaidFee": "2864760000000000",
"data": "ZG9Tb21ldGhpbmc=",
"signature": "64",
"timestamp": 5040,
"status": "success",
"searchOrder": 0,
"isScCall": true,
"operation": "transfer",
"function": "doSomething",
"isRelayed": true,
"relayer": "erd10ksryjr065ad5475jcg82pnjfg9j9qtszjsrp24anl6ym7cmeddshwnru8",
"relayerSignature": "61"
}
Loading