Skip to content

Commit d125bb0

Browse files
authored
Merge pull request #256 from multiversx/rc/v1.7.0
`rc/v1.7.0`
2 parents f891ec5 + 9091e78 commit d125bb0

34 files changed

+558
-92
lines changed

cmd/elasticindexer/config/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
available-indices = [
33
"rating", "transactions", "blocks", "validators", "miniblocks", "rounds", "accounts", "accountshistory",
44
"receipts", "scresults", "accountsesdt", "accountsesdthistory", "epochinfo", "scdeploys", "tokens", "tags",
5-
"logs", "delegators", "operations", "esdts"
5+
"logs", "delegators", "operations", "esdts", "values", "events"
66
]
77
[config.address-converter]
88
length = 32

data/event.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package data
2+
3+
import "time"
4+
5+
// LogEvent is the dto for the log event structure
6+
type LogEvent struct {
7+
ID string `json:"-"`
8+
TxHash string `json:"txHash"`
9+
OriginalTxHash string `json:"originalTxHash,omitempty"`
10+
LogAddress string `json:"logAddress"`
11+
Address string `json:"address"`
12+
Identifier string `json:"identifier"`
13+
Data string `json:"data,omitempty"`
14+
AdditionalData []string `json:"additionalData,omitempty"`
15+
Topics []string `json:"topics"`
16+
Order int `json:"order"`
17+
TxOrder int `json:"txOrder"`
18+
ShardID uint32 `json:"shardID"`
19+
Timestamp time.Duration `json:"timestamp,omitempty"`
20+
}

data/logs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ type PreparedLogsResults struct {
3838
NFTsDataUpdates []*NFTDataUpdate
3939
TokenRolesAndProperties *tokeninfo.TokenRolesAndProperties
4040
DBLogs []*Logs
41+
DBEvents []*LogEvent
4142
}

data/scresult.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type ScResult struct {
3939
CanBeIgnored bool `json:"canBeIgnored,omitempty"`
4040
OriginalSender string `json:"originalSender,omitempty"`
4141
HasLogs bool `json:"hasLogs,omitempty"`
42+
ExecutionOrder int `json:"-"`
4243
SenderAddressBytes []byte `json:"-"`
4344
InitialTxGasUsed uint64 `json:"-"`
4445
InitialTxFee string `json:"-"`

data/transaction.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
)
66

