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

Epoch field in transactions and scresult structure #323

Merged
merged 4 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions data/scresult.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type ScResult struct {
CanBeIgnored bool `json:"canBeIgnored,omitempty"`
OriginalSender string `json:"originalSender,omitempty"`
HasLogs bool `json:"hasLogs,omitempty"`
Epoch uint32 `json:"epoch"`
ExecutionOrder int `json:"-"`
SenderAddressBytes []byte `json:"-"`
InitialTxGasUsed uint64 `json:"-"`
Expand Down
1 change: 1 addition & 0 deletions data/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type Transaction struct {
RelayedAddr string `json:"relayer,omitempty"`
RelayedSignature string `json:"relayerSignature,omitempty"`
HadRefund bool `json:"hadRefund,omitempty"`
Epoch uint32 `json:"epoch"`
ExecutionOrder int `json:"-"`
SmartContractResults []*ScResult `json:"-"`
Hash string `json:"-"`
Expand Down
3 changes: 2 additions & 1 deletion integrationtests/testdata/claimRewards/tx-claim-rewards.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"operation": "transfer",
"function": "claimRewards",
"isScCall": true,
"hasLogs": true
"hasLogs": true,
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@
1e-17
],
"type": "normal",
"operation": "ESDTTransfer"
"operation": "ESDTTransfer",
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@
1e-17
],
"type": "normal",
"operation": "ESDTTransfer"
"operation": "ESDTTransfer",
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@
"receiverShard": 1,
"operation": "ESDTTransfer",
"status": "success",
"searchOrder": 0
"searchOrder": 0,
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@
"receiverShard": 1,
"operation": "ESDTTransfer",
"status": "success",
"searchOrder": 0
"searchOrder": 0,
"epoch": 0
}
3 changes: 2 additions & 1 deletion integrationtests/testdata/esdtTransfer/esdt-transfer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
"esdtValuesNum": [
1e-17
],
"operation": "ESDTTransfer"
"operation": "ESDTTransfer",
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@
"operation": "MultiESDTNFTTransfer",
"status": "fail",
"searchOrder": 0,
"errorEvent": true
"errorEvent": true,
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@
"receiverShard": 0,
"operation": "MultiESDTNFTTransfer",
"status": "success",
"searchOrder": 0
"searchOrder": 0,
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@
],
"operation": "ESDTNFTTransfer",
"type": "normal",
"function": "compoundRewardsProxy"
"function": "compoundRewardsProxy",
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
"status": "fail",
"initialPaidFee": "595490000000000",
"searchOrder": 0,
"errorEvent": true
"errorEvent": true,
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
2
],
"operation": "ESDTNFTTransfer",
"errorEvent": true
"errorEvent": true,
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
1
],
"operation": "ESDTNFTTransfer",
"function": "compoundRewardsProxy"
"function": "compoundRewardsProxy",
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
"timestamp": 5040,
"status": "success",
"initialPaidFee": "1904415000000000",
"searchOrder": 0
"searchOrder": 0,
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"timestamp": 0,
"status": "",
"searchOrder": 0,
"completedEvent": true
"completedEvent": true,
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
"receiverShard": 0,
"operation": "ESDTNFTTransfer",
"status": "success",
"searchOrder": 0
"searchOrder": 0,
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@
"gasPrice": 1000000000,
"timestamp": 5040,
"status": "success",
"searchOrder": 0
"searchOrder": 0,
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"timestamp": 0,
"status": "fail",
"searchOrder": 0,
"errorEvent": true
"errorEvent": true,
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
2
],
"operation": "ESDTNFTTransfer",
"function": "claimRewards"
"function": "claimRewards",
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
],
"operation": "transfer",
"function": "saveAttestation",
"isRelayed": true
"isRelayed": true,
"epoch": 0
}
3 changes: 2 additions & 1 deletion integrationtests/testdata/relayedTx/relayed-tx-intra.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
1
],
"operation": "SaveKeyValue",
"isRelayed": true
"isRelayed": true,
"epoch": 0
}
3 changes: 2 additions & 1 deletion integrationtests/testdata/relayedTx/relayed-tx-source.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
],
"operation": "transfer",
"function": "saveAttestation",
"isRelayed": true
"isRelayed": true,
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
"hasScResults": true,
"operation": "transfer",
"isScCall": true,
"function": "claimRewards"
"function": "claimRewards",
"epoch": 0
}
3 changes: 2 additions & 1 deletion integrationtests/testdata/scCallIntraShard/sc-call-fail.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
"function": "delegate",
"errorEvent": true,
"hasLogs": true,
"hasOperations": true
"hasOperations": true,
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"type": "unsigned",
"status": "success",
"operation": "transfer",
"hasLogs": true
"hasLogs": true,
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"timestamp": 5040,
"type": "unsigned",
"status": "pending",
"operation": "transfer"
"operation": "transfer",
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
"type": "unsigned",
"status": "success",
"operation": "transfer",
"function": "issueNonFungible"
"function": "issueNonFungible",
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
"type": "unsigned",
"status": "pending",
"operation": "transfer",
"function": "issueNonFungible"
"function": "issueNonFungible",
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"isScCall": true,
"operation": "transfer",
"function": "issueToken",
"errorEvent": true
"errorEvent": true,
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"hasScResults": true,
"isScCall": true,
"operation": "transfer",
"function": "issueToken"
"function": "issueToken",
"epoch": 0
}

Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"operation": "transfer",
"function": "issueToken",
"errorEvent": true,
"type": "normal"
"type": "normal",
"epoch": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
"type": "normal",
"operation": "scDeploy",
"errorEvent": true,
"completedEvent": true
"completedEvent": true,
"epoch": 0
}
3 changes: 2 additions & 1 deletion integrationtests/testdata/scDeploy/tx-sc-deploy.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
"status": "success",
"searchOrder": 0,
"isScCall": true,
"operation": "scDeploy"
"operation": "scDeploy",
"epoch": 0
}
3 changes: 2 additions & 1 deletion integrationtests/testdata/transactions/move-balance.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
"timestamp": 5040,
"status": "success",
"searchOrder": 0,
"operation": "transfer"
"operation": "transfer",
"epoch": 0
}
4 changes: 2 additions & 2 deletions process/elasticproc/operations/serialize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func TestOperationsProcessor_SerializeSCRS(t *testing.T) {
err := op.SerializeSCRs(scrs, buffSlice, "operations", 0)
require.Nil(t, err)
require.Equal(t, `{"update":{"_index":"operations","_id":""}}
{"script":{"source":"return"},"upsert":{"uuid":"","nonce":0,"gasLimit":0,"gasPrice":0,"value":"","valueNum":0,"sender":"","receiver":"","senderShard":0,"receiverShard":1,"prevTxHash":"","originalTxHash":"","callType":"","timestamp":0}}
{"script":{"source":"return"},"upsert":{"uuid":"","nonce":0,"gasLimit":0,"gasPrice":0,"value":"","valueNum":0,"sender":"","receiver":"","senderShard":0,"receiverShard":1,"prevTxHash":"","originalTxHash":"","callType":"","timestamp":0,"epoch":0}}
{ "index" : { "_index":"operations","_id" : "" } }
{"uuid":"","nonce":0,"gasLimit":0,"gasPrice":0,"value":"","valueNum":0,"sender":"","receiver":"","senderShard":2,"receiverShard":0,"prevTxHash":"","originalTxHash":"","callType":"","timestamp":0}
{"uuid":"","nonce":0,"gasLimit":0,"gasPrice":0,"value":"","valueNum":0,"sender":"","receiver":"","senderShard":2,"receiverShard":0,"prevTxHash":"","originalTxHash":"","callType":"","timestamp":0,"epoch":0}
`, buffSlice.Buffers()[0].String())
}
10 changes: 5 additions & 5 deletions process/elasticproc/transactions/serialize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func TestSerializeScResults(t *testing.T) {
require.Equal(t, 1, len(buffSlice.Buffers()))

expectedRes := `{ "index" : { "_index": "transactions", "_id" : "hash1" } }
{"uuid":"","nonce":1,"gasLimit":50,"gasPrice":10,"value":"100","valueNum":1e-16,"sender":"","receiver":"","senderShard":0,"receiverShard":1,"prevTxHash":"","originalTxHash":"","callType":"","timestamp":0}
{"uuid":"","nonce":1,"gasLimit":50,"gasPrice":10,"value":"100","valueNum":1e-16,"sender":"","receiver":"","senderShard":0,"receiverShard":1,"prevTxHash":"","originalTxHash":"","callType":"","timestamp":0,"epoch":0}
{ "index" : { "_index": "transactions", "_id" : "hash2" } }
{"uuid":"","nonce":2,"gasLimit":50,"gasPrice":10,"value":"20","valueNum":2e-17,"sender":"","receiver":"","senderShard":2,"receiverShard":3,"prevTxHash":"","originalTxHash":"","callType":"","timestamp":0}
{"uuid":"","nonce":2,"gasLimit":50,"gasPrice":10,"value":"20","valueNum":2e-17,"sender":"","receiver":"","senderShard":2,"receiverShard":3,"prevTxHash":"","originalTxHash":"","callType":"","timestamp":0,"epoch":0}
`
require.Equal(t, expectedRes, buffSlice.Buffers()[0].String())
}
Expand Down Expand Up @@ -86,7 +86,7 @@ func TestSerializeTransactionsIntraShardTx(t *testing.T) {
require.Nil(t, err)

expectedBuff := `{ "index" : { "_index":"transactions", "_id" : "txHash" } }
{"uuid":"","miniBlockHash":"","nonce":0,"round":0,"value":"","valueNum":0,"receiver":"","sender":"","receiverShard":0,"senderShard":0,"gasPrice":0,"gasLimit":0,"gasUsed":0,"fee":"","feeNum":0,"data":null,"signature":"","timestamp":0,"status":"","searchOrder":0}
{"uuid":"","miniBlockHash":"","nonce":0,"round":0,"value":"","valueNum":0,"receiver":"","sender":"","receiverShard":0,"senderShard":0,"gasPrice":0,"gasLimit":0,"gasUsed":0,"fee":"","feeNum":0,"data":null,"signature":"","timestamp":0,"status":"","searchOrder":0,"epoch":0}
`
require.Equal(t, expectedBuff, buffSlice.Buffers()[0].String())
}
Expand All @@ -105,7 +105,7 @@ func TestSerializeTransactionCrossShardTxSource(t *testing.T) {
require.Nil(t, err)

expectedBuff := `{"update":{ "_index":"transactions", "_id":"txHash"}}
{"script":{"source":"return"},"upsert":{"uuid":"","miniBlockHash":"","nonce":0,"round":0,"value":"","valueNum":0,"receiver":"","sender":"","receiverShard":1,"senderShard":0,"gasPrice":0,"gasLimit":0,"gasUsed":0,"fee":"","feeNum":0,"data":null,"signature":"","timestamp":0,"status":"","searchOrder":0,"version":1}}
{"script":{"source":"return"},"upsert":{"uuid":"","miniBlockHash":"","nonce":0,"round":0,"value":"","valueNum":0,"receiver":"","sender":"","receiverShard":1,"senderShard":0,"gasPrice":0,"gasLimit":0,"gasUsed":0,"fee":"","feeNum":0,"data":null,"signature":"","timestamp":0,"status":"","searchOrder":0,"version":1,"epoch":0}}
`
require.Equal(t, expectedBuff, buffSlice.Buffers()[0].String())
}
Expand All @@ -124,7 +124,7 @@ func TestSerializeTransactionsCrossShardTxDestination(t *testing.T) {
require.Nil(t, err)

expectedBuff := `{ "index" : { "_index":"transactions", "_id" : "txHash" } }
{"uuid":"","miniBlockHash":"","nonce":0,"round":0,"value":"","valueNum":0,"receiver":"","sender":"","receiverShard":0,"senderShard":1,"gasPrice":0,"gasLimit":0,"gasUsed":0,"fee":"","feeNum":0,"data":null,"signature":"","timestamp":0,"status":"","searchOrder":0,"version":1}
{"uuid":"","miniBlockHash":"","nonce":0,"round":0,"value":"","valueNum":0,"receiver":"","sender":"","receiverShard":0,"senderShard":1,"gasPrice":0,"gasLimit":0,"gasUsed":0,"fee":"","feeNum":0,"data":null,"signature":"","timestamp":0,"status":"","searchOrder":0,"version":1,"epoch":0}
`
require.Equal(t, expectedBuff, buffSlice.Buffers()[0].String())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ func (proc *smartContractResultsProcessor) prepareSmartContractResult(
GasRefunded: feeInfo.GasRefunded,
ExecutionOrder: int(scrInfo.ExecutionOrder),
UUID: converters.GenerateBase64UUID(),
Epoch: header.GetEpoch(),
}
}

Expand Down
2 changes: 2 additions & 0 deletions process/elasticproc/transactions/transactionDBBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func (dtb *dbTransactionBuilder) prepareTransaction(
RelayedAddr: relayedAddress,
HadRefund: feeInfo.HadRefund,
UUID: converters.GenerateBase64UUID(),
Epoch: header.GetEpoch(),
}

hasValidRelayer := len(eTx.RelayedAddr) == len(eTx.Sender) && len(eTx.RelayedAddr) > 0
Expand Down Expand Up @@ -178,6 +179,7 @@ func (dtb *dbTransactionBuilder) prepareRewardTransaction(
Operation: rewardsOperation,
ExecutionOrder: int(rTxInfo.ExecutionOrder),
UUID: converters.GenerateBase64UUID(),
Epoch: header.GetEpoch(),
}
}

Expand Down
Loading