diff --git a/data/account.go b/data/account.go index f28ff087..9f7caf69 100644 --- a/data/account.go +++ b/data/account.go @@ -1,8 +1,6 @@ package data import ( - "time" - "github.com/multiversx/mx-chain-core-go/data/alteredAccount" ) @@ -22,7 +20,8 @@ type AccountInfo struct { DeveloperRewards string `json:"developerRewards,omitempty"` DeveloperRewardsNum float64 `json:"developerRewardsNum,omitempty"` Data *TokenMetaData `json:"data,omitempty"` - Timestamp time.Duration `json:"timestamp,omitempty"` + Timestamp uint64 `json:"timestamp,omitempty"` + TimestampMs uint64 `json:"timestampMs,omitempty"` Type string `json:"type,omitempty"` CurrentOwner string `json:"currentOwner,omitempty"` ShardID uint32 `json:"shardID"` @@ -50,15 +49,16 @@ type TokenMetaData struct { // AccountBalanceHistory represents an entry in the user accounts balances history type AccountBalanceHistory struct { - Address string `json:"address"` - Timestamp time.Duration `json:"timestamp"` - Balance string `json:"balance"` - Token string `json:"token,omitempty"` - Identifier string `json:"identifier,omitempty"` - TokenNonce uint64 `json:"tokenNonce,omitempty"` - IsSender bool `json:"isSender,omitempty"` - IsSmartContract bool `json:"isSmartContract,omitempty"` - ShardID uint32 `json:"shardID"` + Address string `json:"address"` + Timestamp uint64 `json:"timestamp"` + TimestampMs uint64 `json:"timestampMs,omitempty"` + Balance string `json:"balance"` + Token string `json:"token,omitempty"` + Identifier string `json:"identifier,omitempty"` + TokenNonce uint64 `json:"tokenNonce,omitempty"` + IsSender bool `json:"isSender,omitempty"` + IsSmartContract bool `json:"isSmartContract,omitempty"` + ShardID uint32 `json:"shardID"` } // Account is a structure that is needed for regular accounts diff --git a/data/block.go b/data/block.go index e8720aa4..53a92569 100644 --- a/data/block.go +++ b/data/block.go @@ -1,8 +1,6 @@ package data import ( - "time" - "github.com/multiversx/mx-chain-core-go/data/api" ) @@ -24,7 +22,8 @@ type Block struct { PubKeyBitmap string `json:"pubKeyBitmap"` Size int64 `json:"size"` SizeTxs int64 `json:"sizeTxs"` - Timestamp time.Duration `json:"timestamp"` + Timestamp uint64 `json:"timestamp"` + TimestampMs uint64 `json:"timestampMs,omitempty"` StateRootHash string `json:"stateRootHash"` PrevHash string `json:"prevHash"` ShardID uint32 `json:"shardId"` @@ -104,14 +103,15 @@ type EpochStartShardData struct { // Miniblock is a structure containing miniblock information type Miniblock struct { - Hash string `json:"hash,omitempty"` - SenderShardID uint32 `json:"senderShard"` - ReceiverShardID uint32 `json:"receiverShard"` - SenderBlockHash string `json:"senderBlockHash,omitempty"` - ReceiverBlockHash string `json:"receiverBlockHash,omitempty"` - Type string `json:"type"` - ProcessingTypeOnSource string `json:"procTypeS,omitempty"` - ProcessingTypeOnDestination string `json:"procTypeD,omitempty"` - Timestamp time.Duration `json:"timestamp"` - Reserved []byte `json:"reserved,omitempty"` + Hash string `json:"hash,omitempty"` + SenderShardID uint32 `json:"senderShard"` + ReceiverShardID uint32 `json:"receiverShard"` + SenderBlockHash string `json:"senderBlockHash,omitempty"` + ReceiverBlockHash string `json:"receiverBlockHash,omitempty"` + Type string `json:"type"` + ProcessingTypeOnSource string `json:"procTypeS,omitempty"` + ProcessingTypeOnDestination string `json:"procTypeD,omitempty"` + Timestamp uint64 `json:"timestamp"` + TimestampMs uint64 `json:"timestampMs,omitempty"` + Reserved []byte `json:"reserved,omitempty"` } diff --git a/data/data.go b/data/data.go index 2830db27..9f159155 100644 --- a/data/data.go +++ b/data/data.go @@ -2,7 +2,6 @@ package data import ( "encoding/json" - "time" ) // ValidatorsPublicKeys is a structure containing fields for validators public keys @@ -24,12 +23,13 @@ type ValidatorRatingInfo struct { // RoundInfo is a structure containing block signers and shard id type RoundInfo struct { - Round uint64 `json:"round"` - SignersIndexes []uint64 `json:"signersIndexes"` - BlockWasProposed bool `json:"blockWasProposed"` - ShardId uint32 `json:"shardId"` - Epoch uint32 `json:"epoch"` - Timestamp time.Duration `json:"timestamp"` + Round uint64 `json:"round"` + SignersIndexes []uint64 `json:"signersIndexes"` + BlockWasProposed bool `json:"blockWasProposed"` + ShardId uint32 `json:"shardId"` + Epoch uint32 `json:"epoch"` + Timestamp uint64 `json:"timestamp"` + TimestampMs uint64 `json:"timestampMs,omitempty"` } // EpochInfo holds the information about epoch diff --git a/data/delegators.go b/data/delegators.go index d3a2b79b..7d2175e4 100644 --- a/data/delegators.go +++ b/data/delegators.go @@ -1,23 +1,23 @@ package data -import "time" - // Delegator is a structure that is needed to store information about a delegator type Delegator struct { - Address string `json:"address"` - Contract string `json:"contract"` - Timestamp time.Duration `json:"timestamp"` - ActiveStake string `json:"activeStake"` - ActiveStakeNum float64 `json:"activeStakeNum"` - ShouldDelete bool `json:"-"` - UnDelegateInfo *UnDelegate `json:"-"` - WithdrawFundIDs []string `json:"-"` + Address string `json:"address"` + Contract string `json:"contract"` + Timestamp uint64 `json:"timestamp"` + TimestampMs uint64 `json:"timestampMs,omitempty"` + ActiveStake string `json:"activeStake"` + ActiveStakeNum float64 `json:"activeStakeNum"` + ShouldDelete bool `json:"-"` + UnDelegateInfo *UnDelegate `json:"-"` + WithdrawFundIDs []string `json:"-"` } // UnDelegate is a structure that is needed to store information about user unDelegate position type UnDelegate struct { - Timestamp time.Duration `json:"timestamp"` - ID string `json:"id"` - Value string `json:"value"` - ValueNum float64 `json:"valueNum"` + Timestamp uint64 `json:"timestamp"` + TimestampMs uint64 `json:"timestampMs,omitempty"` + ID string `json:"id"` + Value string `json:"value"` + ValueNum float64 `json:"valueNum"` } diff --git a/data/event.go b/data/event.go index a3d113f7..1770db1d 100644 --- a/data/event.go +++ b/data/event.go @@ -1,21 +1,20 @@ package data -import "time" - // LogEvent is the dto for the log event structure type LogEvent struct { - UUID string `json:"uuid"` - ID string `json:"-"` - TxHash string `json:"txHash"` - OriginalTxHash string `json:"originalTxHash,omitempty"` - LogAddress string `json:"logAddress"` - Address string `json:"address"` - Identifier string `json:"identifier"` - Data string `json:"data,omitempty"` - AdditionalData []string `json:"additionalData,omitempty"` - Topics []string `json:"topics"` - Order int `json:"order"` - TxOrder int `json:"txOrder"` - ShardID uint32 `json:"shardID"` - Timestamp time.Duration `json:"timestamp,omitempty"` + UUID string `json:"uuid"` + ID string `json:"-"` + TxHash string `json:"txHash"` + OriginalTxHash string `json:"originalTxHash,omitempty"` + LogAddress string `json:"logAddress"` + Address string `json:"address"` + Identifier string `json:"identifier"` + Data string `json:"data,omitempty"` + AdditionalData []string `json:"additionalData,omitempty"` + Topics []string `json:"topics"` + Order int `json:"order"` + TxOrder int `json:"txOrder"` + ShardID uint32 `json:"shardID"` + Timestamp uint64 `json:"timestamp,omitempty"` + TimestampMs uint64 `json:"timestampMs,omitempty"` } diff --git a/data/logs.go b/data/logs.go index a2a558f3..336c15a6 100644 --- a/data/logs.go +++ b/data/logs.go @@ -1,20 +1,19 @@ package data import ( - "time" - "github.com/multiversx/mx-chain-core-go/data/outport" "github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/tokeninfo" ) // Logs holds all the fields needed for a logs structure type Logs struct { - UUID string `json:"uuid"` - ID string `json:"-"` - OriginalTxHash string `json:"originalTxHash,omitempty"` - Address string `json:"address"` - Events []*Event `json:"events"` - Timestamp time.Duration `json:"timestamp,omitempty"` + UUID string `json:"uuid"` + ID string `json:"-"` + OriginalTxHash string `json:"originalTxHash,omitempty"` + Address string `json:"address"` + Events []*Event `json:"events"` + Timestamp uint64 `json:"timestamp,omitempty"` + TimestampMs uint64 `json:"timestampMs,omitempty"` } // Event holds all the fields needed for an event structure diff --git a/data/scDeploy.go b/data/scDeploy.go index 7a7bb69c..9e82486f 100644 --- a/data/scDeploy.go +++ b/data/scDeploy.go @@ -7,14 +7,16 @@ type ScDeployInfo struct { CurrentOwner string `json:"currentOwner"` CodeHash []byte `json:"initialCodeHash"` Timestamp uint64 `json:"timestamp"` + TimestampMs uint64 `json:"timestampMs,omitempty"` Upgrades []*Upgrade `json:"upgrades"` OwnersHistory []*OwnerData `json:"owners"` } // Upgrade is the DTO that holds information about a smart contract upgrade type Upgrade struct { - TxHash string `json:"upgradeTxHash"` - Upgrader string `json:"upgrader"` - Timestamp uint64 `json:"timestamp"` - CodeHash []byte `json:"codeHash"` + TxHash string `json:"upgradeTxHash"` + Upgrader string `json:"upgrader"` + Timestamp uint64 `json:"timestamp"` + TimestampMs uint64 `json:"timestampMs"` + CodeHash []byte `json:"codeHash"` } diff --git a/data/scresult.go b/data/scresult.go index 7ff11fbf..504002cf 100644 --- a/data/scresult.go +++ b/data/scresult.go @@ -1,49 +1,48 @@ package data -import "time" - // ScResult is a structure containing all the fields that need to be saved for a smart contract result type ScResult struct { - UUID string `json:"uuid"` - Hash string `json:"-"` - MBHash string `json:"miniBlockHash,omitempty"` - Nonce uint64 `json:"nonce"` - GasLimit uint64 `json:"gasLimit"` - GasPrice uint64 `json:"gasPrice"` - Value string `json:"value"` - ValueNum float64 `json:"valueNum"` - Sender string `json:"sender"` - Receiver string `json:"receiver"` - SenderShard uint32 `json:"senderShard"` - ReceiverShard uint32 `json:"receiverShard"` - RelayerAddr string `json:"relayerAddr,omitempty"` - RelayedValue string `json:"relayedValue,omitempty"` - Code string `json:"code,omitempty"` - Data []byte `json:"data,omitempty"` - PrevTxHash string `json:"prevTxHash"` - OriginalTxHash string `json:"originalTxHash"` - CallType string `json:"callType"` - CodeMetadata []byte `json:"codeMetaData,omitempty"` - ReturnMessage string `json:"returnMessage,omitempty"` - Timestamp time.Duration `json:"timestamp"` - HasOperations bool `json:"hasOperations,omitempty"` - Type string `json:"type,omitempty"` - Status string `json:"status,omitempty"` - Tokens []string `json:"tokens,omitempty"` - ESDTValues []string `json:"esdtValues,omitempty"` - ESDTValuesNum []float64 `json:"esdtValuesNum,omitempty"` - Receivers []string `json:"receivers,omitempty"` - ReceiversShardIDs []uint32 `json:"receiversShardIDs,omitempty"` - Operation string `json:"operation,omitempty"` - Function string `json:"function,omitempty"` - IsRelayed bool `json:"isRelayed,omitempty"` - 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:"-"` - InitialTxFee string `json:"-"` - GasRefunded uint64 `json:"-"` + UUID string `json:"uuid"` + Hash string `json:"-"` + MBHash string `json:"miniBlockHash,omitempty"` + Nonce uint64 `json:"nonce"` + GasLimit uint64 `json:"gasLimit"` + GasPrice uint64 `json:"gasPrice"` + Value string `json:"value"` + ValueNum float64 `json:"valueNum"` + Sender string `json:"sender"` + Receiver string `json:"receiver"` + SenderShard uint32 `json:"senderShard"` + ReceiverShard uint32 `json:"receiverShard"` + RelayerAddr string `json:"relayerAddr,omitempty"` + RelayedValue string `json:"relayedValue,omitempty"` + Code string `json:"code,omitempty"` + Data []byte `json:"data,omitempty"` + PrevTxHash string `json:"prevTxHash"` + OriginalTxHash string `json:"originalTxHash"` + CallType string `json:"callType"` + CodeMetadata []byte `json:"codeMetaData,omitempty"` + ReturnMessage string `json:"returnMessage,omitempty"` + Timestamp uint64 `json:"timestamp"` + TimestampMs uint64 `json:"timestampMs,omitempty"` + HasOperations bool `json:"hasOperations,omitempty"` + Type string `json:"type,omitempty"` + Status string `json:"status,omitempty"` + Tokens []string `json:"tokens,omitempty"` + ESDTValues []string `json:"esdtValues,omitempty"` + ESDTValuesNum []float64 `json:"esdtValuesNum,omitempty"` + Receivers []string `json:"receivers,omitempty"` + ReceiversShardIDs []uint32 `json:"receiversShardIDs,omitempty"` + Operation string `json:"operation,omitempty"` + Function string `json:"function,omitempty"` + IsRelayed bool `json:"isRelayed,omitempty"` + 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:"-"` + InitialTxFee string `json:"-"` + GasRefunded uint64 `json:"-"` } diff --git a/data/tokens.go b/data/tokens.go index 967e13ee..dfd0f7af 100644 --- a/data/tokens.go +++ b/data/tokens.go @@ -1,8 +1,6 @@ package data import ( - "time" - "github.com/multiversx/mx-chain-core-go/core" ) @@ -56,7 +54,8 @@ type TokenInfo struct { NumDecimals uint64 `json:"numDecimals"` Type string `json:"type,omitempty"` Nonce uint64 `json:"nonce,omitempty"` - Timestamp time.Duration `json:"timestamp,omitempty"` + Timestamp uint64 `json:"timestamp,omitempty"` + TimestampMs uint64 `json:"timestampMs,omitempty"` Data *TokenMetaData `json:"data,omitempty"` OwnersHistory []*OwnerData `json:"ownersHistory,omitempty"` TransferOwnership bool `json:"-"` @@ -80,9 +79,10 @@ type TokenProperties struct { // OwnerData is a structure that is needed to store information about an owner type OwnerData struct { - TxHash string `json:"txHash,omitempty"` - Address string `json:"address"` - Timestamp time.Duration `json:"timestamp"` + TxHash string `json:"txHash,omitempty"` + Address string `json:"address"` + Timestamp uint64 `json:"timestamp"` + TimestampMs uint64 `json:"timestampMs,omitempty"` } // TokensHandler defines the actions that a tokens' handler should do diff --git a/data/transaction.go b/data/transaction.go index 4e1800ec..845c41c5 100644 --- a/data/transaction.go +++ b/data/transaction.go @@ -1,72 +1,70 @@ package data -import ( - "time" -) - // Transaction is a structure containing all the fields that need // to be saved for a transaction. It has all the default fields // plus some extra information for ease of search and filter type Transaction struct { - UUID string `json:"uuid"` - MBHash string `json:"miniBlockHash"` - Nonce uint64 `json:"nonce"` - Round uint64 `json:"round"` - Value string `json:"value"` - ValueNum float64 `json:"valueNum"` - Receiver string `json:"receiver"` - Sender string `json:"sender"` - ReceiverShard uint32 `json:"receiverShard"` - SenderShard uint32 `json:"senderShard"` - GasPrice uint64 `json:"gasPrice"` - GasLimit uint64 `json:"gasLimit"` - GasUsed uint64 `json:"gasUsed"` - Fee string `json:"fee"` - FeeNum float64 `json:"feeNum"` - InitialPaidFee string `json:"initialPaidFee,omitempty"` - Data []byte `json:"data"` - Signature string `json:"signature"` - Timestamp time.Duration `json:"timestamp"` - Status string `json:"status"` - SearchOrder uint32 `json:"searchOrder"` - SenderUserName []byte `json:"senderUserName,omitempty"` - ReceiverUserName []byte `json:"receiverUserName,omitempty"` - HasSCR bool `json:"hasScResults,omitempty"` - IsScCall bool `json:"isScCall,omitempty"` - HasOperations bool `json:"hasOperations,omitempty"` - HasLogs bool `json:"hasLogs,omitempty"` - Tokens []string `json:"tokens,omitempty"` - ESDTValues []string `json:"esdtValues,omitempty"` - ESDTValuesNum []float64 `json:"esdtValuesNum,omitempty"` - Receivers []string `json:"receivers,omitempty"` - ReceiversShardIDs []uint32 `json:"receiversShardIDs,omitempty"` - Type string `json:"type,omitempty"` - Operation string `json:"operation,omitempty"` - Function string `json:"function,omitempty"` - IsRelayed bool `json:"isRelayed,omitempty"` - Version uint32 `json:"version,omitempty"` - GuardianAddress string `json:"guardian,omitempty"` - GuardianSignature string `json:"guardianSignature,omitempty"` - ErrorEvent bool `json:"errorEvent,omitempty"` - CompletedEvent bool `json:"completedEvent,omitempty"` - 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:"-"` - BlockHash string `json:"-"` + UUID string `json:"uuid"` + MBHash string `json:"miniBlockHash"` + Nonce uint64 `json:"nonce"` + Round uint64 `json:"round"` + Value string `json:"value"` + ValueNum float64 `json:"valueNum"` + Receiver string `json:"receiver"` + Sender string `json:"sender"` + ReceiverShard uint32 `json:"receiverShard"` + SenderShard uint32 `json:"senderShard"` + GasPrice uint64 `json:"gasPrice"` + GasLimit uint64 `json:"gasLimit"` + GasUsed uint64 `json:"gasUsed"` + Fee string `json:"fee"` + FeeNum float64 `json:"feeNum"` + InitialPaidFee string `json:"initialPaidFee,omitempty"` + Data []byte `json:"data"` + Signature string `json:"signature"` + Timestamp uint64 `json:"timestamp"` + TimestampMs uint64 `json:"timestampMs,omitempty"` + Status string `json:"status"` + SearchOrder uint32 `json:"searchOrder"` + SenderUserName []byte `json:"senderUserName,omitempty"` + ReceiverUserName []byte `json:"receiverUserName,omitempty"` + HasSCR bool `json:"hasScResults,omitempty"` + IsScCall bool `json:"isScCall,omitempty"` + HasOperations bool `json:"hasOperations,omitempty"` + HasLogs bool `json:"hasLogs,omitempty"` + Tokens []string `json:"tokens,omitempty"` + ESDTValues []string `json:"esdtValues,omitempty"` + ESDTValuesNum []float64 `json:"esdtValuesNum,omitempty"` + Receivers []string `json:"receivers,omitempty"` + ReceiversShardIDs []uint32 `json:"receiversShardIDs,omitempty"` + Type string `json:"type,omitempty"` + Operation string `json:"operation,omitempty"` + Function string `json:"function,omitempty"` + IsRelayed bool `json:"isRelayed,omitempty"` + Version uint32 `json:"version,omitempty"` + GuardianAddress string `json:"guardian,omitempty"` + GuardianSignature string `json:"guardianSignature,omitempty"` + ErrorEvent bool `json:"errorEvent,omitempty"` + CompletedEvent bool `json:"completedEvent,omitempty"` + 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:"-"` + BlockHash string `json:"-"` } // Receipt is a structure containing all the fields that need to be safe for a Receipt type Receipt struct { - Hash string `json:"-"` - Value string `json:"value"` - Sender string `json:"sender"` - Data string `json:"data,omitempty"` - TxHash string `json:"txHash"` - Timestamp time.Duration `json:"timestamp"` + Hash string `json:"-"` + Value string `json:"value"` + Sender string `json:"sender"` + Data string `json:"data,omitempty"` + TxHash string `json:"txHash"` + Timestamp uint64 `json:"timestamp"` + TimestampMs uint64 `json:"timestampMs,omitempty"` } // PreparedResults is the DTO that holds all the results after processing diff --git a/go.mod b/go.mod index 0aeaf8e3..179e518d 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/gin-gonic/gin v1.10.0 github.com/google/uuid v1.6.0 github.com/multiversx/mx-chain-communication-go v1.2.1-0.20250520083403-3f2bad6d5476 - github.com/multiversx/mx-chain-core-go v1.3.2-0.20250602142114-cb1013453d39 + github.com/multiversx/mx-chain-core-go v1.3.2-0.20250606113953-9e4dc87c16cb github.com/multiversx/mx-chain-logger-go v1.0.16-0.20250520074859-b2faf3c90273 github.com/multiversx/mx-chain-vm-common-go v1.5.17-0.20250520075408-c94bee9ee163 github.com/prometheus/client_model v0.6.1 diff --git a/go.sum b/go.sum index d68cc34c..52258979 100644 --- a/go.sum +++ b/go.sum @@ -130,8 +130,8 @@ 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.2.1-0.20250520083403-3f2bad6d5476 h1:Dn73bH1AdG+7+3/FFRfOiivOEvwPyzZUBWWxpk8QVxc= github.com/multiversx/mx-chain-communication-go v1.2.1-0.20250520083403-3f2bad6d5476/go.mod h1:99+FW6f7X0Ri5tph+2l2GaDVrdej1do89exkfh7gilE= -github.com/multiversx/mx-chain-core-go v1.3.2-0.20250602142114-cb1013453d39 h1:a+98PN1XXTCYiJEdg7gpqfTOxGuQqvA8H1yglidV/p0= -github.com/multiversx/mx-chain-core-go v1.3.2-0.20250602142114-cb1013453d39/go.mod h1:IO+vspNan+gT0WOHnJ95uvWygiziHZvfXpff6KnxV7g= +github.com/multiversx/mx-chain-core-go v1.3.2-0.20250606113953-9e4dc87c16cb h1:orPuViEu3dnElbfp6w2q1iokLQlTueb9akRpxfqe6IU= +github.com/multiversx/mx-chain-core-go v1.3.2-0.20250606113953-9e4dc87c16cb/go.mod h1:IO+vspNan+gT0WOHnJ95uvWygiziHZvfXpff6KnxV7g= github.com/multiversx/mx-chain-crypto-go v1.2.13-0.20250520075055-8ab2a164945d h1:NI5uKpkwP5XZu9gtDiWxmbbb07T9hXegPist17WAzY4= github.com/multiversx/mx-chain-crypto-go v1.2.13-0.20250520075055-8ab2a164945d/go.mod h1:yekQt4uB5LYXtimbhpdUbnFexjucWrQG/t+AX55bdM8= github.com/multiversx/mx-chain-logger-go v1.0.16-0.20250520074859-b2faf3c90273 h1:1I2CgGDAMINxrKI6yzSP/Y6Wow2YUmqegUXcltpGXQA= diff --git a/integrationtests/accountsBalanceNftTransfer_test.go b/integrationtests/accountsBalanceNftTransfer_test.go index aaf44e00..fb289144 100644 --- a/integrationtests/accountsBalanceNftTransfer_test.go +++ b/integrationtests/accountsBalanceNftTransfer_test.go @@ -29,7 +29,8 @@ func createOutportBlockWithHeader( return &outport.OutportBlockWithHeader{ OutportBlock: &outport.OutportBlock{ BlockData: &outport.BlockData{ - Body: body, + Body: body, + TimestampMs: header.GetTimeStamp() * 1000, }, TransactionPool: pool, AlteredAccounts: coreAlteredAccounts, diff --git a/integrationtests/accountsESDTRollback_test.go b/integrationtests/accountsESDTRollback_test.go index 9fd3a06f..ebc704be 100644 --- a/integrationtests/accountsESDTRollback_test.go +++ b/integrationtests/accountsESDTRollback_test.go @@ -91,7 +91,7 @@ func TestAccountsESDTDeleteOnRollback(t *testing.T) { require.JSONEq(t, readExpectedResult("./testdata/accountsESDTRollback/account-after-create.json"), string(genericResponse.Docs[0].Source)) // DO ROLLBACK - err = esProc.RemoveAccountsESDT(5040, 2) + err = esProc.RemoveAccountsESDT(2, 5040000) require.Nil(t, err) err = esClient.DoMultiGet(context.Background(), ids, indexerdata.AccountsESDTIndex, true, genericResponse) diff --git a/integrationtests/delegators_test.go b/integrationtests/delegators_test.go index 3517b26e..1cea825f 100644 --- a/integrationtests/delegators_test.go +++ b/integrationtests/delegators_test.go @@ -132,7 +132,7 @@ func TestDelegateUnDelegateAndWithdraw(t *testing.T) { // revert unDelegate 2 header.TimeStamp = 5060 - err = esProc.RemoveTransactions(header, body) + err = esProc.RemoveTransactions(header, body, 5060000) require.Nil(t, err) time.Sleep(time.Second) diff --git a/integrationtests/logsCrossShard_test.go b/integrationtests/logsCrossShard_test.go index 7c96688f..002e792e 100644 --- a/integrationtests/logsCrossShard_test.go +++ b/integrationtests/logsCrossShard_test.go @@ -208,7 +208,7 @@ func TestIndexLogSourceShardAndAfterDestinationAndAgainSource(t *testing.T) { }, } - err = esProc.RemoveTransactions(header, body) + err = esProc.RemoveTransactions(header, body, header.TimeStamp*1000) require.Nil(t, err) err = esClient.DoMultiGet(context.Background(), ids, indexerdata.LogsIndex, true, genericResponse) diff --git a/integrationtests/miniblocks_test.go b/integrationtests/miniblocks_test.go index 3814964e..9cde9fe5 100644 --- a/integrationtests/miniblocks_test.go +++ b/integrationtests/miniblocks_test.go @@ -31,7 +31,7 @@ func TestIndexMiniBlocksOnSourceAndDestination(t *testing.T) { ReceiverShardID: 2, }, } - err = esProc.SaveMiniblocks(header, miniBlocks) + err = esProc.SaveMiniblocks(header, miniBlocks, 1234000) require.Nil(t, err) mbHash := "11a1bb4065e16a2e93b2b5ac5957b7b69f1cfba7579b170b24f30dab2d3162e0" ids := []string{mbHash} @@ -57,7 +57,7 @@ func TestIndexMiniBlocksOnSourceAndDestination(t *testing.T) { }, } - err = esProc.SaveMiniblocks(header, miniBlocks) + err = esProc.SaveMiniblocks(header, miniBlocks, 1234000) require.Nil(t, err) err = esClient.DoMultiGet(context.Background(), ids, indexerdata.MiniblocksIndex, true, genericResponse) @@ -96,7 +96,7 @@ func TestIndexMiniBlockFirstOnDestinationAndAfterSource(t *testing.T) { }, } - err = esProc.SaveMiniblocks(header, miniBlocks) + err = esProc.SaveMiniblocks(header, miniBlocks, 54321000) require.Nil(t, err) genericResponse := &GenericResponse{} @@ -116,7 +116,7 @@ func TestIndexMiniBlockFirstOnDestinationAndAfterSource(t *testing.T) { Reserved: mbhrBytes, }, } - err = esProc.SaveMiniblocks(header, miniBlocks) + err = esProc.SaveMiniblocks(header, miniBlocks, 54321000) require.Nil(t, err) err = esClient.DoMultiGet(context.Background(), ids, indexerdata.MiniblocksIndex, true, genericResponse) require.Nil(t, err) diff --git a/integrationtests/testdata/accountsBalanceNftTransfer/balance-nft-after-create.json b/integrationtests/testdata/accountsBalanceNftTransfer/balance-nft-after-create.json index 818b34a2..ffb15164 100644 --- a/integrationtests/testdata/accountsBalanceNftTransfer/balance-nft-after-create.json +++ b/integrationtests/testdata/accountsBalanceNftTransfer/balance-nft-after-create.json @@ -6,5 +6,6 @@ "tokenNonce": 7440483, "token": "NFT-abcdef", "timestamp": 5600, + "timestampMs": 5600000, "shardID": 1 } diff --git a/integrationtests/testdata/accountsBalanceNftTransfer/balance-nft-after-transfer.json b/integrationtests/testdata/accountsBalanceNftTransfer/balance-nft-after-transfer.json index 90c744c4..6fe142b6 100644 --- a/integrationtests/testdata/accountsBalanceNftTransfer/balance-nft-after-transfer.json +++ b/integrationtests/testdata/accountsBalanceNftTransfer/balance-nft-after-transfer.json @@ -6,5 +6,6 @@ "tokenNonce": 7440483, "token": "NFT-abcdef", "timestamp": 5600, + "timestampMs": 5600000, "shardID": 1 } diff --git a/integrationtests/testdata/accountsBalanceWithLowerTimestamp/account-balance-esdt-first-update.json b/integrationtests/testdata/accountsBalanceWithLowerTimestamp/account-balance-esdt-first-update.json index 097b1ac5..fcc30f05 100644 --- a/integrationtests/testdata/accountsBalanceWithLowerTimestamp/account-balance-esdt-first-update.json +++ b/integrationtests/testdata/accountsBalanceWithLowerTimestamp/account-balance-esdt-first-update.json @@ -4,6 +4,7 @@ "balanceNum": 1e-15, "token": "TTTT-abcd", "timestamp": 5600, + "timestampMs": 5600000, "type": "FungibleESDT", "shardID": 2 } diff --git a/integrationtests/testdata/accountsBalanceWithLowerTimestamp/account-balance-esdt-second-update.json b/integrationtests/testdata/accountsBalanceWithLowerTimestamp/account-balance-esdt-second-update.json index e224383a..99c5a1fa 100644 --- a/integrationtests/testdata/accountsBalanceWithLowerTimestamp/account-balance-esdt-second-update.json +++ b/integrationtests/testdata/accountsBalanceWithLowerTimestamp/account-balance-esdt-second-update.json @@ -3,6 +3,7 @@ "balance": "1000", "balanceNum": 1e-15, "timestamp": 6000, + "timestampMs": 6000000, "token": "TTTT-abcd", "type": "FungibleESDT", "shardID": 2 diff --git a/integrationtests/testdata/accountsBalanceWithLowerTimestamp/account-balance-first-update.json b/integrationtests/testdata/accountsBalanceWithLowerTimestamp/account-balance-first-update.json index 97a80077..365289fc 100644 --- a/integrationtests/testdata/accountsBalanceWithLowerTimestamp/account-balance-first-update.json +++ b/integrationtests/testdata/accountsBalanceWithLowerTimestamp/account-balance-first-update.json @@ -3,5 +3,6 @@ "balance": "0", "balanceNum": 0, "timestamp": 5600, + "timestampMs": 5600000, "shardID": 2 } diff --git a/integrationtests/testdata/accountsBalanceWithLowerTimestamp/account-balance-second-update.json b/integrationtests/testdata/accountsBalanceWithLowerTimestamp/account-balance-second-update.json index 3ebc00ce..fd88ff75 100644 --- a/integrationtests/testdata/accountsBalanceWithLowerTimestamp/account-balance-second-update.json +++ b/integrationtests/testdata/accountsBalanceWithLowerTimestamp/account-balance-second-update.json @@ -3,5 +3,6 @@ "balance": "2000", "balanceNum": 0, "timestamp": 6000, + "timestampMs": 6000000, "shardID": 2 } diff --git a/integrationtests/testdata/accountsESDTRollback/account-after-create.json b/integrationtests/testdata/accountsESDTRollback/account-after-create.json index fdc695f5..e4476991 100644 --- a/integrationtests/testdata/accountsESDTRollback/account-after-create.json +++ b/integrationtests/testdata/accountsESDTRollback/account-after-create.json @@ -12,5 +12,6 @@ "tokenNonce": 2, "properties": "3032", "token": "TOKEN-eeee", - "timestamp": 5040 + "timestamp": 5040, + "timestampMs": 5040000 } diff --git a/integrationtests/testdata/accountsESDTWithTokenType/account-esdt-with-type.json b/integrationtests/testdata/accountsESDTWithTokenType/account-esdt-with-type.json index cd053c28..514f7317 100644 --- a/integrationtests/testdata/accountsESDTWithTokenType/account-esdt-with-type.json +++ b/integrationtests/testdata/accountsESDTWithTokenType/account-esdt-with-type.json @@ -12,6 +12,7 @@ "whiteListedStorage": false }, "timestamp": 5600, + "timestampMs": 5600000, "type": "SemiFungibleESDT", "shardID": 2 } diff --git a/integrationtests/testdata/accountsESDTWithTokenType/account-esdt-without-type.json b/integrationtests/testdata/accountsESDTWithTokenType/account-esdt-without-type.json index 5b22dab0..cb342aeb 100644 --- a/integrationtests/testdata/accountsESDTWithTokenType/account-esdt-without-type.json +++ b/integrationtests/testdata/accountsESDTWithTokenType/account-esdt-without-type.json @@ -12,5 +12,6 @@ "whiteListedStorage": false }, "timestamp": 5600, + "timestampMs": 5600000, "shardID": 2 } diff --git a/integrationtests/testdata/accountsESDTWithTokenType/account-esdt.json b/integrationtests/testdata/accountsESDTWithTokenType/account-esdt.json index f8376e75..53543da7 100644 --- a/integrationtests/testdata/accountsESDTWithTokenType/account-esdt.json +++ b/integrationtests/testdata/accountsESDTWithTokenType/account-esdt.json @@ -12,6 +12,7 @@ "whiteListedStorage": false }, "timestamp": 5600, + "timestampMs": 5600000, "type": "SemiFungibleESDT", "currentOwner":"erd1sqy2ywvswp09ef7qwjhv8zwr9kzz3xas6y2ye5nuryaz0wcnfzzsnq0am3", "shardID": 2 diff --git a/integrationtests/testdata/accountsESDTWithTokenType/semi-fungible-token-after-create.json b/integrationtests/testdata/accountsESDTWithTokenType/semi-fungible-token-after-create.json index 16511e1b..0bc56d9c 100644 --- a/integrationtests/testdata/accountsESDTWithTokenType/semi-fungible-token-after-create.json +++ b/integrationtests/testdata/accountsESDTWithTokenType/semi-fungible-token-after-create.json @@ -3,6 +3,7 @@ "token": "TTTT-abcd", "nonce": 2, "timestamp": 5600, + "timestampMs": 5600000, "data": { "creator": "erd1l29zsl2dqq988kvr2y0xlfv9ydgnvhzkatfd8ccalpag265pje8qn8lslf", "nonEmptyURIs": false, diff --git a/integrationtests/testdata/accountsESDTWithTokenType/semi-fungible-token.json b/integrationtests/testdata/accountsESDTWithTokenType/semi-fungible-token.json index 46b05643..0ee2a06c 100644 --- a/integrationtests/testdata/accountsESDTWithTokenType/semi-fungible-token.json +++ b/integrationtests/testdata/accountsESDTWithTokenType/semi-fungible-token.json @@ -6,10 +6,12 @@ "currentOwner": "erd1l29zsl2dqq988kvr2y0xlfv9ydgnvhzkatfd8ccalpag265pje8qn8lslf", "type": "SemiFungibleESDT", "timestamp": 5040, + "timestampMs": 5040000, "ownersHistory": [ { "address": "erd1l29zsl2dqq988kvr2y0xlfv9ydgnvhzkatfd8ccalpag265pje8qn8lslf", - "timestamp": 5040 + "timestamp": 5040, + "timestampMs": 5040000 } ], "properties": { diff --git a/integrationtests/testdata/accountsESDTWithTokenType/token-after-issue.json b/integrationtests/testdata/accountsESDTWithTokenType/token-after-issue.json index c885b715..2b0398a2 100644 --- a/integrationtests/testdata/accountsESDTWithTokenType/token-after-issue.json +++ b/integrationtests/testdata/accountsESDTWithTokenType/token-after-issue.json @@ -6,10 +6,12 @@ "currentOwner": "erd1sqy2ywvswp09ef7qwjhv8zwr9kzz3xas6y2ye5nuryaz0wcnfzzsnq0am3", "type": "SemiFungibleESDT", "timestamp": 5040, + "timestampMs": 5040000, "ownersHistory": [ { "address": "erd1sqy2ywvswp09ef7qwjhv8zwr9kzz3xas6y2ye5nuryaz0wcnfzzsnq0am3", - "timestamp": 5040 + "timestamp": 5040, + "timestampMs": 5040000 } ], "properties": { diff --git a/integrationtests/testdata/claimRewards/tx-claim-rewards.json b/integrationtests/testdata/claimRewards/tx-claim-rewards.json index 044a0c5f..49c938f7 100644 --- a/integrationtests/testdata/claimRewards/tx-claim-rewards.json +++ b/integrationtests/testdata/claimRewards/tx-claim-rewards.json @@ -18,6 +18,7 @@ "data": "Y2xhaW1SZXdhcmRz", "signature": "", "timestamp": 5040, + "timestampMs": 5040000, "status": "success", "searchOrder": 0, "hasScResults": true, diff --git a/integrationtests/testdata/createNFTWithTags/accounts-esdt-address-balance.json b/integrationtests/testdata/createNFTWithTags/accounts-esdt-address-balance.json index a686b376..15e77272 100644 --- a/integrationtests/testdata/createNFTWithTags/accounts-esdt-address-balance.json +++ b/integrationtests/testdata/createNFTWithTags/accounts-esdt-address-balance.json @@ -22,5 +22,6 @@ "properties": "3032", "token": "DESK-abcd", "timestamp": 5600, + "timestampMs": 5600000, "shardID": 2 } diff --git a/integrationtests/testdata/delegators/delegator-after-delegate.json b/integrationtests/testdata/delegators/delegator-after-delegate.json index 00953069..1e6fa018 100644 --- a/integrationtests/testdata/delegators/delegator-after-delegate.json +++ b/integrationtests/testdata/delegators/delegator-after-delegate.json @@ -3,5 +3,6 @@ "contract": "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqhllllsajxzat", "activeStake": "200000000000000000000", "activeStakeNum": 200, - "timestamp": 5040 + "timestamp": 5040, + "timestampMs": 5040000 } diff --git a/integrationtests/testdata/delegators/delegator-after-revert.json b/integrationtests/testdata/delegators/delegator-after-revert.json index 166ab014..2805bc77 100644 --- a/integrationtests/testdata/delegators/delegator-after-revert.json +++ b/integrationtests/testdata/delegators/delegator-after-revert.json @@ -4,12 +4,14 @@ "activeStake": "124500000000000000000", "activeStakeNum": 124.5, "timestamp": 5060, + "timestampMs": 5060000, "unDelegateInfo": [ { "valueNum": 50, "id": "31", "value": "50000000000000000000", - "timestamp": 5050 + "timestamp": 5050, + "timestampMs": 5050000 } ] } diff --git a/integrationtests/testdata/delegators/delegator-after-un-delegate-1.json b/integrationtests/testdata/delegators/delegator-after-un-delegate-1.json index dcc02ab3..0175a557 100644 --- a/integrationtests/testdata/delegators/delegator-after-un-delegate-1.json +++ b/integrationtests/testdata/delegators/delegator-after-un-delegate-1.json @@ -4,12 +4,14 @@ "activeStake": "150000000000000000000", "activeStakeNum": 150, "timestamp": 5050, + "timestampMs": 5050000, "unDelegateInfo": [ { "id": "31", "value": "50000000000000000000", "valueNum": 50, - "timestamp": 5050 + "timestamp": 5050, + "timestampMs": 5050000 } ] } diff --git a/integrationtests/testdata/delegators/delegator-after-un-delegate-2.json b/integrationtests/testdata/delegators/delegator-after-un-delegate-2.json index 2af228f0..95c2590d 100644 --- a/integrationtests/testdata/delegators/delegator-after-un-delegate-2.json +++ b/integrationtests/testdata/delegators/delegator-after-un-delegate-2.json @@ -4,18 +4,21 @@ "activeStake": "124500000000000000000", "activeStakeNum": 124.5, "timestamp": 5060, + "timestampMs": 5060000, "unDelegateInfo": [ { "valueNum": 50, "id": "31", "value": "50000000000000000000", - "timestamp": 5050 + "timestamp": 5050, + "timestampMs": 5050000 }, { "valueNum": 25.5, "id": "32", "value": "25500000000000000000", - "timestamp": 5060 + "timestamp": 5060, + "timestampMs": 5060000 } ] } diff --git a/integrationtests/testdata/delegators/delegator-after-withdraw.json b/integrationtests/testdata/delegators/delegator-after-withdraw.json index 2705940f..e6035ebe 100644 --- a/integrationtests/testdata/delegators/delegator-after-withdraw.json +++ b/integrationtests/testdata/delegators/delegator-after-withdraw.json @@ -3,5 +3,6 @@ "contract": "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqhllllsajxzat", "activeStake": "124500000000000000000", "activeStakeNum": 124.5, - "timestamp": 5070 + "timestamp": 5070, + "timestampMs": 5070000 } diff --git a/integrationtests/testdata/esdtTransfer/esdt-transfer-cross-shard-on-destination.json b/integrationtests/testdata/esdtTransfer/esdt-transfer-cross-shard-on-destination.json index 81cd1701..95c7fb4a 100644 --- a/integrationtests/testdata/esdtTransfer/esdt-transfer-cross-shard-on-destination.json +++ b/integrationtests/testdata/esdtTransfer/esdt-transfer-cross-shard-on-destination.json @@ -17,6 +17,7 @@ "data": "RVNEVFRyYW5zZmVyQDU0NDc0ZTJkMzgzODYyMzgzMzY2QDBh", "signature": "", "timestamp": 10102, + "timestampMs": 10102000, "status": "success", "searchOrder": 0, "hasScResults": true, diff --git a/integrationtests/testdata/esdtTransfer/esdt-transfer-cross-shard-on-source.json b/integrationtests/testdata/esdtTransfer/esdt-transfer-cross-shard-on-source.json index 187e5d7b..1bf9a228 100644 --- a/integrationtests/testdata/esdtTransfer/esdt-transfer-cross-shard-on-source.json +++ b/integrationtests/testdata/esdtTransfer/esdt-transfer-cross-shard-on-source.json @@ -17,6 +17,7 @@ "data": "RVNEVFRyYW5zZmVyQDU0NDc0ZTJkMzgzODYyMzgzMzY2QDBh", "signature": "", "timestamp": 10101, + "timestampMs": 10101000, "status": "pending", "searchOrder": 0, "hasScResults": true, diff --git a/integrationtests/testdata/esdtTransfer/esdt-transfer-first-on-destination.json b/integrationtests/testdata/esdtTransfer/esdt-transfer-first-on-destination.json index 73b1a310..31e2d801 100644 --- a/integrationtests/testdata/esdtTransfer/esdt-transfer-first-on-destination.json +++ b/integrationtests/testdata/esdtTransfer/esdt-transfer-first-on-destination.json @@ -20,6 +20,7 @@ "value": "0", "gasPrice": 1000000000, "timestamp": 10102, + "timestampMs": 10102000, "receiver": "erd13u7zyekzvdvzek8768r5gau9p6677ufppsjuklu9e6t7yx7rhg4s68e2ze", "valueNum": 0, "feeNum": 0.00013766, diff --git a/integrationtests/testdata/esdtTransfer/esdt-transfer-second-on-source.json b/integrationtests/testdata/esdtTransfer/esdt-transfer-second-on-source.json index 2bbb9222..f2560f09 100644 --- a/integrationtests/testdata/esdtTransfer/esdt-transfer-second-on-source.json +++ b/integrationtests/testdata/esdtTransfer/esdt-transfer-second-on-source.json @@ -20,6 +20,7 @@ "value": "0", "gasPrice": 1000000000, "timestamp": 10102, + "timestampMs": 10102000, "receiver": "erd13u7zyekzvdvzek8768r5gau9p6677ufppsjuklu9e6t7yx7rhg4s68e2ze", "valueNum": 0, "feeNum": 0.000136, diff --git a/integrationtests/testdata/esdtTransfer/esdt-transfer.json b/integrationtests/testdata/esdtTransfer/esdt-transfer.json index 9f68664e..20ec79ec 100644 --- a/integrationtests/testdata/esdtTransfer/esdt-transfer.json +++ b/integrationtests/testdata/esdtTransfer/esdt-transfer.json @@ -17,6 +17,7 @@ "data": "RVNEVFRyYW5zZmVyQDU0NDc0ZTJkMzgzODYyMzgzMzY2QDBh", "signature": "", "timestamp": 5040, + "timestampMs": 5040000, "status": "success", "searchOrder": 0, "hasScResults": true, diff --git a/integrationtests/testdata/issueToken/token-semi-after-pause.json b/integrationtests/testdata/issueToken/token-semi-after-pause.json index a4c40241..f588d4e2 100644 --- a/integrationtests/testdata/issueToken/token-semi-after-pause.json +++ b/integrationtests/testdata/issueToken/token-semi-after-pause.json @@ -6,14 +6,17 @@ "currentOwner": "erd1acjlnuhkd8773sqhmw85r0ur4lcyuqgm0n69h9ttxh0gwxtuuzxq4lckh6", "type": "SemiFungibleESDT", "timestamp": 5040, + "timestampMs": 5040000, "ownersHistory": [ { "address": "erd1v7e552pz9py4hv6raan0c4jflez3e6csdmzcgrncg0qrnk4tywvsqx0h5j", - "timestamp": 5040 + "timestamp": 5040, + "timestampMs": 5040000 }, { "address": "erd1acjlnuhkd8773sqhmw85r0ur4lcyuqgm0n69h9ttxh0gwxtuuzxq4lckh6", - "timestamp": 10000 + "timestamp": 10000, + "timestampMs": 10000000 } ], "properties": { diff --git a/integrationtests/testdata/issueToken/token-semi-after-transfer-ownership.json b/integrationtests/testdata/issueToken/token-semi-after-transfer-ownership.json index 6e907c1a..0b0387fe 100644 --- a/integrationtests/testdata/issueToken/token-semi-after-transfer-ownership.json +++ b/integrationtests/testdata/issueToken/token-semi-after-transfer-ownership.json @@ -6,14 +6,17 @@ "currentOwner": "erd1acjlnuhkd8773sqhmw85r0ur4lcyuqgm0n69h9ttxh0gwxtuuzxq4lckh6", "type": "SemiFungibleESDT", "timestamp": 5040, + "timestampMs": 5040000, "ownersHistory": [ { "address": "erd1v7e552pz9py4hv6raan0c4jflez3e6csdmzcgrncg0qrnk4tywvsqx0h5j", - "timestamp": 5040 + "timestamp": 5040, + "timestampMs": 5040000 }, { "address": "erd1acjlnuhkd8773sqhmw85r0ur4lcyuqgm0n69h9ttxh0gwxtuuzxq4lckh6", - "timestamp": 10000 + "timestamp": 10000, + "timestampMs": 10000000 } ], "properties": { diff --git a/integrationtests/testdata/issueToken/token-semi-after-un-pause.json b/integrationtests/testdata/issueToken/token-semi-after-un-pause.json index 57d0af63..9af780cf 100644 --- a/integrationtests/testdata/issueToken/token-semi-after-un-pause.json +++ b/integrationtests/testdata/issueToken/token-semi-after-un-pause.json @@ -6,14 +6,17 @@ "currentOwner": "erd1acjlnuhkd8773sqhmw85r0ur4lcyuqgm0n69h9ttxh0gwxtuuzxq4lckh6", "type": "SemiFungibleESDT", "timestamp": 5040, + "timestampMs": 5040000, "ownersHistory": [ { "address": "erd1v7e552pz9py4hv6raan0c4jflez3e6csdmzcgrncg0qrnk4tywvsqx0h5j", - "timestamp": 5040 + "timestamp": 5040, + "timestampMs": 5040000 }, { "address": "erd1acjlnuhkd8773sqhmw85r0ur4lcyuqgm0n69h9ttxh0gwxtuuzxq4lckh6", - "timestamp": 10000 + "timestamp": 10000, + "timestampMs": 10000000 } ], "properties": { diff --git a/integrationtests/testdata/issueToken/token-semi.json b/integrationtests/testdata/issueToken/token-semi.json index 58d9ff09..9a66c2b5 100644 --- a/integrationtests/testdata/issueToken/token-semi.json +++ b/integrationtests/testdata/issueToken/token-semi.json @@ -6,10 +6,12 @@ "currentOwner": "erd1v7e552pz9py4hv6raan0c4jflez3e6csdmzcgrncg0qrnk4tywvsqx0h5j", "type": "SemiFungibleESDT", "timestamp": 5040, + "timestampMs": 5040000, "ownersHistory": [ { "address": "erd1v7e552pz9py4hv6raan0c4jflez3e6csdmzcgrncg0qrnk4tywvsqx0h5j", - "timestamp": 5040 + "timestamp": 5040, + "timestampMs": 5040000 } ], "numDecimals": 18, diff --git a/integrationtests/testdata/issueTokenAndChangeType/token-with-new-type.json b/integrationtests/testdata/issueTokenAndChangeType/token-with-new-type.json index 8f19fc4b..58d5c6a2 100644 --- a/integrationtests/testdata/issueTokenAndChangeType/token-with-new-type.json +++ b/integrationtests/testdata/issueTokenAndChangeType/token-with-new-type.json @@ -7,10 +7,12 @@ "numDecimals": 0, "type": "DynamicSemiFungibleESDT", "timestamp": 5040, + "timestampMs": 5040000, "ownersHistory": [ { "address": "erd1k04pxr6c0gvlcx4rd5fje0a4uy33axqxwz0fpcrgtfdy3nrqauqqgvxprv", - "timestamp": 5040 + "timestamp": 5040, + "timestampMs": 5040000 } ], "properties": { diff --git a/integrationtests/testdata/issueTokenAndChangeType/token.json b/integrationtests/testdata/issueTokenAndChangeType/token.json index 8b33340d..4d039d6d 100644 --- a/integrationtests/testdata/issueTokenAndChangeType/token.json +++ b/integrationtests/testdata/issueTokenAndChangeType/token.json @@ -7,10 +7,12 @@ "numDecimals": 0, "type": "SemiFungibleESDT", "timestamp": 5040, + "timestampMs": 5040000, "ownersHistory": [ { "address": "erd1k04pxr6c0gvlcx4rd5fje0a4uy33axqxwz0fpcrgtfdy3nrqauqqgvxprv", - "timestamp": 5040 + "timestamp": 5040, + "timestampMs": 5040000 } ], "properties": { diff --git a/integrationtests/testdata/issueTokenAndSetRoles/token-after-issue-ok.json b/integrationtests/testdata/issueTokenAndSetRoles/token-after-issue-ok.json index eb1b1f09..741533df 100644 --- a/integrationtests/testdata/issueTokenAndSetRoles/token-after-issue-ok.json +++ b/integrationtests/testdata/issueTokenAndSetRoles/token-after-issue-ok.json @@ -6,10 +6,12 @@ "currentOwner": "erd1k04pxr6c0gvlcx4rd5fje0a4uy33axqxwz0fpcrgtfdy3nrqauqqgvxprv", "type": "SemiFungibleESDT", "timestamp": 5040, + "timestampMs": 5040000, "ownersHistory": [ { "address": "erd1k04pxr6c0gvlcx4rd5fje0a4uy33axqxwz0fpcrgtfdy3nrqauqqgvxprv", - "timestamp": 5040 + "timestamp": 5040, + "timestampMs": 5040000 } ], "properties": { diff --git a/integrationtests/testdata/issueTokenAndSetRoles/token-after-set-role.json b/integrationtests/testdata/issueTokenAndSetRoles/token-after-set-role.json index ad5c4053..59f86140 100644 --- a/integrationtests/testdata/issueTokenAndSetRoles/token-after-set-role.json +++ b/integrationtests/testdata/issueTokenAndSetRoles/token-after-set-role.json @@ -6,10 +6,12 @@ "currentOwner": "erd1k04pxr6c0gvlcx4rd5fje0a4uy33axqxwz0fpcrgtfdy3nrqauqqgvxprv", "type": "SemiFungibleESDT", "timestamp": 5040, + "timestampMs": 5040000, "ownersHistory": [ { "address": "erd1k04pxr6c0gvlcx4rd5fje0a4uy33axqxwz0fpcrgtfdy3nrqauqqgvxprv", - "timestamp": 5040 + "timestamp": 5040, + "timestampMs": 5040000 } ], "roles": { diff --git a/integrationtests/testdata/issueTokenAndSetRoles/token-after-set-roles-and-issue.json b/integrationtests/testdata/issueTokenAndSetRoles/token-after-set-roles-and-issue.json index fda5e962..855227c5 100644 --- a/integrationtests/testdata/issueTokenAndSetRoles/token-after-set-roles-and-issue.json +++ b/integrationtests/testdata/issueTokenAndSetRoles/token-after-set-roles-and-issue.json @@ -14,10 +14,12 @@ "issuer": "erd1k04pxr6c0gvlcx4rd5fje0a4uy33axqxwz0fpcrgtfdy3nrqauqqgvxprv", "token": "TTT-abcd", "timestamp": 10000, + "timestampMs": 10000000, "ownersHistory": [ { "address": "erd1k04pxr6c0gvlcx4rd5fje0a4uy33axqxwz0fpcrgtfdy3nrqauqqgvxprv", - "timestamp": 10000 + "timestamp": 10000, + "timestampMs": 10000000 } ], "properties": { diff --git a/integrationtests/testdata/issueTokenAndSetRoles/token-after-transfer-role.json b/integrationtests/testdata/issueTokenAndSetRoles/token-after-transfer-role.json index 418a1245..82fceb7e 100644 --- a/integrationtests/testdata/issueTokenAndSetRoles/token-after-transfer-role.json +++ b/integrationtests/testdata/issueTokenAndSetRoles/token-after-transfer-role.json @@ -6,10 +6,12 @@ "currentOwner": "erd1k04pxr6c0gvlcx4rd5fje0a4uy33axqxwz0fpcrgtfdy3nrqauqqgvxprv", "type": "SemiFungibleESDT", "timestamp": 5040, + "timestampMs": 5040000, "ownersHistory": [ { "address": "erd1k04pxr6c0gvlcx4rd5fje0a4uy33axqxwz0fpcrgtfdy3nrqauqqgvxprv", - "timestamp": 5040 + "timestamp": 5040, + "timestampMs": 5040000 } ], "roles": { diff --git a/integrationtests/testdata/issueTokenAndSetRoles/token-after-unset-role.json b/integrationtests/testdata/issueTokenAndSetRoles/token-after-unset-role.json index 42c45bfe..07d6ead9 100644 --- a/integrationtests/testdata/issueTokenAndSetRoles/token-after-unset-role.json +++ b/integrationtests/testdata/issueTokenAndSetRoles/token-after-unset-role.json @@ -6,10 +6,12 @@ "currentOwner": "erd1k04pxr6c0gvlcx4rd5fje0a4uy33axqxwz0fpcrgtfdy3nrqauqqgvxprv", "type": "SemiFungibleESDT", "timestamp": 5040, + "timestampMs": 5040000, "ownersHistory": [ { "address": "erd1k04pxr6c0gvlcx4rd5fje0a4uy33axqxwz0fpcrgtfdy3nrqauqqgvxprv", - "timestamp": 5040 + "timestamp": 5040, + "timestampMs": 5040000 } ], "roles": { diff --git a/integrationtests/testdata/logsCrossShard/event-do-something.json b/integrationtests/testdata/logsCrossShard/event-do-something.json index 2490eea4..c7d626b7 100644 --- a/integrationtests/testdata/logsCrossShard/event-do-something.json +++ b/integrationtests/testdata/logsCrossShard/event-do-something.json @@ -10,5 +10,6 @@ "txHash": "63726f73732d6c6f67", "order": 1, "timestamp": 6040, + "timestampMs": 6040000, "txOrder": 0 } diff --git a/integrationtests/testdata/logsCrossShard/event-transfer-destination.json b/integrationtests/testdata/logsCrossShard/event-transfer-destination.json index c373f9be..b63d091a 100644 --- a/integrationtests/testdata/logsCrossShard/event-transfer-destination.json +++ b/integrationtests/testdata/logsCrossShard/event-transfer-destination.json @@ -11,5 +11,6 @@ "txHash": "63726f73732d6c6f67", "order": 0, "timestamp": 6040, + "timestampMs": 6040000, "txOrder": 0 } diff --git a/integrationtests/testdata/logsCrossShard/event-transfer-source-first.json b/integrationtests/testdata/logsCrossShard/event-transfer-source-first.json index d085f338..7992d558 100644 --- a/integrationtests/testdata/logsCrossShard/event-transfer-source-first.json +++ b/integrationtests/testdata/logsCrossShard/event-transfer-source-first.json @@ -11,5 +11,6 @@ "txOrder": 0, "txHash": "63726f73732d6c6f67", "order": 0, - "timestamp": 5040 + "timestamp": 5040, + "timestampMs": 5040000 } diff --git a/integrationtests/testdata/logsCrossShard/log-at-destination.json b/integrationtests/testdata/logsCrossShard/log-at-destination.json index e18c3000..452abf03 100644 --- a/integrationtests/testdata/logsCrossShard/log-at-destination.json +++ b/integrationtests/testdata/logsCrossShard/log-at-destination.json @@ -23,5 +23,6 @@ "order": 1 } ], - "timestamp": 6040 + "timestamp": 6040, + "timestampMs": 6040000 } diff --git a/integrationtests/testdata/logsCrossShard/log-at-source.json b/integrationtests/testdata/logsCrossShard/log-at-source.json index eaeee595..d8d269f0 100644 --- a/integrationtests/testdata/logsCrossShard/log-at-source.json +++ b/integrationtests/testdata/logsCrossShard/log-at-source.json @@ -13,5 +13,6 @@ "order": 0 } ], - "timestamp": 5040 + "timestamp": 5040, + "timestampMs": 5040000 } diff --git a/integrationtests/testdata/mappings/esdts.json b/integrationtests/testdata/mappings/esdts.json index da8bc0bd..f0f9c16d 100644 --- a/integrationtests/testdata/mappings/esdts.json +++ b/integrationtests/testdata/mappings/esdts.json @@ -27,6 +27,11 @@ "type": "date", "format": "epoch_second", "index": false + }, + "timestampMs": { + "type": "date", + "format": "epoch_millis", + "index": false } } }, @@ -110,10 +115,18 @@ "type": "date", "format": "epoch_second" }, + "timestampMs": { + "type": "date", + "format": "epoch_millis" + }, "changedToDynamicTimestamp": { "type": "date", "format": "epoch_second" }, + "changedToDynamicTimestampMs": { + "type": "date", + "format": "epoch_millis" + }, "token": { "type": "text" }, diff --git a/integrationtests/testdata/miniblocks/cross-miniblock-on-destination-first.json b/integrationtests/testdata/miniblocks/cross-miniblock-on-destination-first.json index a18dfa1e..1ed0c0b3 100644 --- a/integrationtests/testdata/miniblocks/cross-miniblock-on-destination-first.json +++ b/integrationtests/testdata/miniblocks/cross-miniblock-on-destination-first.json @@ -4,5 +4,6 @@ "senderShard": 2, "receiverBlockHash": "b36435faaa72390772da84f418348ce0d477c74432579519bf0ffea1dc4c36e9", "type": "TxBlock", - "timestamp": 54321 + "timestamp": 54321, + "timestampMs": 54321000 } diff --git a/integrationtests/testdata/miniblocks/cross-miniblock-on-destination.json b/integrationtests/testdata/miniblocks/cross-miniblock-on-destination.json index 6baab6f0..6a550803 100644 --- a/integrationtests/testdata/miniblocks/cross-miniblock-on-destination.json +++ b/integrationtests/testdata/miniblocks/cross-miniblock-on-destination.json @@ -5,6 +5,7 @@ "senderShard": 1, "type": "TxBlock", "timestamp": 1234, + "timestampMs": 1234000, "receiverBlockHash": "d7f1e8003a45c7adbd87bbbb269cb4af3d1f4aedd0c214973bfc096dd0f3b65e", "procTypeD": "Scheduled" } diff --git a/integrationtests/testdata/miniblocks/cross-miniblock-on-source-second.json b/integrationtests/testdata/miniblocks/cross-miniblock-on-source-second.json index 0ae4076f..c671a8f7 100644 --- a/integrationtests/testdata/miniblocks/cross-miniblock-on-source-second.json +++ b/integrationtests/testdata/miniblocks/cross-miniblock-on-source-second.json @@ -5,6 +5,7 @@ "receiverBlockHash": "b36435faaa72390772da84f418348ce0d477c74432579519bf0ffea1dc4c36e9", "type": "TxBlock", "timestamp": 54321, + "timestampMs": 54321000, "senderBlockHash": "b601381e1f41df2aa3da9f2b8eb169f14c86418229e30fc65f9e6b37b7f0d902", "procTypeS": "Normal" } diff --git a/integrationtests/testdata/miniblocks/cross-miniblock-on-source.json b/integrationtests/testdata/miniblocks/cross-miniblock-on-source.json index 98dce8aa..520254a5 100644 --- a/integrationtests/testdata/miniblocks/cross-miniblock-on-source.json +++ b/integrationtests/testdata/miniblocks/cross-miniblock-on-source.json @@ -4,5 +4,6 @@ "receiverShard": 2, "senderShard": 1, "type": "TxBlock", - "timestamp": 1234 + "timestamp": 1234, + "timestampMs": 1234000 } diff --git a/integrationtests/testdata/multiTransferWithScCallAndErrorSignaledBySC/transaction-after-execution-of-scr-dst-shard.json b/integrationtests/testdata/multiTransferWithScCallAndErrorSignaledBySC/transaction-after-execution-of-scr-dst-shard.json index 4a3a96b6..1c9613f7 100644 --- a/integrationtests/testdata/multiTransferWithScCallAndErrorSignaledBySC/transaction-after-execution-of-scr-dst-shard.json +++ b/integrationtests/testdata/multiTransferWithScCallAndErrorSignaledBySC/transaction-after-execution-of-scr-dst-shard.json @@ -33,6 +33,7 @@ "valueNum": 0, "gasPrice": 1000000000, "timestamp": 5040, + "timestampMs": 5040000, "receiver": "erd1ju8pkvg57cwdmjsjx58jlmnuf4l9yspstrhr9tgsrt98n9edpm2qtlgy99", "nonce": 79, "round": 50, diff --git a/integrationtests/testdata/multiTransferWithScCallAndErrorSignaledBySC/transaction-executed-on-source.json b/integrationtests/testdata/multiTransferWithScCallAndErrorSignaledBySC/transaction-executed-on-source.json index f5d08816..258d492b 100644 --- a/integrationtests/testdata/multiTransferWithScCallAndErrorSignaledBySC/transaction-executed-on-source.json +++ b/integrationtests/testdata/multiTransferWithScCallAndErrorSignaledBySC/transaction-executed-on-source.json @@ -33,6 +33,7 @@ "valueNum": 0, "gasPrice": 1000000000, "timestamp": 5040, + "timestampMs": 5040000, "receiver": "erd1ju8pkvg57cwdmjsjx58jlmnuf4l9yspstrhr9tgsrt98n9edpm2qtlgy99", "nonce": 79, "round": 50, diff --git a/integrationtests/testdata/nftIssueCreateBurn/non-fungible-after-create.json b/integrationtests/testdata/nftIssueCreateBurn/non-fungible-after-create.json index 05b98a79..7ab1623a 100644 --- a/integrationtests/testdata/nftIssueCreateBurn/non-fungible-after-create.json +++ b/integrationtests/testdata/nftIssueCreateBurn/non-fungible-after-create.json @@ -4,6 +4,7 @@ "type": "NonFungibleESDT", "nonce": 2, "timestamp": 5600, + "timestampMs": 5600000, "data": { "creator": "erd1ju8pkvg57cwdmjsjx58jlmnuf4l9yspstrhr9tgsrt98n9edpm2qtlgy99", "nonEmptyURIs": false, diff --git a/integrationtests/testdata/nftIssueCreateBurn/non-fungible-after-issue.json b/integrationtests/testdata/nftIssueCreateBurn/non-fungible-after-issue.json index 789798f8..d1da2f42 100644 --- a/integrationtests/testdata/nftIssueCreateBurn/non-fungible-after-issue.json +++ b/integrationtests/testdata/nftIssueCreateBurn/non-fungible-after-issue.json @@ -6,10 +6,12 @@ "currentOwner": "erd1ju8pkvg57cwdmjsjx58jlmnuf4l9yspstrhr9tgsrt98n9edpm2qtlgy99", "type": "NonFungibleESDT", "timestamp": 5040, + "timestampMs": 5040000, "ownersHistory": [ { "address": "erd1ju8pkvg57cwdmjsjx58jlmnuf4l9yspstrhr9tgsrt98n9edpm2qtlgy99", - "timestamp": 5040 + "timestamp": 5040, + "timestampMs": 5040000 } ], "properties": { diff --git a/integrationtests/testdata/nftIssueCreateBurn/non-fungible-v2-after-create.json b/integrationtests/testdata/nftIssueCreateBurn/non-fungible-v2-after-create.json index ec233947..022952e3 100644 --- a/integrationtests/testdata/nftIssueCreateBurn/non-fungible-v2-after-create.json +++ b/integrationtests/testdata/nftIssueCreateBurn/non-fungible-v2-after-create.json @@ -6,6 +6,7 @@ "type": "NonFungibleESDTv2", "nonce": 2, "timestamp": 5600, + "timestampMs": 5600000, "data": { "creator": "erd1ju8pkvg57cwdmjsjx58jlmnuf4l9yspstrhr9tgsrt98n9edpm2qtlgy99", "nonEmptyURIs": false, diff --git a/integrationtests/testdata/nftTransferCrossShard/op-nft-transfer-sc-call-after-refund.json b/integrationtests/testdata/nftTransferCrossShard/op-nft-transfer-sc-call-after-refund.json index 66973883..7b7141dd 100644 --- a/integrationtests/testdata/nftTransferCrossShard/op-nft-transfer-sc-call-after-refund.json +++ b/integrationtests/testdata/nftTransferCrossShard/op-nft-transfer-sc-call-after-refund.json @@ -17,6 +17,7 @@ "data": "RVNEVE5GVFRyYW5zZmVyQDRjNGI0NjQxNTI0ZDJkMzM2NjM0NjYzOTYyQDAxNjUzNEA2ZjFlNmYwMWJjNzYyN2Y1YWVAMDAwMDAwMDAwMDAwMDAwMDA1MDBmMWM4ZjJmZGM1OGE2M2M2YjIwMWZjMmVkNjI5OTYyZDNkZmEzM2ZlN2NlYkA2MzZmNmQ3MDZmNzU2ZTY0NTI2NTc3NjE3MjY0NzM1MDcyNmY3ODc5QDAwMDAwMDAwMDAwMDAwMDAwNTAwNGY3OWVjNDRiYjEzMzcyYjVhYzlkOTk2ZDc0OTEyMGY0NzY0Mjc2MjdjZWI=", "signature": "", "timestamp": 5040, + "timestampMs": 5040000, "status": "success", "searchOrder": 0, "hasScResults": true, diff --git a/integrationtests/testdata/nftTransferCrossShard/tx-complete-with-status.json b/integrationtests/testdata/nftTransferCrossShard/tx-complete-with-status.json index 34e1fa1d..07a39d94 100644 --- a/integrationtests/testdata/nftTransferCrossShard/tx-complete-with-status.json +++ b/integrationtests/testdata/nftTransferCrossShard/tx-complete-with-status.json @@ -33,6 +33,7 @@ "operation": "ESDTNFTTransfer", "gasPrice": 1000000000, "timestamp": 5040, + "timestampMs": 5040000, "status": "fail", "initialPaidFee": "595490000000000", "searchOrder": 0, diff --git a/integrationtests/testdata/nftTransferCrossShard/tx-nft-transfer-failed-on-dst.json b/integrationtests/testdata/nftTransferCrossShard/tx-nft-transfer-failed-on-dst.json index 42c7bff5..0e69db86 100644 --- a/integrationtests/testdata/nftTransferCrossShard/tx-nft-transfer-failed-on-dst.json +++ b/integrationtests/testdata/nftTransferCrossShard/tx-nft-transfer-failed-on-dst.json @@ -17,6 +17,7 @@ "data": "RVNEVE5GVFRyYW5zZmVyQDUzNmY2ZDY1NzQ2ODY5NmU2NzJkNjE2MjYzNjQ2NTY2QDAxQDAxQDAwMDAwMDAwMDAwMDAwMDAwNTAwYTdhMDI3NzFhYTA3MDkwZTYwN2YwMmIyNWY0ZDZkMjQxYmZmMzJiOTkwYTI=", "signature": "", "timestamp": 5040, + "timestampMs": 5040000, "status": "fail", "searchOrder": 0, "hasScResults": true, diff --git a/integrationtests/testdata/nftTransferCrossShard/tx-nft-transfer-sc-call-after-refund.json b/integrationtests/testdata/nftTransferCrossShard/tx-nft-transfer-sc-call-after-refund.json index 8adf0bcf..cc44efd8 100644 --- a/integrationtests/testdata/nftTransferCrossShard/tx-nft-transfer-sc-call-after-refund.json +++ b/integrationtests/testdata/nftTransferCrossShard/tx-nft-transfer-sc-call-after-refund.json @@ -17,6 +17,7 @@ "data": "RVNEVE5GVFRyYW5zZmVyQDRjNGI0NjQxNTI0ZDJkMzM2NjM0NjYzOTYyQDAxNjUzNEA2ZjFlNmYwMWJjNzYyN2Y1YWVAMDAwMDAwMDAwMDAwMDAwMDA1MDBmMWM4ZjJmZGM1OGE2M2M2YjIwMWZjMmVkNjI5OTYyZDNkZmEzM2ZlN2NlYkA2MzZmNmQ3MDZmNzU2ZTY0NTI2NTc3NjE3MjY0NzM1MDcyNmY3ODc5QDAwMDAwMDAwMDAwMDAwMDAwNTAwNGY3OWVjNDRiYjEzMzcyYjVhYzlkOTk2ZDc0OTEyMGY0NzY0Mjc2MjdjZWI=", "signature": "", "timestamp": 5040, + "timestampMs": 5040000, "status": "success", "searchOrder": 0, "hasScResults": true, diff --git a/integrationtests/testdata/nftTransferCrossShard/tx-nft-transfer-sc-call-source.json b/integrationtests/testdata/nftTransferCrossShard/tx-nft-transfer-sc-call-source.json index ac53e099..cce42570 100644 --- a/integrationtests/testdata/nftTransferCrossShard/tx-nft-transfer-sc-call-source.json +++ b/integrationtests/testdata/nftTransferCrossShard/tx-nft-transfer-sc-call-source.json @@ -34,6 +34,7 @@ "operation": "ESDTNFTTransfer", "gasPrice": 1000000000, "timestamp": 5040, + "timestampMs": 5040000, "status": "success", "initialPaidFee": "1904415000000000", "searchOrder": 0, diff --git a/integrationtests/testdata/nftTransferCrossShard/tx-nft-transfer-success-source-second.json b/integrationtests/testdata/nftTransferCrossShard/tx-nft-transfer-success-source-second.json index 412fd37f..a1904f9f 100644 --- a/integrationtests/testdata/nftTransferCrossShard/tx-nft-transfer-success-source-second.json +++ b/integrationtests/testdata/nftTransferCrossShard/tx-nft-transfer-success-source-second.json @@ -26,6 +26,7 @@ "value": "0", "gasPrice": 1000000000, "timestamp": 5040, + "timestampMs": 5040000, "receiver": "erd1ure7ea247clj6yqjg80unz6xzjhlj2zwm4gtg6sudcmtsd2cw3xs74hasv", "valueNum": 0, "feeNum": 0.00023882, diff --git a/integrationtests/testdata/nftTransferCrossShard/tx-nft-transfer.json b/integrationtests/testdata/nftTransferCrossShard/tx-nft-transfer.json index b2951f89..cc4445ad 100644 --- a/integrationtests/testdata/nftTransferCrossShard/tx-nft-transfer.json +++ b/integrationtests/testdata/nftTransferCrossShard/tx-nft-transfer.json @@ -34,6 +34,7 @@ "operation": "ESDTNFTTransfer", "gasPrice": 1000000000, "timestamp": 5040, + "timestampMs": 5040000, "status": "success", "searchOrder": 0, "epoch": 0 diff --git a/integrationtests/testdata/nftTransferCrossShardWithScCall/cross-shard-transfer-with-sc-call.json b/integrationtests/testdata/nftTransferCrossShardWithScCall/cross-shard-transfer-with-sc-call.json index 3891231f..48863d0d 100644 --- a/integrationtests/testdata/nftTransferCrossShardWithScCall/cross-shard-transfer-with-sc-call.json +++ b/integrationtests/testdata/nftTransferCrossShardWithScCall/cross-shard-transfer-with-sc-call.json @@ -17,6 +17,7 @@ "data": "RVNEVE5GVFRyYW5zZmVyQDRkNDU1ODQ2NDE1MjRkMmQ2MzYzNjIzMjM1MzJAMDc4YkAwMzQ3NTQzZTViNTljOWJlODY3MEAwMDAwMDAwMDAwMDAwMDAwMDUwMGE3YTAyNzcxYWEwNzA5MGU2MDdmMDJiMjVmNGQ2ZDI0MWJmZjMyYjk5MGEyQDYzNmM2MTY5NmQ1MjY1Nzc2MTcyNjQ3Mw==", "signature": "", "timestamp": 5040, + "timestampMs": 5040000, "status": "success", "searchOrder": 0, "hasScResults": true, diff --git a/integrationtests/testdata/relayedTx/relayed-tx-after-refund.json b/integrationtests/testdata/relayedTx/relayed-tx-after-refund.json index 9551d92a..f80a18a9 100644 --- a/integrationtests/testdata/relayedTx/relayed-tx-after-refund.json +++ b/integrationtests/testdata/relayedTx/relayed-tx-after-refund.json @@ -17,6 +17,7 @@ "data": "cmVsYXllZFR4QDdiMjI2ZTZmNmU2MzY1MjIzYTMyMmMyMjc2NjE2Yzc1NjUyMjNhMzAyYzIyNzI2NTYzNjU2OTc2NjU3MjIyM2EyMjQxNDE0MTQxNDE0MTQxNDE0MTQxNDE0NjQxNDk3NDY3MzczODM1MmY3MzZjNzM1NTQxNDg2ODZiNTczMzQ1Njk2MjRjNmU0NzUyNGI3NjQ5NmY0ZTRkM2QyMjJjMjI3MzY1NmU2NDY1NzIyMjNhMjI3MjZiNmU1MzRhNDc3YTM0Mzc2OTUzNGU3OTRiNDM2NDJmNTA0ZjcxNzA3NTc3NmI1NDc3Njg0NTM0MzA2ZDdhNDc2YTU4NWE1MTY4NmU2MjJiNzI0ZDNkMjIyYzIyNjc2MTczNTA3MjY5NjM2NTIyM2EzMTMwMzAzMDMwMzAzMDMwMzAzMDJjMjI2NzYxNzM0YzY5NmQ2OTc0MjIzYTMxMzUzMDMwMzAzMDMwMzAyYzIyNjQ2MTc0NjEyMjNhMjI2MzMyNDYzMjVhNTU0NjMwNjQ0NzU2N2E2NDQ3NDYzMDYxNTczOTc1NTE0NDQ2Njg1OTdhNDkzMTRkNmE1OTM1NTk2ZDUxMzM1YTQ0NDk3NzU5MzI0YTY5NTk1NDRkMzE1OTZkNTY2YzRmNDQ1OTMxNGQ0NDY0Njg0ZjU3NGU2YTRlN2E2NzdhNWE0NzU1Nzc0ZjQ0NWE2OTRlNDQ0NTMzNGU1NDZiMzQ1YTU0NTE3YTU5NTQ0ZTZiNWE2YTU2NmE1OTMyNDU3OTVhNTQ2ODY4NGQ2YTZjNDE0ZDZhNTEzNDRlNTQ2NzdhNGQ1NzRlNmQ0ZDU0NDUzMDRkNTQ1NjZkNTk2YTQxMzU0ZDZhNjM3NzRlNDQ1MTMyNGU1NzU1MzI0ZTdhNTk3YTU5NTc0ZDMxNGY0NDQ1MzQ1YTU0NjczMTRlNDc1MTM0NTk1NzUyNmQ0ZTU0NDE3YTU5NmE2MzM1NGQ2YTZjNmI0ZjU0NTI2YzRlNmQ0OTc5NGU2YTQ5Nzc1YTY3M2QzZDIyMmMyMjYzNjg2MTY5NmU0OTQ0MjIzYTIyNGQ1MTNkM2QyMjJjMjI3NjY1NzI3MzY5NmY2ZTIyM2EzMTJjMjI3MzY5Njc2ZTYxNzQ3NTcyNjUyMjNhMjI1MjM5NDYyYjM0NTQ2MzUyNDE1YTM4NmQ3NzcxMzI0NTU5MzAzMTYzNTk2YzMzNzY2MjcxNmM0NjY1NzE3NjM4N2E3NjQ3NGE3NzVhNjgzMzU5NGQ0ZjU1NmI0MjM0NjQzNDUxNTc0ZTY2Mzc2NzQ0NjI2YzQ4NDgzMjU3NmI3MTYxNGE3NjYxNDg0NTc0NDM1NjYxNzA0OTcxMzM2NTM1NjU2MjM4NGU0MTc3M2QzZDIyN2Q=", "signature": "", "timestamp": 5040, + "timestampMs": 5040000, "status": "success", "searchOrder": 0, "hasScResults": true, diff --git a/integrationtests/testdata/relayedTx/relayed-tx-intra.json b/integrationtests/testdata/relayedTx/relayed-tx-intra.json index dca3547e..c253da37 100644 --- a/integrationtests/testdata/relayedTx/relayed-tx-intra.json +++ b/integrationtests/testdata/relayedTx/relayed-tx-intra.json @@ -17,6 +17,7 @@ "data": "cmVsYXllZFR4QDdiMjI2ZTZmNmU2MzY1MjIzYTMwMmMyMjc2NjE2Yzc1NjUyMjNhMzAyYzIyNzI2NTYzNjU2OTc2NjU3MjIyM2EyMjcyNmI2ZTUzNGE0NzdhMzQzNzY5NTM0ZTc5NGI0MzY0MmY1MDRmNzE3MDc1Nzc2YjU0Nzc2ODQ1MzQzMDZkN2E0NzZhNTg1YTUxNjg2ZTYyMmI3MjRkM2QyMjJjMjI3MzY1NmU2NDY1NzIyMjNhMjI3MjZiNmU1MzRhNDc3YTM0Mzc2OTUzNGU3OTRiNDM2NDJmNTA0ZjcxNzA3NTc3NmI1NDc3Njg0NTM0MzA2ZDdhNDc2YTU4NWE1MTY4NmU2MjJiNzI0ZDNkMjIyYzIyNjc2MTczNTA3MjY5NjM2NTIyM2EzMTMwMzAzMDMwMzAzMDMwMzAzMDJjMjI2NzYxNzM0YzY5NmQ2OTc0MjIzYTMxMzMzMjMzMzIzMDMwMzAyYzIyNjQ2MTc0NjEyMjNhMjI1NTMyNDYzMjVhNTU3NDZjNjU1NjVhNjg2MjQ4NTY2YzUxNDQ1OTc5NGU2YjU1MzI0ZDZiNDEzMjRkNmE1YTQ2NGU2YTQ5N2E0ZDU0NGQzNTRlNmE1NTMyNGQ1NDRkMzI0ZTZiNGQzMjUxNTQ2Mzc4NGQ3YTZiMzI1MTdhNjMzMDRlNmE1NTMzNGU0NDYzMzA0ZTdhNjczMjRlNTQ0ZDMzNGU3YTUxN2E0ZTdhNTkzMzRlNmI1NTdhNGQ0NDYzNzc0ZDdhNDk3YTRmNTQ2NDQyNGU3YTU5MzM0ZTU0NWE0NDRlNmE0NTMzNGU1NDU5MzI0ZTZhNjMzMzRlNTQ0ZDMwNGU3YTQ1N2E0ZTdhNTkzMzRlN2E0YTQxNGU2YTU1MzM0ZTQ0NTkzNDUxNDQ0ZDc3NGU3YTY3N2E0ZDU0NGQzMDRlNDQ1MTMyNGQ2YTRkNzg0ZTZhNTU3YTRkNDQ0ZDMxNGU2YTU5N2E0ZTU0NTE3YTRlNmE0NTdhNGU1NDRkMzE0ZTZhNDk3YTRkNTQ0ZDdhNGU0NDQ1MzA0ZDdhNTk3ODRkN2E2MzMyNGQ3YTRkMzA0ZTZhNGQ3YTRkNDQ0ZDc4NGU2YTU5N2E0ZTU0NTkzMDRlNDQ1NTdhNGU1NDRkMzE0ZTQ0NDk3YTRmNTQ1MTdhNGU0NDQ1MzI0ZTZhNTk3ODRkN2E2MzdhNGY1NTQxMzI0ZDZhNjMzMDRlNmE0ZTQxNGU2YTQ5MzI0ZDdhNGQ3ODRlN2E0NTMyNGQ1NDU5MzE0ZDdhNTU3YTRmNDQ0ZDdhNGQ3YTRkMzM0ZDZhNjM3OTRlN2E1OTdhNGU0NDRkNzc0ZDdhNDE3YTRlNTQ1YTQ0NGU2YTU5MzI1MjQ0NGQzMTRlN2E1OTMyNTI0NDRkMzI0ZTdhNTUzMjUxNTQ2MzMyNGU2YTUxN2E0ZTQ0NTk3YTRlN2E1MTdhNGY1NDVhNDI0ZTZhNGQ3YTRlNTQ1YTQyNGU3YTYzMzM1MTU0NGQzNDRlNmE1NTMzNGY0NDYzNzcyMjJjMjI2MzY4NjE2OTZlNDk0NDIyM2EyMjRkNTEzZDNkMjIyYzIyNzY2NTcyNzM2OTZmNmUyMjNhMzEyYzIyNzM2OTY3NmU2MTc0NzU3MjY1MjIzYTIyNzE2NjcwNGE0Nzc2NzM0NDQ0NDI1NTUxNGUyZjUyNTU0NzRmNTA1Mzc1NTIzMjQ4NGY0YTYxNGI3MDM4NDUzNjYzNGU1NDc3MzAzMzQzMzc2OTM0NTU3Nzc2MmY0YzU0NzM2ZDJiNmE3MDQyMzk3NTZjNDgzOTY2NTMyYjQ0NzE2MTcyNzE0ZjYyNDg0MTcwMzg2NjZkNzIzMDZhNDE1NTMxNzM2ZTM1NDE2NzNkM2QyMjdk", "signature": "", "timestamp": 5040, + "timestampMs": 5040000, "status": "success", "searchOrder": 0, "hasScResults": true, diff --git a/integrationtests/testdata/relayedTx/relayed-tx-source.json b/integrationtests/testdata/relayedTx/relayed-tx-source.json index 4e6d217a..64347021 100644 --- a/integrationtests/testdata/relayedTx/relayed-tx-source.json +++ b/integrationtests/testdata/relayedTx/relayed-tx-source.json @@ -17,6 +17,7 @@ "data": "cmVsYXllZFR4QDdiMjI2ZTZmNmU2MzY1MjIzYTMyMmMyMjc2NjE2Yzc1NjUyMjNhMzAyYzIyNzI2NTYzNjU2OTc2NjU3MjIyM2EyMjQxNDE0MTQxNDE0MTQxNDE0MTQxNDE0NjQxNDk3NDY3MzczODM1MmY3MzZjNzM1NTQxNDg2ODZiNTczMzQ1Njk2MjRjNmU0NzUyNGI3NjQ5NmY0ZTRkM2QyMjJjMjI3MzY1NmU2NDY1NzIyMjNhMjI3MjZiNmU1MzRhNDc3YTM0Mzc2OTUzNGU3OTRiNDM2NDJmNTA0ZjcxNzA3NTc3NmI1NDc3Njg0NTM0MzA2ZDdhNDc2YTU4NWE1MTY4NmU2MjJiNzI0ZDNkMjIyYzIyNjc2MTczNTA3MjY5NjM2NTIyM2EzMTMwMzAzMDMwMzAzMDMwMzAzMDJjMjI2NzYxNzM0YzY5NmQ2OTc0MjIzYTMxMzUzMDMwMzAzMDMwMzAyYzIyNjQ2MTc0NjEyMjNhMjI2MzMyNDYzMjVhNTU0NjMwNjQ0NzU2N2E2NDQ3NDYzMDYxNTczOTc1NTE0NDQ2Njg1OTdhNDkzMTRkNmE1OTM1NTk2ZDUxMzM1YTQ0NDk3NzU5MzI0YTY5NTk1NDRkMzE1OTZkNTY2YzRmNDQ1OTMxNGQ0NDY0Njg0ZjU3NGU2YTRlN2E2NzdhNWE0NzU1Nzc0ZjQ0NWE2OTRlNDQ0NTMzNGU1NDZiMzQ1YTU0NTE3YTU5NTQ0ZTZiNWE2YTU2NmE1OTMyNDU3OTVhNTQ2ODY4NGQ2YTZjNDE0ZDZhNTEzNDRlNTQ2NzdhNGQ1NzRlNmQ0ZDU0NDUzMDRkNTQ1NjZkNTk2YTQxMzU0ZDZhNjM3NzRlNDQ1MTMyNGU1NzU1MzI0ZTdhNTk3YTU5NTc0ZDMxNGY0NDQ1MzQ1YTU0NjczMTRlNDc1MTM0NTk1NzUyNmQ0ZTU0NDE3YTU5NmE2MzM1NGQ2YTZjNmI0ZjU0NTI2YzRlNmQ0OTc5NGU2YTQ5Nzc1YTY3M2QzZDIyMmMyMjYzNjg2MTY5NmU0OTQ0MjIzYTIyNGQ1MTNkM2QyMjJjMjI3NjY1NzI3MzY5NmY2ZTIyM2EzMTJjMjI3MzY5Njc2ZTYxNzQ3NTcyNjUyMjNhMjI1MjM5NDYyYjM0NTQ2MzUyNDE1YTM4NmQ3NzcxMzI0NTU5MzAzMTYzNTk2YzMzNzY2MjcxNmM0NjY1NzE3NjM4N2E3NjQ3NGE3NzVhNjgzMzU5NGQ0ZjU1NmI0MjM0NjQzNDUxNTc0ZTY2Mzc2NzQ0NjI2YzQ4NDgzMjU3NmI3MTYxNGE3NjYxNDg0NTc0NDM1NjYxNzA0OTcxMzM2NTM1NjU2MjM4NGU0MTc3M2QzZDIyN2Q=", "signature": "", "timestamp": 5040, + "timestampMs": 5040000, "status": "success", "searchOrder": 0, "hasScResults": true, diff --git a/integrationtests/testdata/relayedTxV3/relayed-v3-no-refund.json b/integrationtests/testdata/relayedTxV3/relayed-v3-no-refund.json index aabff5b8..cd47c384 100644 --- a/integrationtests/testdata/relayedTxV3/relayed-v3-no-refund.json +++ b/integrationtests/testdata/relayedTxV3/relayed-v3-no-refund.json @@ -17,6 +17,7 @@ "data": "ZG9Tb21ldGhpbmc=", "signature": "64", "timestamp": 5040, + "timestampMs": 5040000, "status": "success", "searchOrder": 0, "isScCall": true, diff --git a/integrationtests/testdata/relayedTxV3/relayed-v3-with-one-refund.json b/integrationtests/testdata/relayedTxV3/relayed-v3-with-one-refund.json index d0c40bba..c74cc40e 100644 --- a/integrationtests/testdata/relayedTxV3/relayed-v3-with-one-refund.json +++ b/integrationtests/testdata/relayedTxV3/relayed-v3-with-one-refund.json @@ -17,6 +17,7 @@ "data": "ZG9Tb21ldGhpbmc=", "signature": "64", "timestamp": 5040, + "timestampMs": 5040000, "status": "success", "searchOrder": 0, "isScCall": true, diff --git a/integrationtests/testdata/relayedTxV3/relayed-v3-with-two-refunds.json b/integrationtests/testdata/relayedTxV3/relayed-v3-with-two-refunds.json index 62e10c15..764f218f 100644 --- a/integrationtests/testdata/relayedTxV3/relayed-v3-with-two-refunds.json +++ b/integrationtests/testdata/relayedTxV3/relayed-v3-with-two-refunds.json @@ -17,6 +17,7 @@ "data": "ZG9Tb21ldGhpbmc=", "signature": "64", "timestamp": 5040, + "timestampMs": 5040000, "status": "success", "searchOrder": 0, "isScCall": true, diff --git a/integrationtests/testdata/scCallIntraShard/claim-rewards.json b/integrationtests/testdata/scCallIntraShard/claim-rewards.json index 7e8d77ca..0ad03caf 100644 --- a/integrationtests/testdata/scCallIntraShard/claim-rewards.json +++ b/integrationtests/testdata/scCallIntraShard/claim-rewards.json @@ -17,6 +17,7 @@ "data": "Y2xhaW1SZXdhcmRz", "signature": "", "timestamp": 5040, + "timestampMs": 5040000, "status": "success", "searchOrder": 0, "hasScResults": true, diff --git a/integrationtests/testdata/scCallIntraShard/sc-call-fail.json b/integrationtests/testdata/scCallIntraShard/sc-call-fail.json index 22dac8d7..3811e1dc 100644 --- a/integrationtests/testdata/scCallIntraShard/sc-call-fail.json +++ b/integrationtests/testdata/scCallIntraShard/sc-call-fail.json @@ -17,6 +17,7 @@ "data": "ZGVsZWdhdGU=", "signature": "", "timestamp": 5040, + "timestampMs": 5040000, "status": "fail", "searchOrder": 0, "hasScResults": true, diff --git a/integrationtests/testdata/scCallWithIssueEsdt/scr-with-callback-executed-on-destination-shard.json b/integrationtests/testdata/scCallWithIssueEsdt/scr-with-callback-executed-on-destination-shard.json index 5b145d2c..e5e416f8 100644 --- a/integrationtests/testdata/scCallWithIssueEsdt/scr-with-callback-executed-on-destination-shard.json +++ b/integrationtests/testdata/scCallWithIssueEsdt/scr-with-callback-executed-on-destination-shard.json @@ -14,6 +14,7 @@ "originalTxHash": "747857697468536343616c6c", "callType": "2", "timestamp": 5040, + "timestampMs": 5040000, "hasOperations": true, "type": "unsigned", "status": "success", diff --git a/integrationtests/testdata/scCallWithIssueEsdt/scr-with-callback-executed-on-source.json b/integrationtests/testdata/scCallWithIssueEsdt/scr-with-callback-executed-on-source.json index d409e116..d783b0be 100644 --- a/integrationtests/testdata/scCallWithIssueEsdt/scr-with-callback-executed-on-source.json +++ b/integrationtests/testdata/scCallWithIssueEsdt/scr-with-callback-executed-on-source.json @@ -14,6 +14,7 @@ "originalTxHash": "747857697468536343616c6c", "callType": "2", "timestamp": 5040, + "timestampMs": 5040000, "type": "unsigned", "status": "pending", "operation": "transfer", diff --git a/integrationtests/testdata/scCallWithIssueEsdt/scr-with-issue-executed-on-destination-shard.json b/integrationtests/testdata/scCallWithIssueEsdt/scr-with-issue-executed-on-destination-shard.json index cccd0b56..b536be43 100644 --- a/integrationtests/testdata/scCallWithIssueEsdt/scr-with-issue-executed-on-destination-shard.json +++ b/integrationtests/testdata/scCallWithIssueEsdt/scr-with-issue-executed-on-destination-shard.json @@ -14,6 +14,7 @@ "originalTxHash": "747857697468536343616c6c", "callType": "1", "timestamp": 5040, + "timestampMs": 5040000, "type": "unsigned", "status": "success", "operation": "transfer", diff --git a/integrationtests/testdata/scCallWithIssueEsdt/scr-with-issue-executed-on-source-shard.json b/integrationtests/testdata/scCallWithIssueEsdt/scr-with-issue-executed-on-source-shard.json index 7339cb15..c6d0700c 100644 --- a/integrationtests/testdata/scCallWithIssueEsdt/scr-with-issue-executed-on-source-shard.json +++ b/integrationtests/testdata/scCallWithIssueEsdt/scr-with-issue-executed-on-source-shard.json @@ -14,6 +14,7 @@ "originalTxHash": "747857697468536343616c6c", "callType": "1", "timestamp": 5040, + "timestampMs": 5040000, "type": "unsigned", "status": "pending", "operation": "transfer", diff --git a/integrationtests/testdata/scCallWithIssueEsdt/tx-after-execution-of-callback-on-destination-shard.json b/integrationtests/testdata/scCallWithIssueEsdt/tx-after-execution-of-callback-on-destination-shard.json index ed524a11..f44f5da7 100644 --- a/integrationtests/testdata/scCallWithIssueEsdt/tx-after-execution-of-callback-on-destination-shard.json +++ b/integrationtests/testdata/scCallWithIssueEsdt/tx-after-execution-of-callback-on-destination-shard.json @@ -17,6 +17,7 @@ "data": "aXNzdWVUb2tlbkA0RDc5NTQ2NTczNzQ0RTY2NzQ2NEA1NDQ1NTM1NDRFNDY1NA==", "signature": "", "timestamp": 5040, + "timestampMs": 5040000, "status": "fail", "searchOrder": 0, "hasScResults": true, diff --git a/integrationtests/testdata/scCallWithIssueEsdt/tx-after-execution-on-source-shard.json b/integrationtests/testdata/scCallWithIssueEsdt/tx-after-execution-on-source-shard.json index cb9c4326..41185cb4 100644 --- a/integrationtests/testdata/scCallWithIssueEsdt/tx-after-execution-on-source-shard.json +++ b/integrationtests/testdata/scCallWithIssueEsdt/tx-after-execution-on-source-shard.json @@ -17,6 +17,7 @@ "data": "aXNzdWVUb2tlbkA0RDc5NTQ2NTczNzQ0RTY2NzQ2NEA1NDQ1NTM1NDRFNDY1NA==", "signature": "", "timestamp": 5040, + "timestampMs": 5040000, "status": "success", "searchOrder": 0, "hasScResults": true, diff --git a/integrationtests/testdata/scCallWithIssueEsdt/tx-in-op-index-execution-of-callback-on-destination-shard.json b/integrationtests/testdata/scCallWithIssueEsdt/tx-in-op-index-execution-of-callback-on-destination-shard.json index f13509ee..e8bd9a81 100644 --- a/integrationtests/testdata/scCallWithIssueEsdt/tx-in-op-index-execution-of-callback-on-destination-shard.json +++ b/integrationtests/testdata/scCallWithIssueEsdt/tx-in-op-index-execution-of-callback-on-destination-shard.json @@ -17,6 +17,7 @@ "data": "aXNzdWVUb2tlbkA0RDc5NTQ2NTczNzQ0RTY2NzQ2NEA1NDQ1NTM1NDRFNDY1NA==", "signature": "", "timestamp": 5040, + "timestampMs": 5040000, "status": "fail", "searchOrder": 0, "hasScResults": true, diff --git a/integrationtests/testdata/scDeploy/deploy-after-upgrade-and-change-owner-second.json b/integrationtests/testdata/scDeploy/deploy-after-upgrade-and-change-owner-second.json index eaadb107..03bc7f19 100644 --- a/integrationtests/testdata/scDeploy/deploy-after-upgrade-and-change-owner-second.json +++ b/integrationtests/testdata/scDeploy/deploy-after-upgrade-and-change-owner-second.json @@ -4,24 +4,28 @@ "currentOwner": "erd1y78ds2tvzw6ntcggldjld2vk96wgq0mj47mk6auny0nkvn242e3sd4qz7m", "initialCodeHash": "Y29kZUhhc2g=", "timestamp": 5040, + "timestampMs": 5040000, "upgrades": [ { "upgradeTxHash": "6832", "codeHash": "c2Vjb25kQ29kZUhhc2g=", "upgrader": "erd12m3x8jp6dl027pj5f2nw6ght2cyhhjfrs86cdwsa8xn83r375qfqrwpdx0", - "timestamp": 6000 + "timestamp": 6000, + "timestampMs": 6000000 } ], "owners": [ { "address": "erd1d942l8w4yvgjffpqacs8vdwl0mndsv0zn0uxa80hxc3xmq4477eqnyw3dh", "txHash": "6833", - "timestamp": 7000 + "timestamp": 7000, + "timestampMs": 7000000 }, { "address": "erd1y78ds2tvzw6ntcggldjld2vk96wgq0mj47mk6auny0nkvn242e3sd4qz7m", "txHash": "6834", - "timestamp": 8000 + "timestamp": 8000, + "timestampMs": 8000000 } ] } diff --git a/integrationtests/testdata/scDeploy/deploy-after-upgrade-and-change-owner.json b/integrationtests/testdata/scDeploy/deploy-after-upgrade-and-change-owner.json index e4824dd0..94df269d 100644 --- a/integrationtests/testdata/scDeploy/deploy-after-upgrade-and-change-owner.json +++ b/integrationtests/testdata/scDeploy/deploy-after-upgrade-and-change-owner.json @@ -4,19 +4,22 @@ "currentOwner": "erd1d942l8w4yvgjffpqacs8vdwl0mndsv0zn0uxa80hxc3xmq4477eqnyw3dh", "initialCodeHash": "Y29kZUhhc2g=", "timestamp": 5040, + "timestampMs": 5040000, "upgrades": [ { "upgradeTxHash": "6832", "codeHash": "c2Vjb25kQ29kZUhhc2g=", "upgrader": "erd12m3x8jp6dl027pj5f2nw6ght2cyhhjfrs86cdwsa8xn83r375qfqrwpdx0", - "timestamp": 6000 + "timestamp": 6000, + "timestampMs": 6000000 } ], "owners": [ { "address": "erd1d942l8w4yvgjffpqacs8vdwl0mndsv0zn0uxa80hxc3xmq4477eqnyw3dh", "txHash": "6833", - "timestamp": 7000 + "timestamp": 7000, + "timestampMs": 7000000 } ] } diff --git a/integrationtests/testdata/scDeploy/deploy-after-upgrade.json b/integrationtests/testdata/scDeploy/deploy-after-upgrade.json index 687b1969..5b77d4f3 100644 --- a/integrationtests/testdata/scDeploy/deploy-after-upgrade.json +++ b/integrationtests/testdata/scDeploy/deploy-after-upgrade.json @@ -4,12 +4,14 @@ "currentOwner": "erd12m3x8jp6dl027pj5f2nw6ght2cyhhjfrs86cdwsa8xn83r375qfqrwpdx0", "initialCodeHash": "Y29kZUhhc2g=", "timestamp": 5040, + "timestampMs": 5040000, "upgrades": [ { "upgradeTxHash": "6832", "codeHash": "c2Vjb25kQ29kZUhhc2g=", "upgrader": "erd12m3x8jp6dl027pj5f2nw6ght2cyhhjfrs86cdwsa8xn83r375qfqrwpdx0", - "timestamp": 6000 + "timestamp": 6000, + "timestampMs": 6000000 } ], "owners": [] diff --git a/integrationtests/testdata/scDeploy/deploy.json b/integrationtests/testdata/scDeploy/deploy.json index 4f8bd080..19f4249a 100644 --- a/integrationtests/testdata/scDeploy/deploy.json +++ b/integrationtests/testdata/scDeploy/deploy.json @@ -3,6 +3,7 @@ "deployer": "erd12m3x8jp6dl027pj5f2nw6ght2cyhhjfrs86cdwsa8xn83r375qfqrwpdx0", "currentOwner": "erd12m3x8jp6dl027pj5f2nw6ght2cyhhjfrs86cdwsa8xn83r375qfqrwpdx0", "timestamp": 5040, + "timestampMs": 5040000, "initialCodeHash": "Y29kZUhhc2g=", "upgrades": [], "owners": [] diff --git a/integrationtests/testdata/scDeploy/tx-deploy-with-error-event.json b/integrationtests/testdata/scDeploy/tx-deploy-with-error-event.json index 1bd1c109..ca0cdd8a 100644 --- a/integrationtests/testdata/scDeploy/tx-deploy-with-error-event.json +++ b/integrationtests/testdata/scDeploy/tx-deploy-with-error-event.json @@ -17,6 +17,7 @@ "data": "MDA2MTczNmQwMTAwMDAwMDAxMGQwMzYwMDAwMDYwMDAwMTdmNjAwMjdmN2YwMDAyM2UwMzAzNjU2ZTc2MGY2NzY1NzQ0ZTc1NmQ0MTcyNjc3NTZkNjU2ZTc0NzMwMDAxMDM2NTZlNzYwYjczNjk2NzZlNjE2YzQ1NzI3MjZmNzIwMDAyMDM2NTZlNzYwZTYzNjg2NTYzNmI0ZTZmNTA2MTc5NmQ2NTZlNzQwMDAwMDMwMzAyMDAwMDA1MDMwMTAwMDMwNjBmMDI3ZjAwNDE5OTgwMDgwYjdmMDA0MWEwODAwODBiMDczNzA1MDY2ZDY1NmQ2ZjcyNzkwMjAwMDQ2OTZlNjk3NDAwMDMwODYzNjE2YzZjNDI2MTYzNmIwMDA0MGE1ZjVmNjQ2MTc0NjE1ZjY1NmU2NDAzMDAwYjVmNWY2ODY1NjE3MDVmNjI2MTczNjUwMzAxMGExODAyMTIwMDEwMDIxMDAwMDQ0MDQxODA4MDA4NDExOTEwMDEwMDBiMGIwMzAwMDEwYjBiMjEwMTAwNDE4MDgwMDgwYjE5Nzc3MjZmNmU2NzIwNmU3NTZkNjI2NTcyMjA2ZjY2MjA2MTcyNjc3NTZkNjU2ZTc0NzNAMDUwMEAwNTAy", "signature": "", "timestamp": 5040, + "timestampMs": 5040000, "status": "fail", "searchOrder": 0, "isScCall": true, diff --git a/integrationtests/testdata/scDeploy/tx-sc-deploy.json b/integrationtests/testdata/scDeploy/tx-sc-deploy.json index ad7da041..5dfddc0d 100644 --- a/integrationtests/testdata/scDeploy/tx-sc-deploy.json +++ b/integrationtests/testdata/scDeploy/tx-sc-deploy.json @@ -17,6 +17,7 @@ "data": "MDA2MTczNmQwMTAwMDAwMDAxMGQwMzYwMDAwMDYwMDAwMTdmNjAwMjdmN2YwMDAyM2UwMzAzNjU2ZTc2MGY2NzY1NzQ0ZTc1NmQ0MTcyNjc3NTZkNjU2ZTc0NzMwMDAxMDM2NTZlNzYwYjczNjk2NzZlNjE2YzQ1NzI3MjZmNzIwMDAyMDM2NTZlNzYwZTYzNjg2NTYzNmI0ZTZmNTA2MTc5NmQ2NTZlNzQwMDAwMDMwMzAyMDAwMDA1MDMwMTAwMDMwNjBmMDI3ZjAwNDE5OTgwMDgwYjdmMDA0MWEwODAwODBiMDczNzA1MDY2ZDY1NmQ2ZjcyNzkwMjAwMDQ2OTZlNjk3NDAwMDMwODYzNjE2YzZjNDI2MTYzNmIwMDA0MGE1ZjVmNjQ2MTc0NjE1ZjY1NmU2NDAzMDAwYjVmNWY2ODY1NjE3MDVmNjI2MTczNjUwMzAxMGExODAyMTIwMDEwMDIxMDAwMDQ0MDQxODA4MDA4NDExOTEwMDEwMDBiMGIwMzAwMDEwYjBiMjEwMTAwNDE4MDgwMDgwYjE5Nzc3MjZmNmU2NzIwNmU3NTZkNjI2NTcyMjA2ZjY2MjA2MTcyNjc3NTZkNjU2ZTc0NzNAMDUwMEAwNTAy", "signature": "", "timestamp": 5040, + "timestampMs": 5040000, "status": "success", "searchOrder": 0, "isScCall": true, diff --git a/integrationtests/testdata/transactions/move-balance.json b/integrationtests/testdata/transactions/move-balance.json index b5b56f0f..9b24b0de 100644 --- a/integrationtests/testdata/transactions/move-balance.json +++ b/integrationtests/testdata/transactions/move-balance.json @@ -17,6 +17,7 @@ "data": "dHJhbnNmZXI=", "signature": "", "timestamp": 5040, + "timestampMs": 5040000, "status": "success", "searchOrder": 0, "operation": "transfer", diff --git a/integrationtests/testdata/updateNFT/token-after-add-uris.json b/integrationtests/testdata/updateNFT/token-after-add-uris.json index cb54e606..91519905 100644 --- a/integrationtests/testdata/updateNFT/token-after-add-uris.json +++ b/integrationtests/testdata/updateNFT/token-after-add-uris.json @@ -4,6 +4,7 @@ "numDecimals": 0, "nonce": 14, "timestamp": 5040, + "timestampMs": 5040000, "data": { "uris": [ "dXJp", diff --git a/integrationtests/testdata/updateNFT/token-after-freeze.json b/integrationtests/testdata/updateNFT/token-after-freeze.json index 587dd76a..4bc3b34c 100644 --- a/integrationtests/testdata/updateNFT/token-after-freeze.json +++ b/integrationtests/testdata/updateNFT/token-after-freeze.json @@ -4,6 +4,7 @@ "numDecimals": 0, "nonce": 14, "timestamp": 5040, + "timestampMs": 5040000, "data": { "uris": [ "dXJp", diff --git a/integrationtests/testdata/updateNFT/token-after-new-creator.json b/integrationtests/testdata/updateNFT/token-after-new-creator.json index ac967297..ab6f8616 100644 --- a/integrationtests/testdata/updateNFT/token-after-new-creator.json +++ b/integrationtests/testdata/updateNFT/token-after-new-creator.json @@ -4,6 +4,7 @@ "numDecimals": 0, "nonce": 14, "timestamp": 5040, + "timestampMs": 5040000, "data": { "uris": [ "dXJp", diff --git a/integrationtests/testdata/updateNFT/token-after-new-royalties.json b/integrationtests/testdata/updateNFT/token-after-new-royalties.json index b8eb8dbc..142d3807 100644 --- a/integrationtests/testdata/updateNFT/token-after-new-royalties.json +++ b/integrationtests/testdata/updateNFT/token-after-new-royalties.json @@ -4,6 +4,7 @@ "numDecimals": 0, "nonce": 14, "timestamp": 5040, + "timestampMs": 5040000, "data": { "uris": [ "dXJp", diff --git a/integrationtests/testdata/updateNFT/token-after-recreate.json b/integrationtests/testdata/updateNFT/token-after-recreate.json index 3b2385f6..b4c0ff86 100644 --- a/integrationtests/testdata/updateNFT/token-after-recreate.json +++ b/integrationtests/testdata/updateNFT/token-after-recreate.json @@ -4,6 +4,7 @@ "numDecimals": 0, "nonce": 100, "timestamp": 5040, + "timestampMs": 5040000, "data": { "uris": [ "dXJp" diff --git a/integrationtests/testdata/updateNFT/token-after-set-new-uris.json b/integrationtests/testdata/updateNFT/token-after-set-new-uris.json index c3b3ad8a..4555a3ee 100644 --- a/integrationtests/testdata/updateNFT/token-after-set-new-uris.json +++ b/integrationtests/testdata/updateNFT/token-after-set-new-uris.json @@ -4,6 +4,7 @@ "numDecimals": 0, "nonce": 14, "timestamp": 5040, + "timestampMs": 5040000, "data": { "uris": [ "dXJp", diff --git a/integrationtests/testdata/updateNFT/token-after-un-freeze.json b/integrationtests/testdata/updateNFT/token-after-un-freeze.json index 0e791b5a..8e28184f 100644 --- a/integrationtests/testdata/updateNFT/token-after-un-freeze.json +++ b/integrationtests/testdata/updateNFT/token-after-un-freeze.json @@ -4,6 +4,7 @@ "numDecimals": 0, "nonce": 14, "timestamp": 5040, + "timestampMs": 5040000, "data": { "uris": [ "dXJp", diff --git a/integrationtests/testdata/updateNFT/token-after-update-attributes-second.json b/integrationtests/testdata/updateNFT/token-after-update-attributes-second.json index 088aac10..db57f0dd 100644 --- a/integrationtests/testdata/updateNFT/token-after-update-attributes-second.json +++ b/integrationtests/testdata/updateNFT/token-after-update-attributes-second.json @@ -4,6 +4,7 @@ "numDecimals": 0, "nonce": 14, "timestamp": 5040, + "timestampMs": 5040000, "data": { "uris": [ "dXJp", diff --git a/integrationtests/testdata/updateNFT/token-after-update-attributes.json b/integrationtests/testdata/updateNFT/token-after-update-attributes.json index 43bb9c4d..27a92fe9 100644 --- a/integrationtests/testdata/updateNFT/token-after-update-attributes.json +++ b/integrationtests/testdata/updateNFT/token-after-update-attributes.json @@ -4,6 +4,7 @@ "numDecimals": 0, "nonce": 14, "timestamp": 5040, + "timestampMs": 5040000, "data": { "uris": [ "dXJp", diff --git a/integrationtests/testdata/updateNFT/token-after-update.json b/integrationtests/testdata/updateNFT/token-after-update.json index ebb9c835..1e7527e9 100644 --- a/integrationtests/testdata/updateNFT/token-after-update.json +++ b/integrationtests/testdata/updateNFT/token-after-update.json @@ -4,6 +4,7 @@ "numDecimals": 0, "nonce": 100, "timestamp": 5040, + "timestampMs": 5040000, "data": { "uris": [ "dXJp" diff --git a/integrationtests/testdata/updateNFT/token-before-recreate.json b/integrationtests/testdata/updateNFT/token-before-recreate.json index 8abec9d2..d6d65238 100644 --- a/integrationtests/testdata/updateNFT/token-before-recreate.json +++ b/integrationtests/testdata/updateNFT/token-before-recreate.json @@ -4,6 +4,7 @@ "numDecimals": 0, "nonce": 100, "timestamp": 5040, + "timestampMs": 5040000, "data": { "name": "token-token-token", "uris": [ diff --git a/integrationtests/testdata/updateNFT/token-color-1.json b/integrationtests/testdata/updateNFT/token-color-1.json index 4c4f1a45..4e7ae6e6 100644 --- a/integrationtests/testdata/updateNFT/token-color-1.json +++ b/integrationtests/testdata/updateNFT/token-color-1.json @@ -4,6 +4,7 @@ "numDecimals": 0, "nonce": 1, "timestamp": 5040, + "timestampMs": 5040000, "data": { "uris": [ "dXJp" diff --git a/integrationtests/testdata/updateNFT/token-color-2.json b/integrationtests/testdata/updateNFT/token-color-2.json index 87eccc69..fa9362db 100644 --- a/integrationtests/testdata/updateNFT/token-color-2.json +++ b/integrationtests/testdata/updateNFT/token-color-2.json @@ -4,6 +4,7 @@ "numDecimals": 0, "nonce": 2, "timestamp": 5040, + "timestampMs": 5040000, "data": { "uris": [ "dXJp" diff --git a/integrationtests/testdata/updateNFT/token.json b/integrationtests/testdata/updateNFT/token.json index cb54e606..91519905 100644 --- a/integrationtests/testdata/updateNFT/token.json +++ b/integrationtests/testdata/updateNFT/token.json @@ -4,6 +4,7 @@ "numDecimals": 0, "nonce": 14, "timestamp": 5040, + "timestampMs": 5040000, "data": { "uris": [ "dXJp", diff --git a/mock/dbAccountsHandlerStub.go b/mock/dbAccountsHandlerStub.go index 35747c27..c9305d41 100644 --- a/mock/dbAccountsHandlerStub.go +++ b/mock/dbAccountsHandlerStub.go @@ -7,7 +7,7 @@ import ( // DBAccountsHandlerStub - type DBAccountsHandlerStub struct { - PrepareAccountsHistoryCalled func(timestamp uint64, accounts map[string]*data.AccountInfo) map[string]*data.AccountBalanceHistory + PrepareAccountsHistoryCalled func(accounts map[string]*data.AccountInfo, timestampMS uint64) map[string]*data.AccountBalanceHistory SerializeAccountsHistoryCalled func(accounts map[string]*data.AccountBalanceHistory, buffSlice *data.BufferSlice, index string) error } @@ -17,19 +17,19 @@ func (dba *DBAccountsHandlerStub) GetAccounts(_ map[string]*alteredAccount.Alter } // PrepareRegularAccountsMap - -func (dba *DBAccountsHandlerStub) PrepareRegularAccountsMap(_ uint64, _ []*data.Account, _ uint32) map[string]*data.AccountInfo { +func (dba *DBAccountsHandlerStub) PrepareRegularAccountsMap(_ []*data.Account, _ uint32, _ uint64) map[string]*data.AccountInfo { return nil } // PrepareAccountsMapESDT - -func (dba *DBAccountsHandlerStub) PrepareAccountsMapESDT(_ uint64, _ []*data.AccountESDT, _ data.CountTags, _ uint32) (map[string]*data.AccountInfo, data.TokensHandler) { +func (dba *DBAccountsHandlerStub) PrepareAccountsMapESDT(_ []*data.AccountESDT, _ data.CountTags, _ uint32, _ uint64) (map[string]*data.AccountInfo, data.TokensHandler) { return nil, nil } // PrepareAccountsHistory - -func (dba *DBAccountsHandlerStub) PrepareAccountsHistory(timestamp uint64, accounts map[string]*data.AccountInfo, _ uint32) map[string]*data.AccountBalanceHistory { +func (dba *DBAccountsHandlerStub) PrepareAccountsHistory(accounts map[string]*data.AccountInfo, _ uint32, timestampMS uint64) map[string]*data.AccountBalanceHistory { if dba.PrepareAccountsHistoryCalled != nil { - return dba.PrepareAccountsHistoryCalled(timestamp, accounts) + return dba.PrepareAccountsHistoryCalled(accounts, timestampMS) } return nil diff --git a/mock/dbTransactionsHandlerStub.go b/mock/dbTransactionsHandlerStub.go index c4aff654..b50d85f9 100644 --- a/mock/dbTransactionsHandlerStub.go +++ b/mock/dbTransactionsHandlerStub.go @@ -20,7 +20,7 @@ func (tps *DBTransactionProcessorStub) SerializeTransactionsFeeData(_ map[string } // PrepareTransactionsForDatabase - -func (tps *DBTransactionProcessorStub) PrepareTransactionsForDatabase(mbs []*block.MiniBlock, header coreData.HeaderHandler, pool *outport.TransactionPool, _ bool, _ uint32) *data.PreparedResults { +func (tps *DBTransactionProcessorStub) PrepareTransactionsForDatabase(mbs []*block.MiniBlock, header coreData.HeaderHandler, pool *outport.TransactionPool, _ bool, _ uint32, _ uint64) *data.PreparedResults { if tps.PrepareTransactionsForDatabaseCalled != nil { return tps.PrepareTransactionsForDatabaseCalled(mbs, header, pool) } diff --git a/mock/elasticProcessorStub.go b/mock/elasticProcessorStub.go index 3d01b732..b9f7dd7a 100644 --- a/mock/elasticProcessorStub.go +++ b/mock/elasticProcessorStub.go @@ -12,19 +12,19 @@ type ElasticProcessorStub struct { RemoveHeaderCalled func(header coreData.HeaderHandler) error RemoveMiniblocksCalled func(header coreData.HeaderHandler, body *block.Body) error RemoveTransactionsCalled func(header coreData.HeaderHandler, body *block.Body) error - SaveMiniblocksCalled func(header coreData.HeaderHandler, miniBlocks []*block.MiniBlock) error + SaveMiniblocksCalled func(header coreData.HeaderHandler, miniBlocks []*block.MiniBlock, timestampMs uint64) error SaveTransactionsCalled func(outportBlockWithHeader *outport.OutportBlockWithHeader) error SaveValidatorsRatingCalled func(validatorsRating *outport.ValidatorsRating) error SaveRoundsInfoCalled func(infos *outport.RoundsInfo) error SaveShardValidatorsPubKeysCalled func(validators *outport.ValidatorsPubKeys) error SaveAccountsCalled func(accountsData *outport.Accounts) error - RemoveAccountsESDTCalled func(headerTimestamp uint64) error + RemoveAccountsESDTCalled func(shardID uint32, timestampMS uint64) error } // RemoveAccountsESDT - -func (eim *ElasticProcessorStub) RemoveAccountsESDT(headerTimestamp uint64, _ uint32) error { +func (eim *ElasticProcessorStub) RemoveAccountsESDT(shardID uint32, timestampMS uint64) error { if eim.RemoveAccountsESDTCalled != nil { - return eim.RemoveAccountsESDTCalled(headerTimestamp) + return eim.RemoveAccountsESDTCalled(shardID, timestampMS) } return nil @@ -55,7 +55,7 @@ func (eim *ElasticProcessorStub) RemoveMiniblocks(header coreData.HeaderHandler, } // RemoveTransactions - -func (eim *ElasticProcessorStub) RemoveTransactions(header coreData.HeaderHandler, body *block.Body) error { +func (eim *ElasticProcessorStub) RemoveTransactions(header coreData.HeaderHandler, body *block.Body, _ uint64) error { if eim.RemoveMiniblocksCalled != nil { return eim.RemoveTransactionsCalled(header, body) } @@ -63,9 +63,9 @@ func (eim *ElasticProcessorStub) RemoveTransactions(header coreData.HeaderHandle } // SaveMiniblocks - -func (eim *ElasticProcessorStub) SaveMiniblocks(header coreData.HeaderHandler, miniBlocks []*block.MiniBlock) error { +func (eim *ElasticProcessorStub) SaveMiniblocks(header coreData.HeaderHandler, miniBlocks []*block.MiniBlock, timestampMs uint64) error { if eim.SaveMiniblocksCalled != nil { - return eim.SaveMiniblocksCalled(header, miniBlocks) + return eim.SaveMiniblocksCalled(header, miniBlocks, timestampMs) } return nil } diff --git a/process/dataindexer/dataIndexer.go b/process/dataindexer/dataIndexer.go index 9f75e343..ca2460d8 100644 --- a/process/dataindexer/dataIndexer.go +++ b/process/dataindexer/dataIndexer.go @@ -115,7 +115,7 @@ func (di *dataIndexer) saveBlockData(outportBlock *outport.OutportBlock, header } miniBlocks := append(outportBlock.BlockData.Body.MiniBlocks, outportBlock.BlockData.IntraShardMiniBlocks...) - err = di.elasticProcessor.SaveMiniblocks(header, miniBlocks) + err = di.elasticProcessor.SaveMiniblocks(header, miniBlocks, outportBlock.BlockData.GetTimestampMs()) if err != nil { return fmt.Errorf("%w when saving miniblocks, block hash %s, nonce %d", err, hex.EncodeToString(headerHash), headerNonce) @@ -152,12 +152,12 @@ func (di *dataIndexer) RevertIndexedBlock(blockData *outport.BlockData) error { return err } - err = di.elasticProcessor.RemoveTransactions(header, blockData.Body) + err = di.elasticProcessor.RemoveTransactions(header, blockData.Body, blockData.TimestampMs) if err != nil { return err } - return di.elasticProcessor.RemoveAccountsESDT(header.GetTimeStamp(), header.GetShardID()) + return di.elasticProcessor.RemoveAccountsESDT(header.GetShardID(), blockData.TimestampMs) } // SaveRoundsInfo will save data about a slice of rounds in elasticsearch diff --git a/process/dataindexer/dataIndexer_test.go b/process/dataindexer/dataIndexer_test.go index 88970177..0a6404c2 100644 --- a/process/dataindexer/dataIndexer_test.go +++ b/process/dataindexer/dataIndexer_test.go @@ -62,7 +62,7 @@ func TestDataIndexer_SaveBlock(t *testing.T) { countMap[0]++ return nil }, - SaveMiniblocksCalled: func(header coreData.HeaderHandler, miniBlocks []*dataBlock.MiniBlock) error { + SaveMiniblocksCalled: func(header coreData.HeaderHandler, miniBlocks []*dataBlock.MiniBlock, timestampMs uint64) error { countMap[1]++ return nil }, @@ -167,7 +167,7 @@ func TestDataIndexer_RevertIndexedBlock(t *testing.T) { countMap[2]++ return nil }, - RemoveAccountsESDTCalled: func(headerTimestamp uint64) error { + RemoveAccountsESDTCalled: func(_ uint32, _ uint64) error { countMap[3]++ return nil }, diff --git a/process/dataindexer/errors.go b/process/dataindexer/errors.go index 9b4fbd0f..82a142fe 100644 --- a/process/dataindexer/errors.go +++ b/process/dataindexer/errors.go @@ -88,3 +88,6 @@ var ErrNilOperationsHandler = errors.New("nil operations handler") // ErrNilBlockContainerHandler signals that a nil block container handler has been provided var ErrNilBlockContainerHandler = errors.New("nil bock container handler") + +// ErrNilMappingsHandler signals that a nil mappings handler has been provided +var ErrNilMappingsHandler = errors.New("nil mappings handler") diff --git a/process/dataindexer/interface.go b/process/dataindexer/interface.go index cb99ab00..1583de6b 100644 --- a/process/dataindexer/interface.go +++ b/process/dataindexer/interface.go @@ -15,9 +15,9 @@ type ElasticProcessor interface { SaveHeader(outportBlockWithHeader *outport.OutportBlockWithHeader) error RemoveHeader(header coreData.HeaderHandler) error RemoveMiniblocks(header coreData.HeaderHandler, body *block.Body) error - RemoveTransactions(header coreData.HeaderHandler, body *block.Body) error - RemoveAccountsESDT(headerTimestamp uint64, shardID uint32) error - SaveMiniblocks(header coreData.HeaderHandler, miniBlocks []*block.MiniBlock) error + RemoveTransactions(header coreData.HeaderHandler, body *block.Body, uint65 uint64) error + RemoveAccountsESDT(shardID uint32, timestampMS uint64) error + SaveMiniblocks(header coreData.HeaderHandler, miniBlocks []*block.MiniBlock, timestampMS uint64) error SaveTransactions(outportBlockWithHeader *outport.OutportBlockWithHeader) error SaveValidatorsRating(ratingData *outport.ValidatorsRating) error SaveRoundsInfo(rounds *outport.RoundsInfo) error diff --git a/process/elasticproc/accounts/accountsProcessor.go b/process/elasticproc/accounts/accountsProcessor.go index 1c24bfea..11a92c5a 100644 --- a/process/elasticproc/accounts/accountsProcessor.go +++ b/process/elasticproc/accounts/accountsProcessor.go @@ -3,9 +3,6 @@ package accounts import ( "encoding/hex" "fmt" - "math/big" - "time" - "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-core-go/core/check" "github.com/multiversx/mx-chain-core-go/data/alteredAccount" @@ -13,6 +10,7 @@ import ( "github.com/multiversx/mx-chain-es-indexer-go/process/dataindexer" "github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/converters" logger "github.com/multiversx/mx-chain-logger-go" + "math/big" ) var log = logger.GetOrCreate("indexer/process/accounts") @@ -101,8 +99,9 @@ func notZeroBalance(balance string) bool { } // PrepareRegularAccountsMap will prepare a map of regular accounts -func (ap *accountsProcessor) PrepareRegularAccountsMap(timestamp uint64, accounts []*data.Account, shardID uint32) map[string]*data.AccountInfo { +func (ap *accountsProcessor) PrepareRegularAccountsMap(accounts []*data.Account, shardID uint32, timestampMs uint64) map[string]*data.AccountInfo { accountsMap := make(map[string]*data.AccountInfo) + timestampSeconds := converters.MillisecondsToSeconds(timestampMs) for _, userAccount := range accounts { address := userAccount.UserAccount.Address addressBytes, err := ap.addressPubkeyConverter.Decode(address) @@ -129,8 +128,9 @@ func (ap *accountsProcessor) PrepareRegularAccountsMap(timestamp uint64, account BalanceNum: balanceAsFloat, IsSender: userAccount.IsSender, IsSmartContract: core.IsSmartContractAddress(addressBytes), - Timestamp: time.Duration(timestamp), + Timestamp: timestampSeconds, ShardID: shardID, + TimestampMs: timestampMs, } ap.addAdditionalDataInAccount(userAccount.UserAccount.AdditionalData, acc) @@ -179,13 +179,14 @@ func (ap *accountsProcessor) addDeveloperRewardsInAccount(additionalData *altere // PrepareAccountsMapESDT will prepare a map of accounts with ESDT tokens func (ap *accountsProcessor) PrepareAccountsMapESDT( - timestamp uint64, accounts []*data.AccountESDT, tagsCount data.CountTags, shardID uint32, + timestampMs uint64, ) (map[string]*data.AccountInfo, data.TokensHandler) { tokensData := data.NewTokensInfo() accountsESDTMap := make(map[string]*data.AccountInfo) + timestampSeconds := converters.MillisecondsToSeconds(timestampMs) for _, accountESDT := range accounts { address := accountESDT.Account.Address addressBytes, err := ap.addressPubkeyConverter.Decode(address) @@ -224,8 +225,9 @@ func (ap *accountsProcessor) PrepareAccountsMapESDT( IsSender: accountESDT.IsSender, IsSmartContract: core.IsSmartContractAddress(addressBytes), Data: tokenMetaData, - Timestamp: time.Duration(timestamp), + Timestamp: timestampSeconds, ShardID: shardID, + TimestampMs: timestampMs, } if acc.TokenNonce == 0 { @@ -250,22 +252,24 @@ func (ap *accountsProcessor) PrepareAccountsMapESDT( // PrepareAccountsHistory will prepare a map of accounts history balance from a map of accounts func (ap *accountsProcessor) PrepareAccountsHistory( - timestamp uint64, accounts map[string]*data.AccountInfo, shardID uint32, + timestampMs uint64, ) map[string]*data.AccountBalanceHistory { + timestampSeconds := converters.MillisecondsToSeconds(timestampMs) accountsMap := make(map[string]*data.AccountBalanceHistory) for _, userAccount := range accounts { acc := &data.AccountBalanceHistory{ Address: userAccount.Address, Balance: userAccount.Balance, - Timestamp: time.Duration(timestamp), + Timestamp: timestampSeconds, Token: userAccount.TokenName, TokenNonce: userAccount.TokenNonce, IsSender: userAccount.IsSender, IsSmartContract: userAccount.IsSmartContract, Identifier: converters.ComputeTokenIdentifier(userAccount.TokenName, userAccount.TokenNonce), ShardID: shardID, + TimestampMs: timestampMs, } keyInMap := fmt.Sprintf("%s-%s-%d", acc.Address, acc.Token, acc.TokenNonce) accountsMap[keyInMap] = acc diff --git a/process/elasticproc/accounts/accountsProcessor_test.go b/process/elasticproc/accounts/accountsProcessor_test.go index b9c8b7bd..03a07dee 100644 --- a/process/elasticproc/accounts/accountsProcessor_test.go +++ b/process/elasticproc/accounts/accountsProcessor_test.go @@ -4,10 +4,6 @@ import ( "bytes" "encoding/hex" "errors" - "math/big" - "testing" - "time" - "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-core-go/data/alteredAccount" "github.com/multiversx/mx-chain-es-indexer-go/data" @@ -16,6 +12,8 @@ import ( "github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/converters" "github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/tags" "github.com/stretchr/testify/require" + "math/big" + "testing" ) var balanceConverter, _ = converters.NewBalanceConverter(10) @@ -74,7 +72,7 @@ func TestAccountsProcessor_PrepareRegularAccountsMapWithNil(t *testing.T) { ap, _ := NewAccountsProcessor(mock.NewPubkeyConverterMock(32), balanceConverter) - accountsInfo := ap.PrepareRegularAccountsMap(0, nil, 0) + accountsInfo := ap.PrepareRegularAccountsMap(nil, 0, 0) require.Len(t, accountsInfo, 0) } @@ -285,14 +283,15 @@ func TestAccountsProcessor_PrepareAccountsMapEGLD(t *testing.T) { balanceNum, _ := balanceConverter.ComputeBalanceAsFloat(big.NewInt(1000)) - res := ap.PrepareRegularAccountsMap(123, []*data.Account{egldAccount}, 0) + res := ap.PrepareRegularAccountsMap([]*data.Account{egldAccount}, 0, 123000) require.Equal(t, &data.AccountInfo{ Address: addr, Nonce: 1, Balance: "1000", BalanceNum: balanceNum, IsSmartContract: true, - Timestamp: time.Duration(123), + Timestamp: uint64(123), + TimestampMs: uint64(123000), CodeHash: []byte("code"), CodeMetadata: []byte("metadata"), RootHash: []byte("root"), @@ -337,7 +336,7 @@ func TestAccountsProcessor_PrepareAccountsMapESDT(t *testing.T) { } tagsCount := tags.NewTagsCount() - res, _ := ap.PrepareAccountsMapESDT(123, accountsESDT, tagsCount, 0) + res, _ := ap.PrepareAccountsMapESDT(accountsESDT, tagsCount, 0, 123000) require.Len(t, res, 2) balanceNum, _ := balanceConverter.ComputeBalanceAsFloat(big.NewInt(1000)) @@ -353,7 +352,8 @@ func TestAccountsProcessor_PrepareAccountsMapESDT(t *testing.T) { Creator: "creator", Attributes: make([]byte, 0), }, - Timestamp: time.Duration(123), + Timestamp: uint64(123), + TimestampMs: uint64(123000), }, res[hex.EncodeToString([]byte(addr))+"-token-15"]) require.Equal(t, &data.AccountInfo{ @@ -368,7 +368,8 @@ func TestAccountsProcessor_PrepareAccountsMapESDT(t *testing.T) { Creator: "creator", Attributes: make([]byte, 0), }, - Timestamp: time.Duration(123), + Timestamp: uint64(123), + TimestampMs: uint64(123000), }, res[hex.EncodeToString([]byte(addr))+"-token-16"]) } @@ -387,16 +388,17 @@ func TestAccountsProcessor_PrepareAccountsHistory(t *testing.T) { ap, _ := NewAccountsProcessor(mock.NewPubkeyConverterMock(32), balanceConverter) - res := ap.PrepareAccountsHistory(100, accounts, 0) + res := ap.PrepareAccountsHistory(accounts, 0, 100000) accountBalanceHistory := res["addr1-token-112-10"] require.Equal(t, &data.AccountBalanceHistory{ - Address: "addr1", - Timestamp: 100, - Balance: "112", - Token: "token-112", - IsSender: true, - TokenNonce: 10, - Identifier: "token-112-0a", + Address: "addr1", + Timestamp: 100, + TimestampMs: 100000, + Balance: "112", + Token: "token-112", + IsSender: true, + TokenNonce: 10, + Identifier: "token-112-0a", }, accountBalanceHistory) } diff --git a/process/elasticproc/block/blockProcessor.go b/process/elasticproc/block/blockProcessor.go index a1541029..d72570c5 100644 --- a/process/elasticproc/block/blockProcessor.go +++ b/process/elasticproc/block/blockProcessor.go @@ -4,13 +4,10 @@ import ( "encoding/hex" "errors" "fmt" - "github.com/multiversx/mx-chain-core-go/data/api" - "strconv" - "time" - "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-core-go/core/check" coreData "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/api" "github.com/multiversx/mx-chain-core-go/data/block" nodeBlock "github.com/multiversx/mx-chain-core-go/data/block" "github.com/multiversx/mx-chain-core-go/data/outport" @@ -20,6 +17,7 @@ import ( indexer "github.com/multiversx/mx-chain-es-indexer-go/process/dataindexer" "github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/converters" logger "github.com/multiversx/mx-chain-logger-go" + "strconv" ) const ( @@ -96,7 +94,8 @@ func (bp *blockProcessor) PrepareBlockForDB(obh *outport.OutportBlockWithHeader) PubKeyBitmap: hex.EncodeToString(obh.Header.GetPubKeysBitmap()), Size: int64(blockSizeInBytes), SizeTxs: int64(sizeTxs), - Timestamp: time.Duration(obh.Header.GetTimeStamp()), + Timestamp: obh.Header.GetTimeStamp(), + TimestampMs: obh.OutportBlock.BlockData.GetTimestampMs(), TxCount: numTxs, NotarizedTxsCount: notarizedTxs, StateRootHash: hex.EncodeToString(obh.Header.GetRootHash()), diff --git a/process/elasticproc/block/blockProcessor_test.go b/process/elasticproc/block/blockProcessor_test.go index a4ca8a81..acff1533 100644 --- a/process/elasticproc/block/blockProcessor_test.go +++ b/process/elasticproc/block/blockProcessor_test.go @@ -266,6 +266,7 @@ func TestBlockProcessor_PrepareBlockForDBEpochStartMeta(t *testing.T) { TxCount: 120, }, }, + TimeStamp: 123, } headerBytes, _ := bp.marshalizer.Marshal(header) @@ -273,6 +274,7 @@ func TestBlockProcessor_PrepareBlockForDBEpochStartMeta(t *testing.T) { Header: header, OutportBlock: &outport.OutportBlock{ BlockData: &outport.BlockData{ + TimestampMs: 123000, HeaderProof: &dataBlock.HeaderProof{ PubKeysBitmap: []byte("bitmap1"), AggregatedSignature: []byte("sig1"), @@ -311,9 +313,10 @@ func TestBlockProcessor_PrepareBlockForDBEpochStartMeta(t *testing.T) { Proposer: 0, Validators: nil, PubKeyBitmap: "6269746d617031", - Size: 898, + Size: 914, SizeTxs: 0, - Timestamp: 0, + Timestamp: 123, + TimestampMs: 123000, StateRootHash: "", PrevHash: "", ShardID: core.MetachainShardId, diff --git a/process/elasticproc/check.go b/process/elasticproc/check.go index 9284376e..b6670aae 100644 --- a/process/elasticproc/check.go +++ b/process/elasticproc/check.go @@ -39,6 +39,9 @@ func checkArguments(arguments *ArgElasticProcessor) error { if check.IfNilReflect(arguments.OperationsProc) { return elasticIndexer.ErrNilOperationsHandler } + if check.IfNilReflect(arguments.MappingsHandler) { + return elasticIndexer.ErrNilMappingsHandler + } return nil } diff --git a/process/elasticproc/converters/timestamp.go b/process/elasticproc/converters/timestamp.go new file mode 100644 index 00000000..79edbd7d --- /dev/null +++ b/process/elasticproc/converters/timestamp.go @@ -0,0 +1,6 @@ +package converters + +// MillisecondsToSeconds will convert the provided milliseconds in seconds +func MillisecondsToSeconds(ms uint64) uint64 { + return ms / 1000 +} diff --git a/process/elasticproc/converters/timestamp_test.go b/process/elasticproc/converters/timestamp_test.go new file mode 100644 index 00000000..03054785 --- /dev/null +++ b/process/elasticproc/converters/timestamp_test.go @@ -0,0 +1,15 @@ +package converters + +import ( + "github.com/stretchr/testify/require" + "testing" +) + +func TestMillisecondsToSeconds(t *testing.T) { + t.Parallel() + + require.Equal(t, uint64(1), MillisecondsToSeconds(1000)) + require.Equal(t, uint64(0), MillisecondsToSeconds(0)) + require.Equal(t, uint64(12), MillisecondsToSeconds(12_000)) + require.Equal(t, uint64(12), MillisecondsToSeconds(12_123)) +} diff --git a/process/elasticproc/elasticProcessor.go b/process/elasticproc/elasticProcessor.go index dc94c30c..99bd4394 100644 --- a/process/elasticproc/elasticProcessor.go +++ b/process/elasticproc/elasticProcessor.go @@ -6,8 +6,6 @@ import ( "encoding/hex" "encoding/json" "fmt" - "sync" - "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-core-go/core/check" coreData "github.com/multiversx/mx-chain-core-go/data" @@ -22,6 +20,7 @@ import ( "github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/tokeninfo" "github.com/multiversx/mx-chain-es-indexer-go/templates" logger "github.com/multiversx/mx-chain-logger-go" + "sync" ) var ( @@ -43,9 +42,6 @@ type ArgElasticProcessor struct { BulkRequestMaxSize int UseKibana bool ImportDB bool - IndexTemplates map[string]*bytes.Buffer - IndexPolicies map[string]*bytes.Buffer - ExtraMappings []templates.ExtraMapping EnabledIndexes map[string]struct{} TransactionsProc DBTransactionsHandler AccountsProc DBAccountHandler @@ -56,6 +52,7 @@ type ArgElasticProcessor struct { DBClient DatabaseClientHandler LogsAndEventsProc DBLogsAndEventsHandler OperationsProc OperationsHandler + MappingsHandler TemplatesAndPoliciesHandler Version string } @@ -73,6 +70,7 @@ type elasticProcessor struct { validatorsProc DBValidatorsHandler logsAndEventsProc DBLogsAndEventsHandler operationsProc OperationsHandler + mappingsHandler TemplatesAndPoliciesHandler } // NewElasticProcessor handles Elasticsearch operations such as initialization, adding, modifying or removing data @@ -94,9 +92,10 @@ func NewElasticProcessor(arguments *ArgElasticProcessor) (*elasticProcessor, err logsAndEventsProc: arguments.LogsAndEventsProc, operationsProc: arguments.OperationsProc, bulkRequestMaxSize: arguments.BulkRequestMaxSize, + mappingsHandler: arguments.MappingsHandler, } - err = ei.init(arguments.IndexTemplates, arguments.IndexPolicies, arguments.ExtraMappings) + err = ei.init() if err != nil { return nil, err } @@ -107,8 +106,13 @@ func NewElasticProcessor(arguments *ArgElasticProcessor) (*elasticProcessor, err } // TODO move all the index create part in a new component -func (ei *elasticProcessor) init(indexTemplates, _ map[string]*bytes.Buffer, extraMappings []templates.ExtraMapping) error { - err := ei.createOpenDistroTemplates(indexTemplates) +func (ei *elasticProcessor) init() error { + indexTemplates, _, err := ei.mappingsHandler.GetElasticTemplatesAndPolicies() + if err != nil { + return err + } + + err = ei.createOpenDistroTemplates(indexTemplates) if err != nil { return err } @@ -128,6 +132,11 @@ func (ei *elasticProcessor) init(indexTemplates, _ map[string]*bytes.Buffer, ext return err } + extraMappings, err := ei.mappingsHandler.GetTimestampMsMappings() + if err != nil { + return err + } + return ei.addExtraMappings(extraMappings) } @@ -308,7 +317,7 @@ func (ei *elasticProcessor) RemoveMiniblocks(header coreData.HeaderHandler, body } // RemoveTransactions will remove transaction that are in miniblock from the elasticsearch server -func (ei *elasticProcessor) RemoveTransactions(header coreData.HeaderHandler, body *block.Body) error { +func (ei *elasticProcessor) RemoveTransactions(header coreData.HeaderHandler, body *block.Body, timestampMs uint64) error { encodedTxsHashes, encodedScrsHashes := ei.transactionsProc.GetHexEncodedHashesForRemove(header, body) shardID := header.GetShardID() @@ -332,15 +341,15 @@ func (ei *elasticProcessor) RemoveTransactions(header coreData.HeaderHandler, bo return err } - err = ei.removeFromIndexByTimestampAndShardID(header.GetTimeStamp(), header.GetShardID(), elasticIndexer.EventsIndex) + err = ei.removeFromIndexByTimestampAndShardID(header.GetShardID(), elasticIndexer.EventsIndex, timestampMs) if err != nil { return err } - return ei.updateDelegatorsInCaseOfRevert(header, body) + return ei.updateDelegatorsInCaseOfRevert(header, body, timestampMs) } -func (ei *elasticProcessor) updateDelegatorsInCaseOfRevert(header coreData.HeaderHandler, body *block.Body) error { +func (ei *elasticProcessor) updateDelegatorsInCaseOfRevert(header coreData.HeaderHandler, body *block.Body, timestampMs uint64) error { // delegators index should be updated in case of revert only if the observer is in Metachain and the reverted block has miniblocks isMeta := header.GetShardID() == core.MetachainShardId hasMiniblocks := len(body.MiniBlocks) > 0 @@ -350,7 +359,8 @@ func (ei *elasticProcessor) updateDelegatorsInCaseOfRevert(header coreData.Heade } ctxWithValue := context.WithValue(context.Background(), request.ContextKey, request.ExtendTopicWithShardID(request.UpdateTopic, header.GetShardID())) - delegatorsQuery := ei.logsAndEventsProc.PrepareDelegatorsQueryInCaseOfRevert(header.GetTimeStamp()) + + delegatorsQuery := ei.logsAndEventsProc.PrepareDelegatorsQueryInCaseOfRevert(timestampMs) return ei.elasticClient.UpdateByQuery(ctxWithValue, elasticIndexer.DelegatorsIndex, delegatorsQuery) } @@ -368,18 +378,18 @@ func (ei *elasticProcessor) removeIfHashesNotEmpty(index string, hashes []string } // RemoveAccountsESDT will remove data from accountsesdt index and accountsesdthistory -func (ei *elasticProcessor) RemoveAccountsESDT(headerTimestamp uint64, shardID uint32) error { - err := ei.removeFromIndexByTimestampAndShardID(headerTimestamp, shardID, elasticIndexer.AccountsESDTIndex) +func (ei *elasticProcessor) RemoveAccountsESDT(shardID uint32, timestampMs uint64) error { + err := ei.removeFromIndexByTimestampAndShardID(shardID, elasticIndexer.AccountsESDTIndex, timestampMs) if err != nil { return err } - return ei.removeFromIndexByTimestampAndShardID(headerTimestamp, shardID, elasticIndexer.AccountsESDTHistoryIndex) + return ei.removeFromIndexByTimestampAndShardID(shardID, elasticIndexer.AccountsESDTHistoryIndex, timestampMs) } -func (ei *elasticProcessor) removeFromIndexByTimestampAndShardID(headerTimestamp uint64, shardID uint32, index string) error { +func (ei *elasticProcessor) removeFromIndexByTimestampAndShardID(shardID uint32, index string, timestampMs uint64) error { ctxWithValue := context.WithValue(context.Background(), request.ContextKey, request.ExtendTopicWithShardID(request.RemoveTopic, shardID)) - query := fmt.Sprintf(`{"query": {"bool": {"must": [{"match": {"shardID": {"query": %d,"operator": "AND"}}},{"match": {"timestamp": {"query": "%d","operator": "AND"}}}]}}}`, shardID, headerTimestamp) + query := fmt.Sprintf(`{"query": {"bool": {"must": [{"match": {"shardID": {"query": %d,"operator": "AND"}}},{"match": {"timestampMs": {"query": "%d","operator": "AND"}}}]}}}`, shardID, timestampMs) return ei.elasticClient.DoQueryRemove( ctxWithValue, @@ -389,12 +399,12 @@ func (ei *elasticProcessor) removeFromIndexByTimestampAndShardID(headerTimestamp } // SaveMiniblocks will prepare and save information about miniblocks in elasticsearch server -func (ei *elasticProcessor) SaveMiniblocks(header coreData.HeaderHandler, miniBlocks []*block.MiniBlock) error { +func (ei *elasticProcessor) SaveMiniblocks(header coreData.HeaderHandler, miniBlocks []*block.MiniBlock, timestampMS uint64) error { if !ei.isIndexEnabled(elasticIndexer.MiniblocksIndex) { return nil } - mbs := ei.miniblocksProc.PrepareDBMiniblocks(header, miniBlocks) + mbs := ei.miniblocksProc.PrepareDBMiniblocks(header, miniBlocks, timestampMS) if len(mbs) == 0 { return nil } @@ -410,8 +420,8 @@ func (ei *elasticProcessor) SaveTransactions(obh *outport.OutportBlockWithHeader headerTimestamp := obh.Header.GetTimeStamp() miniBlocks := append(obh.BlockData.Body.MiniBlocks, obh.BlockData.IntraShardMiniBlocks...) - preparedResults := ei.transactionsProc.PrepareTransactionsForDatabase(miniBlocks, obh.Header, obh.TransactionPool, ei.isImportDB(), obh.NumberOfShards) - logsData := ei.logsAndEventsProc.ExtractDataFromLogs(obh.TransactionPool.Logs, preparedResults, headerTimestamp, obh.Header.GetShardID(), obh.NumberOfShards) + preparedResults := ei.transactionsProc.PrepareTransactionsForDatabase(miniBlocks, obh.Header, obh.TransactionPool, ei.isImportDB(), obh.NumberOfShards, obh.BlockData.TimestampMs) + logsData := ei.logsAndEventsProc.ExtractDataFromLogs(obh.TransactionPool.Logs, preparedResults, headerTimestamp, obh.Header.GetShardID(), obh.NumberOfShards, obh.BlockData.TimestampMs) buffers := data.NewBufferSlice(ei.bulkRequestMaxSize) err := ei.indexTransactions(preparedResults.Transactions, logsData.TxHashStatusInfo, obh.Header, buffers) @@ -455,7 +465,7 @@ func (ei *elasticProcessor) SaveTransactions(obh *outport.OutportBlockWithHeader } tagsCount := tags.NewTagsCount() - err = ei.indexAlteredAccounts(headerTimestamp, logsData.NFTsDataUpdates, obh.AlteredAccounts, buffers, tagsCount, obh.Header.GetShardID()) + err = ei.indexAlteredAccounts(logsData.NFTsDataUpdates, obh.AlteredAccounts, buffers, tagsCount, obh.Header.GetShardID(), obh.BlockData.TimestampMs) if err != nil { return err } @@ -626,32 +636,32 @@ func (ei *elasticProcessor) SaveRoundsInfo(rounds *outport.RoundsInfo) error { } func (ei *elasticProcessor) indexAlteredAccounts( - timestamp uint64, updatesNFTsData []*data.NFTDataUpdate, coreAlteredAccounts map[string]*alteredAccount.AlteredAccount, buffSlice *data.BufferSlice, tagsCount data.CountTags, shardID uint32, + timestampMs uint64, ) error { regularAccountsToIndex, accountsToIndexESDT := ei.accountsProc.GetAccounts(coreAlteredAccounts) - err := ei.saveAccounts(timestamp, regularAccountsToIndex, buffSlice, shardID) + err := ei.saveAccounts(regularAccountsToIndex, buffSlice, shardID, timestampMs) if err != nil { return err } - return ei.saveAccountsESDT(timestamp, accountsToIndexESDT, updatesNFTsData, buffSlice, tagsCount, shardID) + return ei.saveAccountsESDT(accountsToIndexESDT, updatesNFTsData, buffSlice, tagsCount, shardID, timestampMs) } func (ei *elasticProcessor) saveAccountsESDT( - timestamp uint64, wrappedAccounts []*data.AccountESDT, updatesNFTsData []*data.NFTDataUpdate, buffSlice *data.BufferSlice, tagsCount data.CountTags, shardID uint32, + timestampMs uint64, ) error { - accountsESDTMap, tokensData := ei.accountsProc.PrepareAccountsMapESDT(timestamp, wrappedAccounts, tagsCount, shardID) + accountsESDTMap, tokensData := ei.accountsProc.PrepareAccountsMapESDT(wrappedAccounts, tagsCount, shardID, timestampMs) err := ei.addTokenTypeAndCurrentOwnerInAccountsESDT(tokensData, accountsESDTMap, shardID) if err != nil { return err @@ -662,7 +672,7 @@ func (ei *elasticProcessor) saveAccountsESDT( return err } - return ei.saveAccountsESDTHistory(timestamp, accountsESDTMap, buffSlice, shardID) + return ei.saveAccountsESDTHistory(accountsESDTMap, buffSlice, shardID, timestampMs) } func (ei *elasticProcessor) addTokenTypeAndCurrentOwnerInAccountsESDT(tokensData data.TokensHandler, accountsESDTMap map[string]*data.AccountInfo, shardID uint32) error { @@ -755,17 +765,17 @@ func (ei *elasticProcessor) SaveAccounts(accountsData *outport.Accounts) error { }) } - return ei.saveAccounts(accountsData.BlockTimestamp, accounts, buffSlice, accountsData.ShardID) + return ei.saveAccounts(accounts, buffSlice, accountsData.ShardID, accountsData.BlockTimestampMs) } -func (ei *elasticProcessor) saveAccounts(timestamp uint64, accts []*data.Account, buffSlice *data.BufferSlice, shardID uint32) error { - accountsMap := ei.accountsProc.PrepareRegularAccountsMap(timestamp, accts, shardID) +func (ei *elasticProcessor) saveAccounts(accts []*data.Account, buffSlice *data.BufferSlice, shardID uint32, timestampMs uint64) error { + accountsMap := ei.accountsProc.PrepareRegularAccountsMap(accts, shardID, timestampMs) err := ei.indexAccounts(accountsMap, elasticIndexer.AccountsIndex, buffSlice) if err != nil { return err } - return ei.saveAccountsHistory(timestamp, accountsMap, buffSlice, shardID) + return ei.saveAccountsHistory(accountsMap, buffSlice, shardID, timestampMs) } func (ei *elasticProcessor) indexAccounts(accountsMap map[string]*data.AccountInfo, index string, buffSlice *data.BufferSlice) error { @@ -780,22 +790,22 @@ func (ei *elasticProcessor) serializeAndIndexAccounts(accountsMap map[string]*da return ei.accountsProc.SerializeAccounts(accountsMap, buffSlice, index) } -func (ei *elasticProcessor) saveAccountsESDTHistory(timestamp uint64, accountsInfoMap map[string]*data.AccountInfo, buffSlice *data.BufferSlice, shardID uint32) error { +func (ei *elasticProcessor) saveAccountsESDTHistory(accountsInfoMap map[string]*data.AccountInfo, buffSlice *data.BufferSlice, shardID uint32, timestampMs uint64) error { if !ei.isIndexEnabled(elasticIndexer.AccountsESDTHistoryIndex) { return nil } - accountsMap := ei.accountsProc.PrepareAccountsHistory(timestamp, accountsInfoMap, shardID) + accountsMap := ei.accountsProc.PrepareAccountsHistory(accountsInfoMap, shardID, timestampMs) return ei.serializeAndIndexAccountsHistory(accountsMap, elasticIndexer.AccountsESDTHistoryIndex, buffSlice) } -func (ei *elasticProcessor) saveAccountsHistory(timestamp uint64, accountsInfoMap map[string]*data.AccountInfo, buffSlice *data.BufferSlice, shardID uint32) error { +func (ei *elasticProcessor) saveAccountsHistory(accountsInfoMap map[string]*data.AccountInfo, buffSlice *data.BufferSlice, shardID uint32, timestampMS uint64) error { if !ei.isIndexEnabled(elasticIndexer.AccountsHistoryIndex) { return nil } - accountsMap := ei.accountsProc.PrepareAccountsHistory(timestamp, accountsInfoMap, shardID) + accountsMap := ei.accountsProc.PrepareAccountsHistory(accountsInfoMap, shardID, timestampMS) return ei.serializeAndIndexAccountsHistory(accountsMap, elasticIndexer.AccountsHistoryIndex, buffSlice) } diff --git a/process/elasticproc/elasticProcessor_test.go b/process/elasticproc/elasticProcessor_test.go index ac9123b9..e045e129 100644 --- a/process/elasticproc/elasticProcessor_test.go +++ b/process/elasticproc/elasticProcessor_test.go @@ -23,6 +23,7 @@ import ( "github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/operations" "github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/statistics" "github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/tags" + "github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/templatesAndPolicies" "github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/transactions" "github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/validators" "github.com/stretchr/testify/require" @@ -87,6 +88,7 @@ func createMockElasticProcessorArgs() *ArgElasticProcessor { BlockProc: bp, LogsAndEventsProc: lp, OperationsProc: op, + MappingsHandler: templatesAndPolicies.NewTemplatesAndPolicyReader(), } } @@ -200,6 +202,15 @@ func TestNewElasticProcessor(t *testing.T) { }, exErr: dataindexer.ErrNilTransactionsHandler, }, + { + name: "NilMappingsHandler", + args: func() *ArgElasticProcessor { + arguments := createMockElasticProcessorArgs() + arguments.MappingsHandler = nil + return arguments + }, + exErr: dataindexer.ErrNilMappingsHandler, + }, { name: "InitError", args: func() *ArgElasticProcessor { @@ -411,7 +422,7 @@ func TestElasticProcessor_SaveMiniblocks(t *testing.T) { body := &dataBlock.Body{MiniBlocks: dataBlock.MiniBlockSlice{ {SenderShardID: 0, ReceiverShardID: 1}, }} - err := elasticProc.SaveMiniblocks(header, body.MiniBlocks) + err := elasticProc.SaveMiniblocks(header, body.MiniBlocks, 0) require.Equal(t, localErr, err) } @@ -470,7 +481,7 @@ func TestElasticProcessor_RemoveTransactions(t *testing.T) { called = true } else { require.Equal(t, - `{"query": {"bool": {"must": [{"match": {"shardID": {"query": 4294967295,"operator": "AND"}}},{"match": {"timestamp": {"query": "0","operator": "AND"}}}]}}}`, + `{"query": {"bool": {"must": [{"match": {"shardID": {"query": 4294967295,"operator": "AND"}}},{"match": {"timestampMs": {"query": "0","operator": "AND"}}}]}}}`, body.String(), ) } @@ -505,7 +516,7 @@ func TestElasticProcessor_RemoveTransactions(t *testing.T) { }, } - err := elasticSearchProc.RemoveTransactions(header, blk) + err := elasticSearchProc.RemoveTransactions(header, blk, 0) require.Nil(t, err) require.True(t, called) } @@ -588,7 +599,7 @@ func TestElasticProcessor_IndexAlteredAccounts(t *testing.T) { buffSlice := data.NewBufferSlice(data.DefaultMaxBulkSize) tagsCount := tags.NewTagsCount() - err := elasticSearchProc.indexAlteredAccounts(100, nil, nil, buffSlice, tagsCount, 0) + err := elasticSearchProc.indexAlteredAccounts(nil, nil, buffSlice, tagsCount, 0, 0) require.Nil(t, err) require.True(t, called) } diff --git a/process/elasticproc/factory/elasticProcessorFactory.go b/process/elasticproc/factory/elasticProcessorFactory.go index 92624338..47481245 100644 --- a/process/elasticproc/factory/elasticProcessorFactory.go +++ b/process/elasticproc/factory/elasticProcessorFactory.go @@ -36,14 +36,6 @@ type ArgElasticProcessorFactory struct { // CreateElasticProcessor will create a new instance of ElasticProcessor func CreateElasticProcessor(arguments ArgElasticProcessorFactory) (dataindexer.ElasticProcessor, error) { templatesAndPoliciesReader := templatesAndPolicies.NewTemplatesAndPolicyReader() - indexTemplates, indexPolicies, err := templatesAndPoliciesReader.GetElasticTemplatesAndPolicies() - if err != nil { - return nil, err - } - extraMappings, err := templatesAndPoliciesReader.GetExtraMappings() - if err != nil { - return nil, err - } enabledIndexesMap := make(map[string]struct{}) for _, index := range arguments.EnabledIndexes { @@ -121,12 +113,10 @@ func CreateElasticProcessor(arguments ArgElasticProcessorFactory) (dataindexer.E DBClient: arguments.DBClient, EnabledIndexes: enabledIndexesMap, UseKibana: arguments.UseKibana, - IndexTemplates: indexTemplates, - IndexPolicies: indexPolicies, - ExtraMappings: extraMappings, OperationsProc: operationsProc, ImportDB: arguments.ImportDB, Version: arguments.Version, + MappingsHandler: templatesAndPoliciesReader, } return elasticproc.NewElasticProcessor(args) diff --git a/process/elasticproc/interface.go b/process/elasticproc/interface.go index fe4b565f..4caa6af8 100644 --- a/process/elasticproc/interface.go +++ b/process/elasticproc/interface.go @@ -10,6 +10,7 @@ import ( "github.com/multiversx/mx-chain-core-go/data/outport" "github.com/multiversx/mx-chain-es-indexer-go/data" "github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/tokeninfo" + "github.com/multiversx/mx-chain-es-indexer-go/templates" ) // DatabaseClientHandler defines the actions that a component that handles requests should do @@ -33,9 +34,9 @@ type DatabaseClientHandler interface { // DBAccountHandler defines the actions that an accounts' handler should do type DBAccountHandler interface { GetAccounts(coreAlteredAccounts map[string]*alteredAccount.AlteredAccount) ([]*data.Account, []*data.AccountESDT) - PrepareRegularAccountsMap(timestamp uint64, accounts []*data.Account, shardID uint32) map[string]*data.AccountInfo - PrepareAccountsMapESDT(timestamp uint64, accounts []*data.AccountESDT, tagsCount data.CountTags, shardID uint32) (map[string]*data.AccountInfo, data.TokensHandler) - PrepareAccountsHistory(timestamp uint64, accounts map[string]*data.AccountInfo, shardID uint32) map[string]*data.AccountBalanceHistory + PrepareRegularAccountsMap(accounts []*data.Account, shardID uint32, timestampMs uint64) map[string]*data.AccountInfo + PrepareAccountsMapESDT(accounts []*data.AccountESDT, tagsCount data.CountTags, shardID uint32, timestampMs uint64) (map[string]*data.AccountInfo, data.TokensHandler) + PrepareAccountsHistory(accounts map[string]*data.AccountInfo, shardID uint32, timestampMs uint64) map[string]*data.AccountBalanceHistory PutTokenMedataDataInTokens(tokensData []*data.TokenInfo, coreAlteredAccounts map[string]*alteredAccount.AlteredAccount) SerializeAccountsHistory(accounts map[string]*data.AccountBalanceHistory, buffSlice *data.BufferSlice, index string) error @@ -62,6 +63,7 @@ type DBTransactionsHandler interface { pool *outport.TransactionPool, isImportDB bool, numOfShards uint32, + timestampMS uint64, ) *data.PreparedResults GetHexEncodedHashesForRemove(header coreData.HeaderHandler, body *block.Body) ([]string, []string) @@ -73,7 +75,7 @@ type DBTransactionsHandler interface { // DBMiniblocksHandler defines the actions that a miniblocks handler should do type DBMiniblocksHandler interface { - PrepareDBMiniblocks(header coreData.HeaderHandler, miniBlocks []*block.MiniBlock) []*data.Miniblock + PrepareDBMiniblocks(header coreData.HeaderHandler, miniBlocks []*block.MiniBlock, timestampMS uint64) []*data.Miniblock GetMiniblocksHashesHexEncoded(header coreData.HeaderHandler, body *block.Body) []string SerializeBulkMiniBlocks(bulkMbs []*data.Miniblock, buffSlice *data.BufferSlice, index string, shardID uint32) @@ -98,6 +100,7 @@ type DBLogsAndEventsHandler interface { timestamp uint64, shardID uint32, numOfShards uint32, + timestampMs uint64, ) *data.PreparedLogsResults SerializeEvents(events []*data.LogEvent, buffSlice *data.BufferSlice, index string) error @@ -112,7 +115,7 @@ type DBLogsAndEventsHandler interface { buffSlice *data.BufferSlice, index string, ) error - PrepareDelegatorsQueryInCaseOfRevert(timestamp uint64) *bytes.Buffer + PrepareDelegatorsQueryInCaseOfRevert(timestampMs uint64) *bytes.Buffer } // OperationsHandler defines the actions that an operations' handler should do @@ -120,3 +123,10 @@ type OperationsHandler interface { ProcessTransactionsAndSCRs(txs []*data.Transaction, scrs []*data.ScResult, isImportDB bool, shardID uint32) ([]*data.Transaction, []*data.ScResult) SerializeSCRs(scrs []*data.ScResult, buffSlice *data.BufferSlice, index string, shardID uint32) error } + +// TemplatesAndPoliciesHandler defines the actions that a templates and policies handler should do +type TemplatesAndPoliciesHandler interface { + GetElasticTemplatesAndPolicies() (map[string]*bytes.Buffer, map[string]*bytes.Buffer, error) + GetExtraMappings() ([]templates.ExtraMapping, error) + GetTimestampMsMappings() ([]templates.ExtraMapping, error) +} diff --git a/process/elasticproc/logsevents/delegatorsProcessor.go b/process/elasticproc/logsevents/delegatorsProcessor.go index 1cf6c6e7..d4d171e7 100644 --- a/process/elasticproc/logsevents/delegatorsProcessor.go +++ b/process/elasticproc/logsevents/delegatorsProcessor.go @@ -2,13 +2,11 @@ package logsevents import ( "encoding/hex" - "math/big" - "strconv" - "time" - "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-es-indexer-go/data" indexer "github.com/multiversx/mx-chain-es-indexer-go/process/dataindexer" + "math/big" + "strconv" ) const ( @@ -101,7 +99,8 @@ func (dp *delegatorsProc) processEvent(args *argsProcessEvent) argOutputProcessE Contract: contractAddr, ActiveStake: activeStake.String(), ActiveStakeNum: activeStakeNum, - Timestamp: time.Duration(args.timestamp), + Timestamp: args.timestamp, + TimestampMs: args.timestampMs, } if eventIdentifierStr == withdrawFunc && len(topics) >= minNumTopicsDelegators+1 { @@ -121,10 +120,11 @@ func (dp *delegatorsProc) processEvent(args *argsProcessEvent) argOutputProcessE } delegator.UnDelegateInfo = &data.UnDelegate{ - Timestamp: time.Duration(args.timestamp), - Value: unDelegateValue.String(), - ValueNum: unDelegatedValueNum, - ID: hex.EncodeToString(topics[4]), + Timestamp: args.timestamp, + TimestampMs: args.timestampMs, + Value: unDelegateValue.String(), + ValueNum: unDelegatedValueNum, + ID: hex.EncodeToString(topics[4]), } } diff --git a/process/elasticproc/logsevents/delegatorsProcessor_test.go b/process/elasticproc/logsevents/delegatorsProcessor_test.go index 8d8a5471..16dde022 100644 --- a/process/elasticproc/logsevents/delegatorsProcessor_test.go +++ b/process/elasticproc/logsevents/delegatorsProcessor_test.go @@ -24,6 +24,7 @@ func TestDelegatorsProcessor_ProcessEvent(t *testing.T) { } args := &argsProcessEvent{ timestamp: 1234, + timestampMs: 1234000, event: event, logAddress: []byte("contract"), selfShardID: core.MetachainShardId, @@ -40,6 +41,7 @@ func TestDelegatorsProcessor_ProcessEvent(t *testing.T) { ActiveStakeNum: 0.1, ActiveStake: "1000000000", Timestamp: 1234, + TimestampMs: 1234000, }, res.delegator) } @@ -53,6 +55,7 @@ func TestDelegatorProcessor_WithdrawWithDelete(t *testing.T) { } args := &argsProcessEvent{ timestamp: 1234, + timestampMs: 1234000, event: event, logAddress: []byte("contract"), selfShardID: core.MetachainShardId, @@ -70,6 +73,7 @@ func TestDelegatorProcessor_WithdrawWithDelete(t *testing.T) { ActiveStake: "0", ShouldDelete: true, Timestamp: 1234, + TimestampMs: 1234000, WithdrawFundIDs: []string{"61"}, }, res.delegator) } diff --git a/process/elasticproc/logsevents/esdtIssueProcessor.go b/process/elasticproc/logsevents/esdtIssueProcessor.go index 6f5c9fa3..e221ad27 100644 --- a/process/elasticproc/logsevents/esdtIssueProcessor.go +++ b/process/elasticproc/logsevents/esdtIssueProcessor.go @@ -1,11 +1,9 @@ package logsevents import ( - "math/big" - "time" - "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-es-indexer-go/data" + "math/big" ) const ( @@ -91,11 +89,13 @@ func (eip *esdtIssueProcessor) processEvent(args *argsProcessEvent) argOutputPro NumDecimals: numDecimals, Issuer: encodedAddr, CurrentOwner: encodedAddr, - Timestamp: time.Duration(args.timestamp), + Timestamp: args.timestamp, + TimestampMs: args.timestampMs, OwnersHistory: []*data.OwnerData{ { - Address: encodedAddr, - Timestamp: time.Duration(args.timestamp), + Address: encodedAddr, + Timestamp: args.timestamp, + TimestampMs: args.timestampMs, }, }, Properties: &data.TokenProperties{}, diff --git a/process/elasticproc/logsevents/esdtIssueProcessor_test.go b/process/elasticproc/logsevents/esdtIssueProcessor_test.go index f62d2ab3..214a295a 100644 --- a/process/elasticproc/logsevents/esdtIssueProcessor_test.go +++ b/process/elasticproc/logsevents/esdtIssueProcessor_test.go @@ -1,14 +1,12 @@ package logsevents import ( - "testing" - "time" - "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-core-go/data/transaction" "github.com/multiversx/mx-chain-es-indexer-go/data" "github.com/multiversx/mx-chain-es-indexer-go/mock" "github.com/stretchr/testify/require" + "testing" ) func TestIssueESDTProcessor(t *testing.T) { @@ -25,6 +23,7 @@ func TestIssueESDTProcessor(t *testing.T) { timestamp: 1234, event: event, selfShardID: core.MetachainShardId, + timestampMs: 1234000, } res := esdtIssueProc.processEvent(args) @@ -33,14 +32,16 @@ func TestIssueESDTProcessor(t *testing.T) { Token: "MYTOKEN-abcd", Name: "my-token", Ticker: "MYTOKEN", - Timestamp: time.Duration(1234), + Timestamp: 1234, + TimestampMs: 1234000, Type: core.NonFungibleESDT, Issuer: "61646472", CurrentOwner: "61646472", OwnersHistory: []*data.OwnerData{ { - Address: "61646472", - Timestamp: time.Duration(1234), + Address: "61646472", + Timestamp: 1234, + TimestampMs: 1234000, }, }, Properties: &data.TokenProperties{}, @@ -59,6 +60,7 @@ func TestIssueESDTProcessor_TransferOwnership(t *testing.T) { } args := &argsProcessEvent{ timestamp: 1234, + timestampMs: 1234000, event: event, selfShardID: core.MetachainShardId, } @@ -69,14 +71,16 @@ func TestIssueESDTProcessor_TransferOwnership(t *testing.T) { Token: "MYTOKEN-abcd", Name: "my-token", Ticker: "MYTOKEN", - Timestamp: time.Duration(1234), + Timestamp: 1234, + TimestampMs: 1234000, Type: core.NonFungibleESDT, Issuer: "61646472", CurrentOwner: "6e65774f776e6572", OwnersHistory: []*data.OwnerData{ { - Address: "6e65774f776e6572", - Timestamp: time.Duration(1234), + Address: "6e65774f776e6572", + Timestamp: 1234, + TimestampMs: 1234000, }, }, TransferOwnership: true, @@ -96,6 +100,7 @@ func TestIssueESDTProcessor_EventWithShardID0ShouldBeIgnored(t *testing.T) { } args := &argsProcessEvent{ timestamp: 1234, + timestampMs: 1234000, event: event, selfShardID: 0, } diff --git a/process/elasticproc/logsevents/interface.go b/process/elasticproc/logsevents/interface.go index 4d434cef..ff845ef9 100644 --- a/process/elasticproc/logsevents/interface.go +++ b/process/elasticproc/logsevents/interface.go @@ -19,6 +19,7 @@ type argsProcessEvent struct { tokenRolesAndProperties *tokeninfo.TokenRolesAndProperties txHashStatusInfoProc txHashStatusInfoHandler timestamp uint64 + timestampMs uint64 logAddress []byte selfShardID uint32 numOfShards uint32 diff --git a/process/elasticproc/logsevents/logsAndEventsProcessor.go b/process/elasticproc/logsevents/logsAndEventsProcessor.go index 39d8085a..5b4ffa88 100644 --- a/process/elasticproc/logsevents/logsAndEventsProcessor.go +++ b/process/elasticproc/logsevents/logsAndEventsProcessor.go @@ -3,8 +3,6 @@ package logsevents import ( "encoding/hex" "fmt" - "time" - "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-core-go/core/check" coreData "github.com/multiversx/mx-chain-core-go/data" @@ -95,8 +93,9 @@ func (lep *logsAndEventsProcessor) ExtractDataFromLogs( timestamp uint64, shardID uint32, numOfShards uint32, + timestampMs uint64, ) *data.PreparedLogsResults { - lgData := newLogsData(timestamp, preparedResults.Transactions, preparedResults.ScResults) + lgData := newLogsData(timestamp, preparedResults.Transactions, preparedResults.ScResults, timestampMs) for _, txLog := range logsAndEvents { if txLog == nil { continue @@ -117,7 +116,7 @@ func (lep *logsAndEventsProcessor) ExtractDataFromLogs( } } - dbLogs, dbEvents := lep.prepareLogsForDB(lgData, logsAndEvents, timestamp, shardID) + dbLogs, dbEvents := lep.prepareLogsForDB(lgData, logsAndEvents, timestamp, shardID, timestampMs) return &data.PreparedLogsResults{ Tokens: lgData.tokens, @@ -153,6 +152,7 @@ func (lep *logsAndEventsProcessor) processEvent(lgData *logsData, logHashHexEnco tokens: lgData.tokens, tokensSupply: lgData.tokensSupply, timestamp: lgData.timestamp, + timestampMs: lgData.timestampMs, scDeploys: lgData.scDeploys, txs: lgData.txsMap, scrs: lgData.scrsMap, @@ -194,6 +194,7 @@ func (lep *logsAndEventsProcessor) prepareLogsForDB( logsAndEvents []*outport.LogData, timestamp uint64, shardID uint32, + timestampMs uint64, ) ([]*data.Logs, []*data.LogEvent) { logs := make([]*data.Logs, 0, len(logsAndEvents)) events := make([]*data.LogEvent, 0) @@ -203,7 +204,7 @@ func (lep *logsAndEventsProcessor) prepareLogsForDB( continue } - dbLog, logEvents := lep.prepareLog(lgData, txLog.TxHash, txLog.Log, timestamp, shardID) + dbLog, logEvents := lep.prepareLog(lgData, txLog.TxHash, txLog.Log, timestamp, shardID, timestampMs) logs = append(logs, dbLog) events = append(events, logEvents...) @@ -218,6 +219,7 @@ func (lep *logsAndEventsProcessor) prepareLog( eventLogs *transaction.Log, timestamp uint64, shardID uint32, + timestampMs uint64, ) (*data.Logs, []*data.LogEvent) { originalTxHash := lep.getOriginalTxHash(lgData, logHashHex) encodedAddr := lep.pubKeyConverter.SilentEncode(eventLogs.GetAddress(), log) @@ -226,8 +228,9 @@ func (lep *logsAndEventsProcessor) prepareLog( ID: logHashHex, OriginalTxHash: originalTxHash, Address: encodedAddr, - Timestamp: time.Duration(timestamp), + Timestamp: timestamp, Events: make([]*data.Event, 0, len(eventLogs.Events)), + TimestampMs: timestampMs, } dbEvents := make([]*data.LogEvent, 0, len(eventLogs.Events)) @@ -247,13 +250,13 @@ func (lep *logsAndEventsProcessor) prepareLog( logsDB.Events = append(logsDB.Events, logEvent) executionOrder := lep.getExecutionOrder(lgData, logHashHex) - dbEvents = append(dbEvents, lep.prepareLogEvent(logsDB, logEvent, shardID, executionOrder)) + dbEvents = append(dbEvents, lep.prepareLogEvent(logsDB, logEvent, shardID, executionOrder, timestampMs)) } return logsDB, dbEvents } -func (lep *logsAndEventsProcessor) prepareLogEvent(dbLog *data.Logs, event *data.Event, shardID uint32, execOrder int) *data.LogEvent { +func (lep *logsAndEventsProcessor) prepareLogEvent(dbLog *data.Logs, event *data.Event, shardID uint32, execOrder int, timestampMs uint64) *data.LogEvent { dbEvent := &data.LogEvent{ UUID: converters.GenerateBase64UUID(), TxHash: dbLog.ID, @@ -269,6 +272,7 @@ func (lep *logsAndEventsProcessor) prepareLogEvent(dbLog *data.Logs, event *data OriginalTxHash: dbLog.OriginalTxHash, Timestamp: dbLog.Timestamp, ID: fmt.Sprintf(eventIDFormat, dbLog.ID, shardID, event.Order), + TimestampMs: timestampMs, } return dbEvent diff --git a/process/elasticproc/logsevents/logsAndEventsProcessor_test.go b/process/elasticproc/logsevents/logsAndEventsProcessor_test.go index 5fa6c582..0020af6f 100644 --- a/process/elasticproc/logsevents/logsAndEventsProcessor_test.go +++ b/process/elasticproc/logsevents/logsAndEventsProcessor_test.go @@ -2,10 +2,6 @@ package logsevents import ( "encoding/hex" - "math/big" - "testing" - "time" - "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-core-go/data/outport" "github.com/multiversx/mx-chain-core-go/data/transaction" @@ -14,6 +10,8 @@ import ( elasticIndexer "github.com/multiversx/mx-chain-es-indexer-go/process/dataindexer" "github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/converters" "github.com/stretchr/testify/require" + "math/big" + "testing" ) func createMockArgs() ArgsLogsAndEventsProcessor { @@ -157,7 +155,7 @@ func TestLogsAndEventsProcessor_ExtractDataFromLogsAndPutInAltered(t *testing.T) args.BalanceConverter = balanceConverter proc, _ := NewLogsAndEventsProcessor(args) - resLogs := proc.ExtractDataFromLogs(logsAndEvents, res, 1000, core.MetachainShardId, 3) + resLogs := proc.ExtractDataFromLogs(logsAndEvents, res, 1000, core.MetachainShardId, 3, 1000000) require.NotNil(t, resLogs.Tokens) require.True(t, res.Transactions[0].HasOperations) require.True(t, res.ScResults[0].HasOperations) @@ -169,6 +167,7 @@ func TestLogsAndEventsProcessor_ExtractDataFromLogsAndPutInAltered(t *testing.T) Creator: "6164647232", CurrentOwner: "6164647232", Timestamp: uint64(1000), + TimestampMs: uint64(1000000), CodeHash: []byte("codeHash"), }, resLogs.ScDeploys["6164647231"]) @@ -178,12 +177,14 @@ func TestLogsAndEventsProcessor_ExtractDataFromLogsAndPutInAltered(t *testing.T) Token: "SEMI-abcd", Type: core.SemiFungibleESDT, Timestamp: 1000, + TimestampMs: 1000000, Issuer: "61646472", CurrentOwner: "61646472", OwnersHistory: []*data.OwnerData{ { - Address: "61646472", - Timestamp: 1000, + Address: "61646472", + Timestamp: 1000, + TimestampMs: 1000000, }, }, Properties: &data.TokenProperties{}, @@ -194,14 +195,16 @@ func TestLogsAndEventsProcessor_ExtractDataFromLogsAndPutInAltered(t *testing.T) Contract: "636f6e7472616374", ActiveStakeNum: 0.1, ActiveStake: "1000000000", - Timestamp: time.Duration(1000), + Timestamp: 1000, + TimestampMs: 1000000, }, resLogs.Delegators["61646472636f6e7472616374"]) require.Equal(t, &data.Delegator{ Address: "61646472", Contract: "636f6e74726163742d7365636f6e64", ActiveStakeNum: 0.1, ActiveStake: "1000000000", - Timestamp: time.Duration(1000), + Timestamp: 1000, + TimestampMs: 1000000, }, resLogs.Delegators["61646472636f6e74726163742d7365636f6e64"]) } @@ -234,7 +237,7 @@ func TestLogsAndEventsProcessor_PrepareLogsForDB(t *testing.T) { Hash: "747848617368", OriginalTxHash: "orignalHash", }, - }}, 1234, 0, 3) + }}, 1234, 0, 3, 1234000) result.DBLogs[0].UUID = "" @@ -242,7 +245,8 @@ func TestLogsAndEventsProcessor_PrepareLogsForDB(t *testing.T) { ID: "747848617368", Address: "61646472657373", OriginalTxHash: "orignalHash", - Timestamp: time.Duration(1234), + Timestamp: 1234, + TimestampMs: 1234000, Events: []*data.Event{ { Address: "61646472", @@ -290,12 +294,14 @@ func TestLogsAndEventsProcessor_ExtractDataFromLogsNFTBurn(t *testing.T) { args.BalanceConverter = balanceConverter proc, _ := NewLogsAndEventsProcessor(args) - resLogs := proc.ExtractDataFromLogs(logsAndEventsSlice, res, 1000, 2, 3) + resLogs := proc.ExtractDataFromLogs(logsAndEventsSlice, res, 1000, 2, 3, 1000000) require.Equal(t, 1, resLogs.TokensSupply.Len()) tokensSupply := resLogs.TokensSupply.GetAll() require.Equal(t, "MY-NFT", tokensSupply[0].Token) require.Equal(t, "MY-NFT-02", tokensSupply[0].Identifier) + require.Equal(t, uint64(1000), tokensSupply[0].Timestamp) + require.Equal(t, uint64(1000000), tokensSupply[0].TimestampMs) } func TestPrepareLogsAndEvents_LogEvents(t *testing.T) { @@ -333,7 +339,7 @@ func TestPrepareLogsAndEvents_LogEvents(t *testing.T) { Hash: "747848617368", OriginalTxHash: "originalHash", }, - }}, 1234, 1, 3) + }}, 1234, 1, 3, 1234000) results.DBEvents[0].UUID = "" results.DBEvents[1].UUID = "" @@ -351,6 +357,7 @@ func TestPrepareLogsAndEvents_LogEvents(t *testing.T) { Order: 0, ShardID: 1, Timestamp: 1234, + TimestampMs: 1234000, TxOrder: 0, }, { @@ -366,6 +373,7 @@ func TestPrepareLogsAndEvents_LogEvents(t *testing.T) { Order: 1, ShardID: 1, Timestamp: 1234, + TimestampMs: 1234000, TxOrder: 0, }, }, results.DBEvents) diff --git a/process/elasticproc/logsevents/logsData.go b/process/elasticproc/logsevents/logsData.go index caacb880..0b45f903 100644 --- a/process/elasticproc/logsevents/logsData.go +++ b/process/elasticproc/logsevents/logsData.go @@ -8,6 +8,7 @@ import ( type logsData struct { timestamp uint64 + timestampMs uint64 txHashStatusInfoProc txHashStatusInfoHandler tokens data.TokensHandler tokensSupply data.TokensHandler @@ -25,6 +26,7 @@ func newLogsData( timestamp uint64, txs []*data.Transaction, scrs []*data.ScResult, + timestampMs uint64, ) *logsData { ld := &logsData{} @@ -40,6 +42,7 @@ func newLogsData( ld.nftsDataUpdates = make([]*data.NFTDataUpdate, 0) ld.tokenRolesAndProperties = tokeninfo.NewTokenRolesAndProperties() ld.txHashStatusInfoProc = newTxHashStatusInfoProcessor() + ld.timestampMs = timestampMs return ld } diff --git a/process/elasticproc/logsevents/nftsProcessor.go b/process/elasticproc/logsevents/nftsProcessor.go index 4189f964..01618c5c 100644 --- a/process/elasticproc/logsevents/nftsProcessor.go +++ b/process/elasticproc/logsevents/nftsProcessor.go @@ -1,9 +1,6 @@ package logsevents import ( - "math/big" - "time" - "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-core-go/core/sharding" coreData "github.com/multiversx/mx-chain-core-go/data" @@ -13,6 +10,7 @@ import ( "github.com/multiversx/mx-chain-es-indexer-go/data" "github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/converters" logger "github.com/multiversx/mx-chain-logger-go" + "math/big" ) const ( @@ -65,7 +63,7 @@ func (np *nftsProcessor) processEvent(args *argsProcessEvent) argOutputProcessEv sender := args.event.GetAddress() senderShardID := sharding.ComputeShardID(sender, args.numOfShards) if senderShardID == args.selfShardID { - np.processNFTEventOnSender(args.event, args.tokens, args.tokensSupply, args.timestamp) + np.processNFTEventOnSender(args.event, args.tokens, args.tokensSupply, args.timestamp, args.timestampMs) } token := string(topics[0]) @@ -87,10 +85,11 @@ func (np *nftsProcessor) processEvent(args *argsProcessEvent) argOutputProcessEv if eventIdentifier == core.BuiltInFunctionESDTWipe { args.tokensSupply.Add(&data.TokenInfo{ - Token: token, - Identifier: identifier, - Timestamp: time.Duration(args.timestamp), - Nonce: nonceBig.Uint64(), + Token: token, + Identifier: identifier, + Timestamp: args.timestamp, + TimestampMs: args.timestampMs, + Nonce: nonceBig.Uint64(), }) } @@ -116,6 +115,7 @@ func (np *nftsProcessor) processNFTEventOnSender( tokensCreateInfo data.TokensHandler, tokensSupply data.TokensHandler, timestamp uint64, + timestampMs uint64, ) { topics := event.GetTopics() token := string(topics[0]) @@ -123,10 +123,11 @@ func (np *nftsProcessor) processNFTEventOnSender( eventIdentifier := string(event.GetIdentifier()) if eventIdentifier == core.BuiltInFunctionESDTNFTBurn || eventIdentifier == core.BuiltInFunctionESDTWipe { tokensSupply.Add(&data.TokenInfo{ - Token: token, - Identifier: converters.ComputeTokenIdentifier(token, nonceBig.Uint64()), - Timestamp: time.Duration(timestamp), - Nonce: nonceBig.Uint64(), + Token: token, + Identifier: converters.ComputeTokenIdentifier(token, nonceBig.Uint64()), + Timestamp: timestamp, + TimestampMs: timestampMs, + Nonce: nonceBig.Uint64(), }) } @@ -146,11 +147,12 @@ func (np *nftsProcessor) processNFTEventOnSender( tokenMetaData := converters.PrepareTokenMetaData(convertMetaData(np.pubKeyConverter, esdtToken.TokenMetaData)) tokensCreateInfo.Add(&data.TokenInfo{ - Token: token, - Identifier: converters.ComputeTokenIdentifier(token, nonceBig.Uint64()), - Timestamp: time.Duration(timestamp), - Data: tokenMetaData, - Nonce: nonceBig.Uint64(), + Token: token, + Identifier: converters.ComputeTokenIdentifier(token, nonceBig.Uint64()), + Timestamp: timestamp, + TimestampMs: timestampMs, + Data: tokenMetaData, + Nonce: nonceBig.Uint64(), }) } diff --git a/process/elasticproc/logsevents/nftsProcessor_test.go b/process/elasticproc/logsevents/nftsProcessor_test.go index f8c25925..30189b09 100644 --- a/process/elasticproc/logsevents/nftsProcessor_test.go +++ b/process/elasticproc/logsevents/nftsProcessor_test.go @@ -3,16 +3,14 @@ package logsevents import ( "encoding/hex" "encoding/json" - "math/big" - "testing" - "time" - "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-core-go/data/esdt" "github.com/multiversx/mx-chain-core-go/data/transaction" "github.com/multiversx/mx-chain-es-indexer-go/data" "github.com/multiversx/mx-chain-es-indexer-go/mock" "github.com/stretchr/testify/require" + "math/big" + "testing" ) func TestNftsProcessor_processLogAndEventsNFTs(t *testing.T) { @@ -82,6 +80,6 @@ func TestNftsProcessor_processLogAndEventsNFTs_Wipe(t *testing.T) { Identifier: "nft-0123-14", Token: "nft-0123", Nonce: 20, - Timestamp: time.Duration(10000), + Timestamp: 10000, }, tokensSupply.GetAll()[0]) } diff --git a/process/elasticproc/logsevents/scDeploys.go b/process/elasticproc/logsevents/scDeploys.go index 03c990ff..3a315098 100644 --- a/process/elasticproc/logsevents/scDeploys.go +++ b/process/elasticproc/logsevents/scDeploys.go @@ -1,8 +1,6 @@ package logsevents import ( - "time" - "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-es-indexer-go/data" ) @@ -56,6 +54,7 @@ func (sdp *scDeploysProcessor) processEvent(args *argsProcessEvent) argOutputPro CurrentOwner: creatorAddress, CodeHash: topics[2], Timestamp: args.timestamp, + TimestampMs: args.timestampMs, } return argOutputProcessEvent{ @@ -67,9 +66,10 @@ func (sdp *scDeploysProcessor) processChangeOwnerEvent(args *argsProcessEvent) a scAddress := sdp.pubKeyConverter.SilentEncode(args.event.GetAddress(), log) newOwner := sdp.pubKeyConverter.SilentEncode(args.event.GetTopics()[0], log) args.changeOwnerOperations[scAddress] = &data.OwnerData{ - TxHash: args.txHashHexEncoded, - Address: newOwner, - Timestamp: time.Duration(args.timestamp), + TxHash: args.txHashHexEncoded, + Address: newOwner, + Timestamp: args.timestamp, + TimestampMs: args.timestampMs, } return argOutputProcessEvent{ diff --git a/process/elasticproc/logsevents/scDeploys_test.go b/process/elasticproc/logsevents/scDeploys_test.go index a725fb4b..8c29af56 100644 --- a/process/elasticproc/logsevents/scDeploys_test.go +++ b/process/elasticproc/logsevents/scDeploys_test.go @@ -25,6 +25,7 @@ func TestScDeploysProcessor(t *testing.T) { res := scDeploysProc.processEvent(&argsProcessEvent{ event: event, timestamp: 1000, + timestampMs: 1000000, scDeploys: scDeploys, txHashHexEncoded: "01020304", }) @@ -34,6 +35,7 @@ func TestScDeploysProcessor(t *testing.T) { TxHash: "01020304", Creator: "6164647232", Timestamp: uint64(1000), + TimestampMs: uint64(1000000), CurrentOwner: "6164647232", CodeHash: []byte("codeHash"), }, scDeploys["6164647231"]) @@ -53,13 +55,15 @@ func TestScDeploysProcessorChangeOwner(t *testing.T) { event: event, changeOwnerOperations: changeOwnerOperations, timestamp: 2000, + timestampMs: 2000000, txHashHexEncoded: "01020304", }) require.True(t, res.processed) require.Equal(t, &data.OwnerData{ - TxHash: "01020304", - Address: "6e65774f776e6572", - Timestamp: 2000, + TxHash: "01020304", + Address: "6e65774f776e6572", + Timestamp: 2000, + TimestampMs: 2000000, }, changeOwnerOperations["636f6e747261637441646472"]) } diff --git a/process/elasticproc/logsevents/serialize.go b/process/elasticproc/logsevents/serialize.go index 57d69f7e..ef406550 100644 --- a/process/elasticproc/logsevents/serialize.go +++ b/process/elasticproc/logsevents/serialize.go @@ -154,10 +154,11 @@ func serializeDeploy(deployInfo *data.ScDeployInfo) ([]byte, error) { } upgradeData := &data.Upgrade{ - TxHash: deployInfo.TxHash, - Upgrader: deployInfo.Creator, - Timestamp: deployInfo.Timestamp, - CodeHash: deployInfo.CodeHash, + TxHash: deployInfo.TxHash, + Upgrader: deployInfo.Creator, + Timestamp: deployInfo.Timestamp, + CodeHash: deployInfo.CodeHash, + TimestampMs: deployInfo.TimestampMs, } upgradeSerialized, errPrepareU := json.Marshal(upgradeData) if errPrepareU != nil { diff --git a/process/elasticproc/logsevents/serializeDelegators.go b/process/elasticproc/logsevents/serializeDelegators.go index b5b023da..1d3b1b74 100644 --- a/process/elasticproc/logsevents/serializeDelegators.go +++ b/process/elasticproc/logsevents/serializeDelegators.go @@ -28,26 +28,26 @@ func (lep *logsAndEventsProcessor) SerializeDelegators(delegators map[string]*da } // PrepareDelegatorsQueryInCaseOfRevert will prepare the delegators query in case of revert -func (lep *logsAndEventsProcessor) PrepareDelegatorsQueryInCaseOfRevert(timestamp uint64) *bytes.Buffer { +func (lep *logsAndEventsProcessor) PrepareDelegatorsQueryInCaseOfRevert(timestampMs uint64) *bytes.Buffer { codeToExecute := ` if ( !ctx._source.containsKey('unDelegateInfo') ) { return } if ( ctx._source.unDelegateInfo.length == 0 ) { return } - ctx._source.unDelegateInfo.removeIf(info -> info.timestamp.equals(params.timestamp)); + ctx._source.unDelegateInfo.removeIf(info -> info.timestampMs.equals(params.timestampMs)); ` query := fmt.Sprintf(` { "query": { "match": { - "timestamp": "%d" + "timestampMs": "%d" } }, "script": { "source": "%s", "lang": "painless", - "params": {"timestamp": %d} + "params": {"timestampMs": %d} } - }`, timestamp, converters.FormatPainlessSource(codeToExecute), timestamp) + }`, timestampMs, converters.FormatPainlessSource(codeToExecute), timestampMs) return bytes.NewBuffer([]byte(query)) } @@ -85,6 +85,7 @@ func prepareSerializedDataForDelegator(delegatorSerialized []byte) []byte { ctx._source.activeStake = params.delegator.activeStake; ctx._source.activeStakeNum = params.delegator.activeStakeNum; ctx._source.timestamp = params.delegator.timestamp; + ctx._source.timestampMs = params.delegator.timestampMs; } ` serializedDataStr := fmt.Sprintf(`{"scripted_upsert": true, "script": {`+ @@ -117,6 +118,7 @@ func prepareSerializedDataForUnDelegate(delegator *data.Delegator, delegatorSeri ctx._source.activeStake = params.delegator.activeStake; ctx._source.activeStakeNum = params.delegator.activeStakeNum; ctx._source.timestamp = params.delegator.timestamp; + ctx._source.timestampMs = params.delegator.timestampMs; } ` serializedDataStr := fmt.Sprintf(`{"scripted_upsert": true, "script": {`+ @@ -158,6 +160,7 @@ func prepareSerializedDataForWithdrawal(delegator *data.Delegator, delegatorSeri ctx._source.activeStake = params.delegator.activeStake; ctx._source.activeStakeNum = params.delegator.activeStakeNum; ctx._source.timestamp = params.delegator.timestamp; + ctx._source.timestampMs = params.delegator.timestampMs; } ` serializedDataStr := fmt.Sprintf(`{"scripted_upsert": true, "script": {`+ diff --git a/process/elasticproc/logsevents/serialize_test.go b/process/elasticproc/logsevents/serialize_test.go index f547e18d..30c84362 100644 --- a/process/elasticproc/logsevents/serialize_test.go +++ b/process/elasticproc/logsevents/serialize_test.go @@ -1,14 +1,12 @@ package logsevents import ( - "math/big" - "testing" - "time" - "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-es-indexer-go/data" "github.com/multiversx/mx-chain-es-indexer-go/mock" "github.com/stretchr/testify/require" + "math/big" + "testing" ) func TestLogsAndEventsProcessor_SerializeLogs(t *testing.T) { @@ -18,7 +16,7 @@ func TestLogsAndEventsProcessor_SerializeLogs(t *testing.T) { { ID: "747848617368", Address: "61646472657373", - Timestamp: time.Duration(1234), + Timestamp: 1234, Events: []*data.Event{ { Address: "61646472", @@ -46,9 +44,10 @@ func TestLogsAndEventsProcessor_SerializeSCDeploys(t *testing.T) { scDeploys := map[string]*data.ScDeployInfo{ "scAddr": { - Creator: "creator", - Timestamp: 123, - TxHash: "hash", + Creator: "creator", + Timestamp: 123, + TxHash: "hash", + TimestampMs: 123000, }, } @@ -57,7 +56,7 @@ func TestLogsAndEventsProcessor_SerializeSCDeploys(t *testing.T) { require.Nil(t, err) expectedRes := `{ "update" : { "_index":"scdeploys", "_id" : "scAddr" } } -{"script": {"source": "if (!ctx._source.containsKey('upgrades')) {ctx._source.upgrades = [params.elem];} else {ctx._source.upgrades.add(params.elem);}","lang": "painless","params": {"elem": {"upgradeTxHash":"hash","upgrader":"creator","timestamp":123,"codeHash":null}}},"upsert": {"deployTxHash":"hash","deployer":"creator","currentOwner":"","initialCodeHash":null,"timestamp":123,"upgrades":[],"owners":[]}} +{"script": {"source": "if (!ctx._source.containsKey('upgrades')) {ctx._source.upgrades = [params.elem];} else {ctx._source.upgrades.add(params.elem);}","lang": "painless","params": {"elem": {"upgradeTxHash":"hash","upgrader":"creator","timestamp":123,"timestampMs":123000,"codeHash":null}}},"upsert": {"deployTxHash":"hash","deployer":"creator","currentOwner":"","initialCodeHash":null,"timestamp":123,"timestampMs":123000,"upgrades":[],"owners":[]}} ` require.Equal(t, expectedRes, buffSlice.Buffers()[0].String()) } @@ -134,7 +133,7 @@ func TestLogsAndEventsProcessor_SerializeDelegators(t *testing.T) { require.Nil(t, err) expectedRes := `{ "update" : { "_index":"delegators", "_id" : "/GeogJjDjtpxnceK9t6+BVBYWuuJHbjmsWK0/1BlH9c=" } } -{"scripted_upsert": true, "script": {"source": "if ('create' == ctx.op) {ctx._source = params.delegator} else {ctx._source.activeStake = params.delegator.activeStake;ctx._source.activeStakeNum = params.delegator.activeStakeNum;ctx._source.timestamp = params.delegator.timestamp;}","lang": "painless","params": { "delegator": {"address":"addr1","contract":"contract1","timestamp":0,"activeStake":"100000000000000","activeStakeNum":0.1} }},"upsert": {}} +{"scripted_upsert": true, "script": {"source": "if ('create' == ctx.op) {ctx._source = params.delegator} else {ctx._source.activeStake = params.delegator.activeStake;ctx._source.activeStakeNum = params.delegator.activeStakeNum;ctx._source.timestamp = params.delegator.timestamp;ctx._source.timestampMs = params.delegator.timestampMs;}","lang": "painless","params": { "delegator": {"address":"addr1","contract":"contract1","timestamp":0,"activeStake":"100000000000000","activeStakeNum":0.1} }},"upsert": {}} ` require.Equal(t, expectedRes, buffSlice.Buffers()[0].String()) } diff --git a/process/elasticproc/miniblocks/miniblocksProcessor.go b/process/elasticproc/miniblocks/miniblocksProcessor.go index c4c1c061..451991cd 100644 --- a/process/elasticproc/miniblocks/miniblocksProcessor.go +++ b/process/elasticproc/miniblocks/miniblocksProcessor.go @@ -2,8 +2,6 @@ package miniblocks import ( "encoding/hex" - "time" - "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-core-go/core/check" coreData "github.com/multiversx/mx-chain-core-go/data" @@ -41,7 +39,7 @@ func NewMiniblocksProcessor( } // PrepareDBMiniblocks will prepare miniblocks -func (mp *miniblocksProcessor) PrepareDBMiniblocks(header coreData.HeaderHandler, miniBlocks []*block.MiniBlock) []*data.Miniblock { +func (mp *miniblocksProcessor) PrepareDBMiniblocks(header coreData.HeaderHandler, miniBlocks []*block.MiniBlock, timestampMS uint64) []*data.Miniblock { headerHash, err := mp.calculateHash(header) if err != nil { log.Warn("indexer: could not calculate header hash", "error", err) @@ -56,7 +54,7 @@ func (mp *miniblocksProcessor) PrepareDBMiniblocks(header coreData.HeaderHandler continue } - dbMiniBlock, errPrepareMiniBlock := mp.prepareMiniblockForDB(mbIndex, miniBlock, header, headerHash) + dbMiniBlock, errPrepareMiniBlock := mp.prepareMiniblockForDB(mbIndex, miniBlock, header, headerHash, timestampMS) if errPrepareMiniBlock != nil { log.Warn("miniblocksProcessor.PrepareDBMiniBlocks cannot prepare miniblock", "error", errPrepareMiniBlock) continue @@ -73,6 +71,7 @@ func (mp *miniblocksProcessor) prepareMiniblockForDB( miniblock *block.MiniBlock, header coreData.HeaderHandler, headerHash []byte, + timestampMS uint64, ) (*data.Miniblock, error) { mbHash, err := mp.calculateHash(miniblock) if err != nil { @@ -86,7 +85,8 @@ func (mp *miniblocksProcessor) prepareMiniblockForDB( SenderShardID: miniblock.SenderShardID, ReceiverShardID: miniblock.ReceiverShardID, Type: miniblock.Type.String(), - Timestamp: time.Duration(header.GetTimeStamp()), + Timestamp: header.GetTimeStamp(), + TimestampMs: timestampMS, Reserved: miniblock.Reserved, } diff --git a/process/elasticproc/miniblocks/miniblocksProcessor_test.go b/process/elasticproc/miniblocks/miniblocksProcessor_test.go index f9cf687b..180b16fe 100644 --- a/process/elasticproc/miniblocks/miniblocksProcessor_test.go +++ b/process/elasticproc/miniblocks/miniblocksProcessor_test.go @@ -65,7 +65,7 @@ func TestMiniblocksProcessor_PrepareDBMiniblocks(t *testing.T) { }, } - miniblocks := mp.PrepareDBMiniblocks(header, body.MiniBlocks) + miniblocks := mp.PrepareDBMiniblocks(header, body.MiniBlocks, 1234000) require.Len(t, miniblocks, 3) } @@ -90,6 +90,7 @@ func TestMiniblocksProcessor_PrepareScheduledMB(t *testing.T) { Reserved: mbhrBytes, }, }, + TimeStamp: 1234, } miniBlocks := []*dataBlock.MiniBlock{ { @@ -106,7 +107,7 @@ func TestMiniblocksProcessor_PrepareScheduledMB(t *testing.T) { }, } - miniblocks := mp.PrepareDBMiniblocks(header, miniBlocks) + miniblocks := mp.PrepareDBMiniblocks(header, miniBlocks, 1234000) require.Len(t, miniblocks, 3) require.Equal(t, dataBlock.Scheduled.String(), miniblocks[1].ProcessingTypeOnSource) @@ -114,11 +115,13 @@ func TestMiniblocksProcessor_PrepareScheduledMB(t *testing.T) { Hash: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", SenderShardID: 0, ReceiverShardID: 0, - SenderBlockHash: "84b80cbf612d067201b5260b4c6f90fa7b5c11e898fa9c1c65f4c75e61e41619", - ReceiverBlockHash: "84b80cbf612d067201b5260b4c6f90fa7b5c11e898fa9c1c65f4c75e61e41619", + SenderBlockHash: "64ad61aaddb68f8d0b38ceda3b2b1f76a6749a0e848ed9e95bdaff46b4e73423", + ReceiverBlockHash: "64ad61aaddb68f8d0b38ceda3b2b1f76a6749a0e848ed9e95bdaff46b4e73423", ProcessingTypeOnSource: dataBlock.Normal.String(), ProcessingTypeOnDestination: dataBlock.Normal.String(), Type: dataBlock.TxBlock.String(), + Timestamp: 1234, + TimestampMs: 1234000, }, miniblocks[2]) } diff --git a/process/elasticproc/statistics/serialize.go b/process/elasticproc/statistics/serialize.go index 09879f25..61edf964 100644 --- a/process/elasticproc/statistics/serialize.go +++ b/process/elasticproc/statistics/serialize.go @@ -4,8 +4,6 @@ import ( "bytes" "encoding/json" "fmt" - "time" - "github.com/multiversx/mx-chain-core-go/data/outport" "github.com/multiversx/mx-chain-es-indexer-go/data" logger "github.com/multiversx/mx-chain-logger-go" @@ -31,7 +29,8 @@ func (sp *statisticsProcessor) SerializeRoundsInfo(rounds *outport.RoundsInfo) * BlockWasProposed: info.BlockWasProposed, ShardId: info.ShardId, Epoch: info.Epoch, - Timestamp: time.Duration(info.Timestamp), + Timestamp: info.Timestamp, + TimestampMs: info.TimestampMs, }) buff.Grow(len(meta) + len(serializedRoundInfo)) diff --git a/process/elasticproc/statistics/serialize_test.go b/process/elasticproc/statistics/serialize_test.go index a0cd079c..cf9e96c6 100644 --- a/process/elasticproc/statistics/serialize_test.go +++ b/process/elasticproc/statistics/serialize_test.go @@ -14,11 +14,13 @@ func TestStatisticsProcessor_SerializeRoundsInfo(t *testing.T) { buff := sp.SerializeRoundsInfo(&outport.RoundsInfo{ RoundsInfo: []*outport.RoundInfo{{ - Epoch: 1, + Epoch: 1, + Timestamp: 1234, + TimestampMs: 1234000, }}, }) expectedBuff := `{ "index" : { "_id" : "0_0" } } -{"round":0,"signersIndexes":null,"blockWasProposed":false,"shardId":0,"epoch":1,"timestamp":0} +{"round":0,"signersIndexes":null,"blockWasProposed":false,"shardId":0,"epoch":1,"timestamp":1234,"timestampMs":1234000} ` require.Equal(t, expectedBuff, buff.String()) } diff --git a/process/elasticproc/templatesAndPolicies/interface.go b/process/elasticproc/templatesAndPolicies/interface.go deleted file mode 100644 index 2215c781..00000000 --- a/process/elasticproc/templatesAndPolicies/interface.go +++ /dev/null @@ -1,13 +0,0 @@ -package templatesAndPolicies - -import ( - "bytes" - - "github.com/multiversx/mx-chain-es-indexer-go/templates" -) - -// TemplatesAndPoliciesHandler defines the actions that a templates and policies handler should do -type TemplatesAndPoliciesHandler interface { - GetElasticTemplatesAndPolicies() (map[string]*bytes.Buffer, map[string]*bytes.Buffer, error) - GetExtraMappings() ([]templates.ExtraMapping, error) -} diff --git a/process/elasticproc/templatesAndPolicies/reader.go b/process/elasticproc/templatesAndPolicies/reader.go index d14c7987..35db2efb 100644 --- a/process/elasticproc/templatesAndPolicies/reader.go +++ b/process/elasticproc/templatesAndPolicies/reader.go @@ -47,6 +47,81 @@ func (tr *templatesAndPolicyReader) GetElasticTemplatesAndPolicies() (map[string return indexTemplates, indexPolicies, nil } +// GetTimestampMsMappings will return the timestampMs field mappings for all indices +func (tr *templatesAndPolicyReader) GetTimestampMsMappings() ([]templates.ExtraMapping, error) { + return []templates.ExtraMapping{ + { + Index: indexer.TransactionsIndex, + Mappings: indices.TimestampMs.ToBuffer(), + }, + { + Index: indexer.BlockIndex, + Mappings: indices.TimestampMs.ToBuffer(), + }, + { + Index: indexer.MiniblocksIndex, + Mappings: indices.TimestampMs.ToBuffer(), + }, + { + Index: indexer.RoundsIndex, + Mappings: indices.TimestampMs.ToBuffer(), + }, + { + Index: indexer.AccountsIndex, + Mappings: indices.TimestampMs.ToBuffer(), + }, + { + Index: indexer.AccountsESDTIndex, + Mappings: indices.TimestampMs.ToBuffer(), + }, + { + Index: indexer.AccountsHistoryIndex, + Mappings: indices.TimestampMs.ToBuffer(), + }, + { + Index: indexer.AccountsESDTHistoryIndex, + Mappings: indices.TimestampMs.ToBuffer(), + }, + { + Index: indexer.ReceiptsIndex, + Mappings: indices.TimestampMs.ToBuffer(), + }, + + { + Index: indexer.ScResultsIndex, + Mappings: indices.TimestampMs.ToBuffer(), + }, + { + Index: indexer.LogsIndex, + Mappings: indices.TimestampMs.ToBuffer(), + }, + { + Index: indexer.OperationsIndex, + Mappings: indices.TimestampMs.ToBuffer(), + }, + { + Index: indexer.EventsIndex, + Mappings: indices.TimestampMs.ToBuffer(), + }, + { + Index: indexer.TokensIndex, + Mappings: indices.TokensTimestampMs.ToBuffer(), + }, + { + Index: indexer.ESDTsIndex, + Mappings: indices.TokensTimestampMs.ToBuffer(), + }, + { + Index: indexer.DelegatorsIndex, + Mappings: indices.DelegatorsTimestampMs.ToBuffer(), + }, + { + Index: indexer.SCDeploysIndex, + Mappings: indices.DeploysTimestampMs.ToBuffer(), + }, + }, nil +} + // GetExtraMappings will return an array of indices extra mappings func (tr *templatesAndPolicyReader) GetExtraMappings() ([]templates.ExtraMapping, error) { return []templates.ExtraMapping{}, nil diff --git a/process/elasticproc/transactions/smartContractResultsProcessor.go b/process/elasticproc/transactions/smartContractResultsProcessor.go index 495978cd..4eaf71d7 100644 --- a/process/elasticproc/transactions/smartContractResultsProcessor.go +++ b/process/elasticproc/transactions/smartContractResultsProcessor.go @@ -2,9 +2,6 @@ package transactions import ( "encoding/hex" - "strconv" - "time" - "github.com/multiversx/mx-chain-core-go/core" coreData "github.com/multiversx/mx-chain-core-go/data" "github.com/multiversx/mx-chain-core-go/data/block" @@ -14,6 +11,7 @@ import ( indexerData "github.com/multiversx/mx-chain-es-indexer-go/data" "github.com/multiversx/mx-chain-es-indexer-go/process/dataindexer" "github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/converters" + "strconv" ) type smartContractResultsProcessor struct { @@ -45,6 +43,7 @@ func (proc *smartContractResultsProcessor) processSCRs( header coreData.HeaderHandler, scrs map[string]*outport.SCRInfo, numOfShards uint32, + timestampMs uint64, ) []*indexerData.ScResult { allSCRs := make([]*indexerData.ScResult, 0, len(scrs)) @@ -55,14 +54,14 @@ func (proc *smartContractResultsProcessor) processSCRs( continue } - indexerSCRs := proc.processSCRsFromMiniblock(header, mb, workingSCRSMap, numOfShards) + indexerSCRs := proc.processSCRsFromMiniblock(header, mb, workingSCRSMap, numOfShards, timestampMs) allSCRs = append(allSCRs, indexerSCRs...) } selfShardID := header.GetShardID() for scrHashHex, noMBScrInfo := range workingSCRSMap { - indexerScr := proc.prepareSmartContractResult(scrHashHex, nil, noMBScrInfo, header, selfShardID, selfShardID, numOfShards) + indexerScr := proc.prepareSmartContractResult(scrHashHex, nil, noMBScrInfo, header, selfShardID, selfShardID, numOfShards, timestampMs) allSCRs = append(allSCRs, indexerScr) } @@ -75,6 +74,7 @@ func (proc *smartContractResultsProcessor) processSCRsFromMiniblock( mb *block.MiniBlock, scrs map[string]*outport.SCRInfo, numOfShards uint32, + timestampMs uint64, ) []*indexerData.ScResult { mbHash, err := core.CalculateHash(proc.marshalizer, proc.hasher, mb) if err != nil { @@ -93,7 +93,7 @@ func (proc *smartContractResultsProcessor) processSCRsFromMiniblock( continue } - indexerSCR := proc.prepareSmartContractResult(hex.EncodeToString(scrHash), mbHash, scrInfo, header, mb.SenderShardID, mb.ReceiverShardID, numOfShards) + indexerSCR := proc.prepareSmartContractResult(hex.EncodeToString(scrHash), mbHash, scrInfo, header, mb.SenderShardID, mb.ReceiverShardID, numOfShards, timestampMs) indexerSCRs = append(indexerSCRs, indexerSCR) delete(scrs, scrHashHex) @@ -110,6 +110,7 @@ func (proc *smartContractResultsProcessor) prepareSmartContractResult( senderShard uint32, receiverShard uint32, numOfShards uint32, + timestampMs uint64, ) *indexerData.ScResult { scr := scrInfo.SmartContractResult hexEncodedMBHash := "" @@ -174,7 +175,7 @@ func (proc *smartContractResultsProcessor) prepareSmartContractResult( CallType: strconv.Itoa(int(scr.CallType)), CodeMetadata: scr.CodeMetadata, ReturnMessage: string(scr.ReturnMessage), - Timestamp: time.Duration(header.GetTimeStamp()), + Timestamp: header.GetTimeStamp(), SenderAddressBytes: scr.SndAddr, SenderShard: senderShard, ReceiverShard: receiverShard, @@ -193,6 +194,7 @@ func (proc *smartContractResultsProcessor) prepareSmartContractResult( ExecutionOrder: int(scrInfo.ExecutionOrder), UUID: converters.GenerateBase64UUID(), Epoch: header.GetEpoch(), + TimestampMs: timestampMs, } } diff --git a/process/elasticproc/transactions/smartContractResultsProcessor_test.go b/process/elasticproc/transactions/smartContractResultsProcessor_test.go index ac35dfd8..940669f6 100644 --- a/process/elasticproc/transactions/smartContractResultsProcessor_test.go +++ b/process/elasticproc/transactions/smartContractResultsProcessor_test.go @@ -2,10 +2,6 @@ package transactions import ( "encoding/hex" - "math/big" - "testing" - "time" - "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" @@ -14,6 +10,8 @@ import ( "github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/converters" datafield "github.com/multiversx/mx-chain-vm-common-go/parsers/dataField" "github.com/stretchr/testify/require" + "math/big" + "testing" ) func createDataFieldParserMock() DataFieldParser { @@ -60,7 +58,7 @@ func TestPrepareSmartContractResult(t *testing.T) { header := &block.Header{TimeStamp: 100} mbHash := []byte("hash") - scRes := scrsProc.prepareSmartContractResult(scHash, mbHash, scrInfo, header, 0, 1, 3) + scRes := scrsProc.prepareSmartContractResult(scHash, mbHash, scrInfo, header, 0, 1, 3, 100000) scRes.UUID = "" senderAddr, err := pubKeyConverter.Encode(sndAddr) @@ -79,7 +77,8 @@ func TestPrepareSmartContractResult(t *testing.T) { Receiver: receiverAddr, Value: "", CallType: "1", - Timestamp: time.Duration(100), + Timestamp: uint64(100), + TimestampMs: uint64(100000), SenderShard: 0, ReceiverShard: 1, Operation: "transfer", diff --git a/process/elasticproc/transactions/transactionDBBuilder.go b/process/elasticproc/transactions/transactionDBBuilder.go index 3bb75015..ebba6838 100644 --- a/process/elasticproc/transactions/transactionDBBuilder.go +++ b/process/elasticproc/transactions/transactionDBBuilder.go @@ -3,8 +3,6 @@ package transactions import ( "encoding/hex" "fmt" - "time" - "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-core-go/core/sharding" coreData "github.com/multiversx/mx-chain-core-go/data" @@ -42,6 +40,7 @@ func (dtb *dbTransactionBuilder) prepareTransaction( header coreData.HeaderHandler, txStatus string, numOfShards uint32, + timestampMs uint64, ) *data.Transaction { tx := txInfo.Transaction @@ -106,7 +105,7 @@ func (dtb *dbTransactionBuilder) prepareTransaction( GasLimit: tx.GasLimit, Data: tx.Data, Signature: hex.EncodeToString(tx.Signature), - Timestamp: time.Duration(header.GetTimeStamp()), + Timestamp: header.GetTimeStamp(), Status: txStatus, GasUsed: feeInfo.GasUsed, InitialPaidFee: feeInfo.InitialPaidFee.String(), @@ -128,6 +127,7 @@ func (dtb *dbTransactionBuilder) prepareTransaction( HadRefund: feeInfo.HadRefund, UUID: converters.GenerateBase64UUID(), Epoch: header.GetEpoch(), + TimestampMs: timestampMs, } hasValidRelayer := len(eTx.RelayedAddr) == len(eTx.Sender) && len(eTx.RelayedAddr) > 0 @@ -149,6 +149,7 @@ func (dtb *dbTransactionBuilder) prepareRewardTransaction( mb *block.MiniBlock, header coreData.HeaderHandler, txStatus string, + timestampMs uint64, ) *data.Transaction { rTx := rTxInfo.Reward valueNum, err := dtb.balanceConverter.ConvertBigValueToFloat(rTx.Value) @@ -174,12 +175,13 @@ func (dtb *dbTransactionBuilder) prepareRewardTransaction( GasLimit: 0, Data: make([]byte, 0), Signature: "", - Timestamp: time.Duration(header.GetTimeStamp()), + Timestamp: header.GetTimeStamp(), Status: txStatus, Operation: rewardsOperation, ExecutionOrder: int(rTxInfo.ExecutionOrder), UUID: converters.GenerateBase64UUID(), Epoch: header.GetEpoch(), + TimestampMs: timestampMs, } } @@ -187,15 +189,17 @@ func (dtb *dbTransactionBuilder) prepareReceipt( recHashHex string, rec *receipt.Receipt, header coreData.HeaderHandler, + timestampMs uint64, ) *data.Receipt { senderAddr := dtb.addressPubkeyConverter.SilentEncode(rec.SndAddr, log) return &data.Receipt{ - Hash: recHashHex, - Value: rec.Value.String(), - Sender: senderAddr, - Data: string(rec.Data), - TxHash: hex.EncodeToString(rec.TxHash), - Timestamp: time.Duration(header.GetTimeStamp()), + Hash: recHashHex, + Value: rec.Value.String(), + Sender: senderAddr, + Data: string(rec.Data), + TxHash: hex.EncodeToString(rec.TxHash), + Timestamp: header.GetTimeStamp(), + TimestampMs: timestampMs, } } diff --git a/process/elasticproc/transactions/transactionDBBuilder_test.go b/process/elasticproc/transactions/transactionDBBuilder_test.go index ce67ece1..74be210a 100644 --- a/process/elasticproc/transactions/transactionDBBuilder_test.go +++ b/process/elasticproc/transactions/transactionDBBuilder_test.go @@ -3,10 +3,6 @@ package transactions import ( "encoding/hex" "fmt" - "math/big" - "testing" - "time" - "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-core-go/data/block" "github.com/multiversx/mx-chain-core-go/data/outport" @@ -16,6 +12,8 @@ import ( "github.com/multiversx/mx-chain-es-indexer-go/mock" "github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/converters" "github.com/stretchr/testify/require" + "math/big" + "testing" ) func createCommonProcessor() dbTransactionBuilder { @@ -33,7 +31,7 @@ func TestGetMoveBalanceTransaction(t *testing.T) { txHash := []byte("txHash") mbHash := []byte("mbHash") mb := &block.MiniBlock{TxHashes: [][]byte{txHash}} - header := &block.Header{Nonce: 2} + header := &block.Header{Nonce: 2, TimeStamp: 1234} status := "Success" gasPrice := uint64(1000) gasLimit := uint64(1000) @@ -86,7 +84,6 @@ func TestGetMoveBalanceTransaction(t *testing.T) { InitialPaidFee: "100", Data: tx.Data, Signature: hex.EncodeToString(tx.Signature), - Timestamp: time.Duration(header.GetTimeStamp()), Status: status, Fee: "100", FeeNum: 1e-16, @@ -96,9 +93,11 @@ func TestGetMoveBalanceTransaction(t *testing.T) { Operation: "transfer", Version: 1, Receivers: []string{}, + Timestamp: 1234, + TimestampMs: 1234000, } - dbTx := cp.prepareTransaction(txInfo, txHash, mbHash, mb, header, status, 3) + dbTx := cp.prepareTransaction(txInfo, txHash, mbHash, mb, header, status, 3, 1234000) dbTx.UUID = "" require.Equal(t, expectedTx, dbTx) } @@ -114,24 +113,26 @@ func TestGetTransactionByType_RewardTx(t *testing.T) { txHash := []byte("txHash") mbHash := []byte("mbHash") mb := &block.MiniBlock{TxHashes: [][]byte{txHash}} - header := &block.Header{Nonce: 2} + header := &block.Header{Nonce: 2, TimeStamp: 1234} status := "Success" rewardInfo := &outport.RewardInfo{ Reward: rwdTx, } - resultTx := cp.prepareRewardTransaction(rewardInfo, txHash, mbHash, mb, header, status) + resultTx := cp.prepareRewardTransaction(rewardInfo, txHash, mbHash, mb, header, status, 1234000) resultTx.UUID = "" expectedTx := &data.Transaction{ - Hash: hex.EncodeToString(txHash), - MBHash: hex.EncodeToString(mbHash), - Round: round, - Receiver: hex.EncodeToString(rcvAddr), - Status: status, - Value: "", - Sender: fmt.Sprintf("%d", core.MetachainShardId), - Data: make([]byte, 0), - Operation: rewardsOperation, + Hash: hex.EncodeToString(txHash), + MBHash: hex.EncodeToString(mbHash), + Round: round, + Receiver: hex.EncodeToString(rcvAddr), + Status: status, + Value: "", + Sender: fmt.Sprintf("%d", core.MetachainShardId), + Data: make([]byte, 0), + Operation: rewardsOperation, + Timestamp: 1234, + TimestampMs: 1234000, } require.Equal(t, expectedTx, resultTx) @@ -143,7 +144,7 @@ func TestRelayedV3Transaction(t *testing.T) { txHash := []byte("txHash") mbHash := []byte("mbHash") mb := &block.MiniBlock{TxHashes: [][]byte{txHash}, Type: block.InvalidBlock} - header := &block.Header{Nonce: 2} + header := &block.Header{Nonce: 2, TimeStamp: 1234} status := transaction.TxStatusInvalid.String() gasPrice := uint64(1000) gasLimit := uint64(1000) @@ -183,7 +184,6 @@ func TestRelayedV3Transaction(t *testing.T) { InitialPaidFee: "100", Data: tx.Data, Signature: hex.EncodeToString(tx.Signature), - Timestamp: time.Duration(header.GetTimeStamp()), Status: status, Fee: "100", FeeNum: 1e-16, @@ -195,6 +195,8 @@ func TestRelayedV3Transaction(t *testing.T) { ESDTValuesNum: []float64{}, RelayedAddr: hex.EncodeToString(tx.RelayerAddr), RelayedSignature: hex.EncodeToString(tx.RelayerSignature), + Timestamp: 1234, + TimestampMs: 1234000, } txInfo := &outport.TxInfo{ @@ -207,7 +209,7 @@ func TestRelayedV3Transaction(t *testing.T) { ExecutionOrder: 0, } - dbTx := cp.prepareTransaction(txInfo, txHash, mbHash, mb, header, status, 3) + dbTx := cp.prepareTransaction(txInfo, txHash, mbHash, mb, header, status, 3, 1234000) dbTx.UUID = "" require.Equal(t, expectedTx, dbTx) } @@ -218,7 +220,7 @@ func TestGetMoveBalanceTransactionInvalid(t *testing.T) { txHash := []byte("txHash") mbHash := []byte("mbHash") mb := &block.MiniBlock{TxHashes: [][]byte{txHash}, Type: block.InvalidBlock} - header := &block.Header{Nonce: 2} + header := &block.Header{Nonce: 2, TimeStamp: 1234} status := transaction.TxStatusInvalid.String() gasPrice := uint64(1000) gasLimit := uint64(1000) @@ -256,7 +258,6 @@ func TestGetMoveBalanceTransactionInvalid(t *testing.T) { InitialPaidFee: "100", Data: tx.Data, Signature: hex.EncodeToString(tx.Signature), - Timestamp: time.Duration(header.GetTimeStamp()), Status: status, Fee: "100", FeeNum: 1e-16, @@ -266,6 +267,8 @@ func TestGetMoveBalanceTransactionInvalid(t *testing.T) { Version: 1, Receivers: []string{}, ESDTValuesNum: []float64{}, + Timestamp: 1234, + TimestampMs: 1234000, } txInfo := &outport.TxInfo{ @@ -278,7 +281,7 @@ func TestGetMoveBalanceTransactionInvalid(t *testing.T) { ExecutionOrder: 0, } - dbTx := cp.prepareTransaction(txInfo, txHash, mbHash, mb, header, status, 3) + dbTx := cp.prepareTransaction(txInfo, txHash, mbHash, mb, header, status, 3, 1234000) dbTx.UUID = "" require.Equal(t, expectedTx, dbTx) } diff --git a/process/elasticproc/transactions/transactionsGrouper.go b/process/elasticproc/transactions/transactionsGrouper.go index 5aaf15a4..1c7e237a 100644 --- a/process/elasticproc/transactions/transactionsGrouper.go +++ b/process/elasticproc/transactions/transactionsGrouper.go @@ -43,6 +43,7 @@ func (tg *txsGrouper) groupNormalTxs( txs map[string]*outport.TxInfo, isImportDB bool, numOfShards uint32, + timestampMs uint64, ) (map[string]*data.Transaction, error) { transactions := make(map[string]*data.Transaction) @@ -55,7 +56,7 @@ func (tg *txsGrouper) groupNormalTxs( executedTxHashes := extractExecutedTxHashes(mbIndex, mb.TxHashes, header) mbStatus := computeStatus(selfShardID, mb.ReceiverShardID) for _, txHash := range executedTxHashes { - dbTx, ok := tg.prepareNormalTxForDB(mbHash, mb, mbStatus, txHash, txs, header, numOfShards) + dbTx, ok := tg.prepareNormalTxForDB(mbHash, mb, mbStatus, txHash, txs, header, numOfShards, timestampMs) if !ok { continue } @@ -97,13 +98,14 @@ func (tg *txsGrouper) prepareNormalTxForDB( txs map[string]*outport.TxInfo, header coreData.HeaderHandler, numOfShards uint32, + timestampMs uint64, ) (*data.Transaction, bool) { txInfo, okGet := txs[hex.EncodeToString(txHash)] if !okGet { return nil, false } - dbTx := tg.txBuilder.prepareTransaction(txInfo, txHash, mbHash, mb, header, mbStatus, numOfShards) + dbTx := tg.txBuilder.prepareTransaction(txInfo, txHash, mbHash, mb, header, mbStatus, numOfShards, timestampMs) return dbTx, true } @@ -114,6 +116,7 @@ func (tg *txsGrouper) groupRewardsTxs( header coreData.HeaderHandler, txs map[string]*outport.RewardInfo, isImportDB bool, + timestampMs uint64, ) (map[string]*data.Transaction, error) { rewardsTxs := make(map[string]*data.Transaction) mbHash, err := core.CalculateHash(tg.marshalizer, tg.hasher, mb) @@ -125,7 +128,7 @@ func (tg *txsGrouper) groupRewardsTxs( mbStatus := computeStatus(selfShardID, mb.ReceiverShardID) executedTxHashes := extractExecutedTxHashes(mbIndex, mb.TxHashes, header) for _, txHash := range executedTxHashes { - rewardDBTx, ok := tg.prepareRewardTxForDB(mbHash, mb, mbStatus, txHash, txs, header) + rewardDBTx, ok := tg.prepareRewardTxForDB(mbHash, mb, mbStatus, txHash, txs, header, timestampMs) if !ok { continue } @@ -145,13 +148,14 @@ func (tg *txsGrouper) prepareRewardTxForDB( txHash []byte, txs map[string]*outport.RewardInfo, header coreData.HeaderHandler, + timestampMs uint64, ) (*data.Transaction, bool) { rtx, okGet := txs[hex.EncodeToString(txHash)] if !okGet { return nil, false } - dbTx := tg.txBuilder.prepareRewardTransaction(rtx, txHash, mbHash, mb, header, mbStatus) + dbTx := tg.txBuilder.prepareRewardTransaction(rtx, txHash, mbHash, mb, header, mbStatus, timestampMs) return dbTx, true } @@ -162,6 +166,7 @@ func (tg *txsGrouper) groupInvalidTxs( header coreData.HeaderHandler, txs map[string]*outport.TxInfo, numOfShards uint32, + timestampMs uint64, ) (map[string]*data.Transaction, error) { transactions := make(map[string]*data.Transaction) mbHash, err := core.CalculateHash(tg.marshalizer, tg.hasher, mb) @@ -171,7 +176,7 @@ func (tg *txsGrouper) groupInvalidTxs( executedTxHashes := extractExecutedTxHashes(mbIndex, mb.TxHashes, header) for _, txHash := range executedTxHashes { - invalidDBTx, ok := tg.prepareInvalidTxForDB(mbHash, mb, txHash, txs, header, numOfShards) + invalidDBTx, ok := tg.prepareInvalidTxForDB(mbHash, mb, txHash, txs, header, numOfShards, timestampMs) if !ok { continue } @@ -189,13 +194,14 @@ func (tg *txsGrouper) prepareInvalidTxForDB( txs map[string]*outport.TxInfo, header coreData.HeaderHandler, numOfShards uint32, + timestampMs uint64, ) (*data.Transaction, bool) { txInfo, okGet := txs[hex.EncodeToString(txHash)] if !okGet { return nil, false } - dbTx := tg.txBuilder.prepareTransaction(txInfo, txHash, mbHash, mb, header, transaction.TxStatusInvalid.String(), numOfShards) + dbTx := tg.txBuilder.prepareTransaction(txInfo, txHash, mbHash, mb, header, transaction.TxStatusInvalid.String(), numOfShards, timestampMs) return dbTx, true } @@ -208,10 +214,10 @@ func (tg *txsGrouper) shouldIndex(destinationShardID uint32, isImportDB bool, se return selfShardID == destinationShardID } -func (tg *txsGrouper) groupReceipts(header coreData.HeaderHandler, txsPool map[string]*receipt.Receipt) []*data.Receipt { +func (tg *txsGrouper) groupReceipts(header coreData.HeaderHandler, txsPool map[string]*receipt.Receipt, timestampMs uint64) []*data.Receipt { dbReceipts := make([]*data.Receipt, 0) for hashHex, rec := range txsPool { - dbReceipts = append(dbReceipts, tg.txBuilder.prepareReceipt(hashHex, rec, header)) + dbReceipts = append(dbReceipts, tg.txBuilder.prepareReceipt(hashHex, rec, header, timestampMs)) } return dbReceipts diff --git a/process/elasticproc/transactions/transactionsGrouper_test.go b/process/elasticproc/transactions/transactionsGrouper_test.go index 12c6b75e..da468802 100644 --- a/process/elasticproc/transactions/transactionsGrouper_test.go +++ b/process/elasticproc/transactions/transactionsGrouper_test.go @@ -2,8 +2,6 @@ package transactions import ( "encoding/hex" - "testing" - "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/receipt" @@ -12,6 +10,7 @@ import ( "github.com/multiversx/mx-chain-es-indexer-go/mock" "github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/converters" "github.com/stretchr/testify/require" + "testing" ) func TestGroupNormalTxs(t *testing.T) { @@ -28,7 +27,7 @@ func TestGroupNormalTxs(t *testing.T) { TxHashes: [][]byte{txHash1, txHash2}, Type: block.TxBlock, } - header := &block.Header{} + header := &block.Header{TimeStamp: 1234} txs := map[string]*outport.TxInfo{ hex.EncodeToString(txHash1): { Transaction: &transaction.Transaction{ @@ -46,8 +45,10 @@ func TestGroupNormalTxs(t *testing.T) { }, } - normalTxs, _ := grouper.groupNormalTxs(0, mb, header, txs, false, 3) + normalTxs, _ := grouper.groupNormalTxs(0, mb, header, txs, false, 3, 1234000) require.Len(t, normalTxs, 2) + require.Equal(t, uint64(1234), normalTxs[string(txHash1)].Timestamp) + require.Equal(t, uint64(1234000), normalTxs[string(txHash1)].TimestampMs) } func TestGroupRewardsTxs(t *testing.T) { @@ -64,7 +65,7 @@ func TestGroupRewardsTxs(t *testing.T) { TxHashes: [][]byte{txHash1, txHash2}, Type: block.RewardsBlock, } - header := &block.Header{} + header := &block.Header{TimeStamp: 1234} txs := map[string]*outport.RewardInfo{ hex.EncodeToString(txHash1): {Reward: &rewardTx.RewardTx{ RcvAddr: []byte("receiver1"), @@ -74,8 +75,10 @@ func TestGroupRewardsTxs(t *testing.T) { }}, } - normalTxs, _ := grouper.groupRewardsTxs(0, mb, header, txs, false) + normalTxs, _ := grouper.groupRewardsTxs(0, mb, header, txs, false, 1234000) require.Len(t, normalTxs, 2) + require.Equal(t, uint64(1234), normalTxs[string(txHash1)].Timestamp) + require.Equal(t, uint64(1234000), normalTxs[string(txHash1)].TimestampMs) } func TestGroupInvalidTxs(t *testing.T) { @@ -92,7 +95,7 @@ func TestGroupInvalidTxs(t *testing.T) { TxHashes: [][]byte{txHash1, txHash2}, Type: block.InvalidBlock, } - header := &block.Header{} + header := &block.Header{TimeStamp: 1234} txs := map[string]*outport.TxInfo{ hex.EncodeToString(txHash1): { Transaction: &transaction.Transaction{ @@ -106,8 +109,10 @@ func TestGroupInvalidTxs(t *testing.T) { }, FeeInfo: &outport.FeeInfo{}}, } - normalTxs, _ := grouper.groupInvalidTxs(0, mb, header, txs, 3) + normalTxs, _ := grouper.groupInvalidTxs(0, mb, header, txs, 3, 1234000) require.Len(t, normalTxs, 2) + require.Equal(t, uint64(1234), normalTxs[string(txHash1)].Timestamp) + require.Equal(t, uint64(1234000), normalTxs[string(txHash1)].TimestampMs) } func TestGroupReceipts(t *testing.T) { @@ -120,7 +125,7 @@ func TestGroupReceipts(t *testing.T) { txHash1 := []byte("txHash1") txHash2 := []byte("txHash2") - header := &block.Header{} + header := &block.Header{TimeStamp: 1234} txs := map[string]*receipt.Receipt{ hex.EncodeToString(txHash1): { SndAddr: []byte("sender1"), @@ -130,6 +135,8 @@ func TestGroupReceipts(t *testing.T) { }, } - receipts := grouper.groupReceipts(header, txs) + receipts := grouper.groupReceipts(header, txs, 1234000) require.Len(t, receipts, 2) + require.Equal(t, uint64(1234), receipts[0].Timestamp) + require.Equal(t, uint64(1234000), receipts[0].TimestampMs) } diff --git a/process/elasticproc/transactions/transactionsProcessor.go b/process/elasticproc/transactions/transactionsProcessor.go index b85c9b71..93aef8e9 100644 --- a/process/elasticproc/transactions/transactionsProcessor.go +++ b/process/elasticproc/transactions/transactionsProcessor.go @@ -71,6 +71,7 @@ func (tdp *txsDatabaseProcessor) PrepareTransactionsForDatabase( pool *outport.TransactionPool, isImportDB bool, numOfShards uint32, + timestampMs uint64, ) *data.PreparedResults { err := checkPrepareTransactionForDatabaseArguments(header, pool) if err != nil { @@ -93,21 +94,21 @@ func (tdp *txsDatabaseProcessor) PrepareTransactionsForDatabase( continue } - txs, errGroup := tdp.txsGrouper.groupNormalTxs(mbIndex, mb, header, pool.Transactions, isImportDB, numOfShards) + txs, errGroup := tdp.txsGrouper.groupNormalTxs(mbIndex, mb, header, pool.Transactions, isImportDB, numOfShards, timestampMs) if errGroup != nil { log.Warn("txsDatabaseProcessor.groupNormalTxs", "error", errGroup) continue } mergeTxsMaps(normalTxs, txs) case block.RewardsBlock: - txs, errGroup := tdp.txsGrouper.groupRewardsTxs(mbIndex, mb, header, pool.Rewards, isImportDB) + txs, errGroup := tdp.txsGrouper.groupRewardsTxs(mbIndex, mb, header, pool.Rewards, isImportDB, timestampMs) if errGroup != nil { log.Warn("txsDatabaseProcessor.groupRewardsTxs", "error", errGroup) continue } mergeTxsMaps(rewardsTxs, txs) case block.InvalidBlock: - txs, errGroup := tdp.txsGrouper.groupInvalidTxs(mbIndex, mb, header, pool.InvalidTxs, numOfShards) + txs, errGroup := tdp.txsGrouper.groupInvalidTxs(mbIndex, mb, header, pool.InvalidTxs, numOfShards, timestampMs) if errGroup != nil { log.Warn("txsDatabaseProcessor.groupInvalidTxs", "error", errGroup) continue @@ -119,8 +120,8 @@ func (tdp *txsDatabaseProcessor) PrepareTransactionsForDatabase( } normalTxs = tdp.setTransactionSearchOrder(normalTxs) - dbReceipts := tdp.txsGrouper.groupReceipts(header, pool.Receipts) - dbSCResults := tdp.scrsProc.processSCRs(miniBlocks, header, pool.SmartContractResults, numOfShards) + dbReceipts := tdp.txsGrouper.groupReceipts(header, pool.Receipts, timestampMs) + dbSCResults := tdp.scrsProc.processSCRs(miniBlocks, header, pool.SmartContractResults, numOfShards, timestampMs) srcsNoTxInCurrentShard := tdp.scrsDataToTxs.attachSCRsToTransactionsAndReturnSCRsWithoutTx(normalTxs, dbSCResults) tdp.scrsDataToTxs.processTransactionsAfterSCRsWereAttached(normalTxs) diff --git a/process/elasticproc/transactions/transactionsProcessor_test.go b/process/elasticproc/transactions/transactionsProcessor_test.go index 1348e427..230c2bd6 100644 --- a/process/elasticproc/transactions/transactionsProcessor_test.go +++ b/process/elasticproc/transactions/transactionsProcessor_test.go @@ -211,7 +211,7 @@ func TestPrepareTransactionsForDatabase(t *testing.T) { txDbProc, _ := NewTransactionsProcessor(createMockArgsTxsDBProc()) - results := txDbProc.PrepareTransactionsForDatabase(mbs, header, pool, false, 3) + results := txDbProc.PrepareTransactionsForDatabase(mbs, header, pool, false, 3, 1234000) assert.Equal(t, 7, len(results.Transactions)) } @@ -267,7 +267,7 @@ func TestRelayedTransactions(t *testing.T) { txDbProc, _ := NewTransactionsProcessor(createMockArgsTxsDBProc()) - results := txDbProc.PrepareTransactionsForDatabase(mbs, header, pool, false, 3) + results := txDbProc.PrepareTransactionsForDatabase(mbs, header, pool, false, 3, 1234000) assert.Equal(t, 1, len(results.Transactions)) assert.Equal(t, 2, len(results.Transactions[0].SmartContractResults)) assert.Equal(t, transaction.TxStatusSuccess.String(), results.Transactions[0].Status) @@ -375,7 +375,7 @@ func TestCheckGasUsedInvalidTransaction(t *testing.T) { }, } - results := txDbProc.PrepareTransactionsForDatabase(mbs, header, pool, false, 3) + results := txDbProc.PrepareTransactionsForDatabase(mbs, header, pool, false, 3, 1234000) require.Len(t, results.Transactions, 1) require.Equal(t, tx1.Transaction.GetGasLimit(), results.Transactions[0].GasUsed) } @@ -505,7 +505,7 @@ func TestTxsDatabaseProcessor_PrepareTransactionsForDatabaseInvalidTxWithSCR(t * }, } - results := txDbProc.PrepareTransactionsForDatabase(mbs, header, pool, false, 3) + results := txDbProc.PrepareTransactionsForDatabase(mbs, header, pool, false, 3, 1234000) require.NotNil(t, results) require.Len(t, results.Transactions, 1) require.Len(t, results.ScResults, 1) @@ -562,7 +562,7 @@ func TestTxsDatabaseProcessor_PrepareTransactionsForDatabaseESDTNFTTransfer(t *t }, } - results := txDbProc.PrepareTransactionsForDatabase(mbs, header, pool, false, 3) + results := txDbProc.PrepareTransactionsForDatabase(mbs, header, pool, false, 3, 1234000) require.NotNil(t, results) require.Len(t, results.Transactions, 1) require.Len(t, results.ScResults, 1) @@ -626,7 +626,7 @@ func TestTxsDatabaseProcessor_IssueESDTTx(t *testing.T) { }, } - res := txDbProc.PrepareTransactionsForDatabase(mbs, header, pool, false, 3) + res := txDbProc.PrepareTransactionsForDatabase(mbs, header, pool, false, 3, 1234000) require.Equal(t, "success", res.Transactions[0].Status) require.Equal(t, 2, len(res.ScResults)) @@ -649,7 +649,7 @@ func TestTxsDatabaseProcessor_IssueESDTTx(t *testing.T) { }, } - res = txDbProc.PrepareTransactionsForDatabase(mbs, header, pool, false, 3) + res = txDbProc.PrepareTransactionsForDatabase(mbs, header, pool, false, 3, 1234000) require.Equal(t, "success", res.Transactions[0].Status) require.Equal(t, 1, len(res.ScResults)) } diff --git a/templates/indices/timestampMs.go b/templates/indices/timestampMs.go new file mode 100644 index 00000000..99f99b45 --- /dev/null +++ b/templates/indices/timestampMs.go @@ -0,0 +1,82 @@ +package indices + +// TimestampMs holds the configuration for the timestampMs field +var TimestampMs = Object{ + "properties": Object{ + "timestampMs": Object{ + "type": "date", + "format": "epoch_millis", + }, + }, +} + +// TokensTimestampMs holds the configuration for the tokens index timestampMs fields +var TokensTimestampMs = Object{ + "properties": Object{ + "timestampMs": Object{ + "type": "date", + "format": "epoch_millis", + }, + "changedToDynamicTimestampMs": Object{ + "type": "date", + "format": "epoch_millis", + }, + "ownersHistory": Object{ + "type": "nested", + "properties": Object{ + "timestampMs": Object{ + "index": "false", + "type": "date", + "format": "epoch_millis", + }, + }, + }, + }, +} + +// DelegatorsTimestampMs holds the configuration for the delegators index timestampMs fields +var DelegatorsTimestampMs = Object{ + "properties": Object{ + "timestampMs": Object{ + "type": "date", + "format": "epoch_millis", + }, + "unDelegateInfo": Object{ + "properties": Object{ + "timestampMs": Object{ + "index": "false", + "type": "date", + "format": "epoch_millis", + }, + }, + }, + }, +} + +// DeploysTimestampMs holds the configuration for the scdeploys index timestampMs fields +var DeploysTimestampMs = Object{ + "properties": Object{ + "timestampMs": Object{ + "type": "date", + "format": "epoch_millis", + }, + "upgrades": Object{ + "type": "nested", + "properties": Object{ + "timestampMs": Object{ + "type": "date", + "format": "epoch_millis", + }, + }, + }, + "owners": Object{ + "type": "nested", + "properties": Object{ + "timestampMs": Object{ + "type": "date", + "format": "epoch_millis", + }, + }, + }, + }, +}