77
// Transaction is a structure containing all the fields that need
8-
// to be saved for a transaction. It has all the default fields
9-
// plus some extra information for ease of search and filter
8+
// to be saved for a transaction. It has all the default fields
9+
// plus some extra information for ease of search and filter
1010
type Transaction struct {
1111
MBHash string `json:"miniBlockHash"`
1212
Nonce uint64 `json:"nonce"`
@@ -48,6 +48,7 @@ type Transaction struct {
4848
GuardianSignature string `json:"guardianSignature,omitempty"`
4949
ErrorEvent bool `json:"errorEvent,omitempty"`
5050
CompletedEvent bool `json:"completedEvent,omitempty"`
51+
ExecutionOrder int `json:"-"`
5152
SmartContractResults []*ScResult `json:"-"`
5253
Hash string `json:"-"`
5354
BlockHash string `json:"-"`

docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
version: "3.0"
21
services:
32
elasticsearch:
43
container_name: es-container

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ require (
66
github.com/elastic/go-elasticsearch/v7 v7.12.0
77
github.com/gin-contrib/cors v1.4.0
88
github.com/gin-gonic/gin v1.9.1
9-
github.com/multiversx/mx-chain-communication-go v1.0.12
10-
github.com/multiversx/mx-chain-core-go v1.2.16
11-
github.com/multiversx/mx-chain-logger-go v1.0.13
12-
github.com/multiversx/mx-chain-vm-common-go v1.5.2
9+
github.com/multiversx/mx-chain-communication-go v1.0.14
10+
github.com/multiversx/mx-chain-core-go v1.2.19
11+
github.com/multiversx/mx-chain-logger-go v1.0.14
12+
github.com/multiversx/mx-chain-vm-common-go v1.5.12
1313
github.com/prometheus/client_model v0.4.0
1414
github.com/prometheus/common v0.37.0
1515
github.com/stretchr/testify v1.8.4

go.sum

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,15 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
247247
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
248248
github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
249249
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
250-
github.com/multiversx/mx-chain-communication-go v1.0.12 h1:67WOaf87gpwouydD1AAOHw5LMGZh7NfITrp/KqFY3Tw=
251-
github.com/multiversx/mx-chain-communication-go v1.0.12/go.mod h1:+oaUowpq+SqrEmAsMPGwhz44g7L81loWb6AiNQU9Ms4=
252-
github.com/multiversx/mx-chain-core-go v1.2.16 h1:m0hUNmZQjGJxKDLQOHoM9jSaeDfVTbyd+mqiS8+NckE=
253-
github.com/multiversx/mx-chain-core-go v1.2.16/go.mod h1:BILOGHUOIG5dNNX8cgkzCNfDaVtoYrJRYcPnpxRMH84=
254-
github.com/multiversx/mx-chain-crypto-go v1.2.8 h1:wOgVlUaO5X4L8iEbFjcQcL8SZvv6WZ7LqH73BiRPhxU=
255-
github.com/multiversx/mx-chain-logger-go v1.0.13 h1:eru/TETo0MkO4ZTnXsQDKf4PBRpAXmqjT02klNT/JnY=
256-
github.com/multiversx/mx-chain-logger-go v1.0.13/go.mod h1:MZJhTAtZTJxT+yK2EHc4ZW3YOHUc1UdjCD0iahRNBZk=
257-
github.com/multiversx/mx-chain-vm-common-go v1.5.2 h1:iRWJNlogjkq9w+pJZIfkVkXQFmMoRxZr6pzCfg2/K68=
258-
github.com/multiversx/mx-chain-vm-common-go v1.5.2/go.mod h1:sqkKMCnwkWl8DURdb9q7pctK8IANghdHY1KJLE0ox2c=
250+
github.com/multiversx/mx-chain-communication-go v1.0.14 h1:YhAUDjBBpc5h5W0A7LHLXUMIMeCgwgGvkqfAPbFqsno=
251+
github.com/multiversx/mx-chain-communication-go v1.0.14/go.mod h1:qYCqgk0h+YpcTA84jHIpCBy6UShRwmXzHSCcdfwNrkw=
252+
github.com/multiversx/mx-chain-core-go v1.2.19 h1:2BaVHkB0tro3cjs5ay2pmLup1loCV0e1p9jV5QW0xqc=
253+
github.com/multiversx/mx-chain-core-go v1.2.19/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE=
254+
github.com/multiversx/mx-chain-crypto-go v1.2.11 h1:MNPJoiTJA5/tedYrI0N22OorbsKDESWG0SF8MCJwcJI=
255+
github.com/multiversx/mx-chain-logger-go v1.0.14 h1:PRMpAvXE7Nec2d//QNmbYfKVHMomOKmcN4UXurQWX9o=
256+
github.com/multiversx/mx-chain-logger-go v1.0.14/go.mod h1:bDfHSdwqIimn7Gp8w+SH5KlDuGzJ//nlyEANAaTSc3o=
257+
github.com/multiversx/mx-chain-vm-common-go v1.5.12 h1:Q8F6DE7XhgHtWgg2rozSv4Tv5fE3ENkJz6mjRoAfht8=
258+
github.com/multiversx/mx-chain-vm-common-go v1.5.12/go.mod h1:Sv6iS1okB6gy3HAsW6KHYtAxShNAfepKLtu//AURI8c=
259259
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
260260
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
261261
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=

integrationtests/accountsBalanceNftTransfer_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func createOutportBlockWithHeader(
3434
TransactionPool: pool,
3535
AlteredAccounts: coreAlteredAccounts,
3636
NumberOfShards: numOfShards,
37+
ShardID: header.GetShardID(),
3738
},
3839
Header: header,
3940
}

integrationtests/logsCrossShard_test.go

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,21 @@ func TestIndexLogSourceShardAndAfterDestinationAndAgainSource(t *testing.T) {
3030
Round: 50,
3131
TimeStamp: 5040,
3232
}
33-
body := &dataBlock.Body{}
33+
34+
txHash := []byte("cross-log")
35+
logID := hex.EncodeToString(txHash)
36+
37+
body := &dataBlock.Body{
38+
MiniBlocks: []*dataBlock.MiniBlock{
39+
{
40+
TxHashes: [][]byte{txHash},
41+
},
42+
},
43+
}
3444

3545
address1 := "erd1ju8pkvg57cwdmjsjx58jlmnuf4l9yspstrhr9tgsrt98n9edpm2qtlgy99"
3646
address2 := "erd1w7jyzuj6cv4ngw8luhlkakatjpmjh3ql95lmxphd3vssc4vpymks6k5th7"
3747

38-
logID := hex.EncodeToString([]byte("cross-log"))
39-
4048
// index on source
4149
pool := &outport.TransactionPool{
4250
Logs: []*outport.LogData{
@@ -55,6 +63,12 @@ func TestIndexLogSourceShardAndAfterDestinationAndAgainSource(t *testing.T) {
5563
},
5664
},
5765
},
66+
Transactions: map[string]*outport.TxInfo{
67+
logID: {
68+
Transaction: &transaction.Transaction{},
69+
ExecutionOrder: 0,
70+
},
71+
},
5872
}
5973
err = esProc.SaveTransactions(createOutportBlockWithHeader(body, header, pool, map[string]*alteredAccount.AlteredAccount{}, testNumOfShards))
6074
require.Nil(t, err)
@@ -68,10 +82,20 @@ func TestIndexLogSourceShardAndAfterDestinationAndAgainSource(t *testing.T) {
6882
string(genericResponse.Docs[0].Source),
6983
)
7084

85+
event1ID := logID + "-0-0"
86+
ids = []string{event1ID}
87+
err = esClient.DoMultiGet(context.Background(), ids, indexerdata.EventsIndex, true, genericResponse)
88+
require.Nil(t, err)
89+
require.JSONEq(t,
90+
readExpectedResult("./testdata/logsCrossShard/event-transfer-source-first.json"),
91+
string(genericResponse.Docs[0].Source),
92+
)
93+
7194
// INDEX ON DESTINATION
7295
header = &dataBlock.Header{
7396
Round: 50,
7497
TimeStamp: 6040,
98+
ShardID: 1,
7599
}
76100
pool = &outport.TransactionPool{
77101
Logs: []*outport.LogData{
@@ -96,17 +120,37 @@ func TestIndexLogSourceShardAndAfterDestinationAndAgainSource(t *testing.T) {
96120
},
97121
},
98122
},
123+
Transactions: map[string]*outport.TxInfo{
124+
logID: {
125+
Transaction: &transaction.Transaction{},
126+
ExecutionOrder: 0,
127+
},
128+
},
99129
}
100130
err = esProc.SaveTransactions(createOutportBlockWithHeader(body, header, pool, map[string]*alteredAccount.AlteredAccount{}, testNumOfShards))
101131
require.Nil(t, err)
102132

