New timestamp field in all structures#345
Conversation
# Conflicts: # go.mod # go.sum
| Size: int64(blockSizeInBytes), | ||
| SizeTxs: int64(sizeTxs), | ||
| Timestamp: time.Duration(obh.Header.GetTimeStamp()), | ||
| TimestampMs: time.Duration(obh.OutportBlock.BlockData.TimestampMs), |
There was a problem hiding this comment.
| TimestampMs: time.Duration(obh.OutportBlock.BlockData.TimestampMs), | |
| TimestampMs: time.Duration(obh.OutportBlock.BlockData.GetTimestampMs()), |
?
process/elasticproc/interface.go
Outdated
| SerializeSCRs(scrs []*data.ScResult, buffSlice *data.BufferSlice, index string, shardID uint32) error | ||
| } | ||
|
|
||
| // TemplatesAndPoliciesHandler defines the actions that a templates and policies handler should do |
There was a problem hiding this comment.
| // TemplatesAndPoliciesHandler defines the actions that a templates and policies handler should do | |
| // TemplatesAndPoliciesHandler defines the actions that a templates and policies handler should do |
| "properties": Object{ | ||
| "timestampMs": Object{ | ||
| "type": "date", | ||
| "format": "epoch_millis", |
There was a problem hiding this comment.
what epoch_millis means here? could have been header_millis?
There was a problem hiding this comment.
epoch_millis in Elasticsearch means:
The date is stored and interpreted as the number of milliseconds since the Unix epoch (i.e., since 1970-01-01T00:00:00Z). (it's an Elasticsearch format for date )
|
|
||
| var TokensTimestampMs = Object{ |
There was a problem hiding this comment.
add comments to the other fields in this file
|
|
||
| // 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(timestamp uint64, accounts []*data.Account, shardID uint32, timestampMs uint64) map[string]*data.AccountInfo { |
There was a problem hiding this comment.
i'm thinking if it might work to pass only timestampMs and get old timestamp as timestampMs/1000 when needed, since we care about ms granularity now and we can get seconds granularity from milliseconds
There was a problem hiding this comment.
in order to avoid passing kind of duplicated variables
There was a problem hiding this comment.
and this can be applied to all other places if suitable
| // GetTimestampMsMappings will return the timestampMs field mappings for all indices | ||
| func (tr *templatesAndPolicyReader) GetTimestampMsMappings() ([]templates.ExtraMapping, error) { |
There was a problem hiding this comment.
this function is needed to add the new timestampMS mappings for already existing indices.
| Index: indexer.EventsIndex, | ||
| Mappings: indices.TimestampMs.ToBuffer(), | ||
| }, | ||
|
|
There was a problem hiding this comment.
delete empty line
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new timestampMs field (milliseconds) alongside existing timestamp fields across all data structures and updates related tests and fixtures to use these values.
- Added
timestampMsto JSON test fixtures and data models, replacingtime.Durationwithuint64fortimestamp - Updated integration tests to pass millisecond timestamps to new methods
- Bumped
mx-chain-core-godependency version
Reviewed Changes
Copilot reviewed 160 out of 160 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| integrationtests/testdata/accountsBalanceWithLowerTimestamp/account-balance-esdt-second-update.json | Add timestampMs to fixture |
| integrationtests/testdata/accountsBalanceWithLowerTimestamp/account-balance-esdt-first-update.json | Add timestampMs to fixture |
| integrationtests/testdata/accountsBalanceNftTransfer/balance-nft-after-transfer.json | Add timestampMs to fixture |
| integrationtests/testdata/accountsBalanceNftTransfer/balance-nft-after-create.json | Add timestampMs to fixture |
| integrationtests/miniblocks_test.go | Pass millisecond timestamp to SaveMiniblocks |
| integrationtests/logsCrossShard_test.go | Pass millisecond timestamp to RemoveTransactions |
| integrationtests/delegators_test.go | Pass millisecond timestamp to RemoveTransactions |
| integrationtests/accountsESDTRollback_test.go | Update RemoveAccountsESDT call with ms timestamp |
| integrationtests/accountsBalanceNftTransfer_test.go | Set TimestampMs in block creation helper |
| go.mod | Bump mx-chain-core-go version |
| data/transaction.go | Change Timestamp type; add TimestampMs |
| data/tokens.go | Change Timestamp type; add TimestampMs |
| data/scresult.go | Change Timestamp type; add TimestampMs |
| data/scDeploy.go | Add TimestampMs to ScDeployInfo and Upgrade |
| data/logs.go | Change Timestamp type; add TimestampMs |
| data/event.go | Change Timestamp type; add TimestampMs |
| data/delegators.go | Change Timestamp type; add TimestampMs |
| data/data.go | Change Timestamp type; add TimestampMs |
| data/block.go | Change Timestamp type; add TimestampMs |
| data/account.go | Change Timestamp type; add TimestampMs |
Comments suppressed due to low confidence (1)
integrationtests/accountsESDTRollback_test.go:94
- It looks like the arguments to
RemoveAccountsESDThave been swapped compared to the original call (timestamp, shardID). Please confirm the new signature and correct the argument order.
err = esProc.RemoveAccountsESDT(2, 5040000)
| TxHash string `json:"upgradeTxHash"` | ||
| Upgrader string `json:"upgrader"` | ||
| Timestamp uint64 `json:"timestamp"` | ||
| TimestampMs uint64 `json:"timestampMs"` |
There was a problem hiding this comment.
[nitpick] The TimestampMs field in Upgrade lacks the omitempty JSON tag, which causes zero values to always be serialized. Consider adding omitempty for consistency with other timestamp fields.
| TimestampMs uint64 `json:"timestampMs"` | |
| TimestampMs uint64 `json:"timestampMs,omitempty"` |
| }, | ||
| } | ||
| err = esProc.SaveMiniblocks(header, miniBlocks) | ||
| err = esProc.SaveMiniblocks(header, miniBlocks, 1234000) |
There was a problem hiding this comment.
[nitpick] This test uses a hardcoded millisecond value (1234000). To prevent mismatches if header.TimeStamp changes, consider computing it with header.TimeStamp * 1000.
| err = esProc.SaveMiniblocks(header, miniBlocks, 1234000) | |
| err = esProc.SaveMiniblocks(header, miniBlocks, header.TimeStamp*1000) |
timestampMsin all structures