133+
ids = []string{logID}
103134
err = esClient.DoMultiGet(context.Background(), ids, indexerdata.LogsIndex, true, genericResponse)
104135
require.Nil(t, err)
105136
require.JSONEq(t,
106137
readExpectedResult("./testdata/logsCrossShard/log-at-destination.json"),
107138
string(genericResponse.Docs[0].Source),
108139
)
109140

141+
event2ID, event3ID := logID+"-1-0", logID+"-1-1"
142+
ids = []string{event2ID, event3ID}
143+
err = esClient.DoMultiGet(context.Background(), ids, indexerdata.EventsIndex, true, genericResponse)
144+
require.Nil(t, err)
145+
require.JSONEq(t,
146+
readExpectedResult("./testdata/logsCrossShard/event-transfer-destination.json"),
147+
string(genericResponse.Docs[0].Source),
148+
)
149+
require.JSONEq(t,
150+
readExpectedResult("./testdata/logsCrossShard/event-do-something.json"),
151+
string(genericResponse.Docs[1].Source),
152+
)
153+
110154
// index on source again should not change the log
111155
header = &dataBlock.Header{
112156
Round: 50,
@@ -129,10 +173,17 @@ func TestIndexLogSourceShardAndAfterDestinationAndAgainSource(t *testing.T) {
129173
},
130174
},
131175
},
176+
Transactions: map[string]*outport.TxInfo{
177+
logID: {
178+
Transaction: &transaction.Transaction{},
179+
ExecutionOrder: 0,
180+
},
181+
},
132182
}
133183
err = esProc.SaveTransactions(createOutportBlockWithHeader(body, header, pool, map[string]*alteredAccount.AlteredAccount{}, testNumOfShards))
134184
require.Nil(t, err)
135185

186+
ids = []string{logID}
136187
err = esClient.DoMultiGet(context.Background(), ids, indexerdata.LogsIndex, true, genericResponse)
137188
require.Nil(t, err)
138189
require.JSONEq(t,
@@ -147,6 +198,7 @@ func TestIndexLogSourceShardAndAfterDestinationAndAgainSource(t *testing.T) {
147198
MiniBlockHeaders: []dataBlock.MiniBlockHeader{
148199
{},
149200
},
201+
ShardID: 1,
150202
}
151203
body = &dataBlock.Body{
152204
MiniBlocks: []*dataBlock.MiniBlock{
@@ -163,4 +215,11 @@ func TestIndexLogSourceShardAndAfterDestinationAndAgainSource(t *testing.T) {
163215
require.Nil(t, err)
164216

165217
require.False(t, genericResponse.Docs[0].Found)
218+
219+
ids = []string{event2ID, event3ID}
220+
err = esClient.DoMultiGet(context.Background(), ids, indexerdata.EventsIndex, true, genericResponse)
221+
require.Nil(t, err)
222+
223+
require.False(t, genericResponse.Docs[0].Found)
224+
require.False(t, genericResponse.Docs[1].Found)
166225
}

0 commit comments

Comments
 (0)