-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Hyperblock coordinates in GetTxByHash() #2226
Conversation
Capacity = 20000 | ||
Type = "LRU" | ||
[FullHistory.HashEpochStorageConfig.DB] | ||
[FullHistory.MiniblockHashByTxHashStorageConfig.DB] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if we use the INDEXER interface in order to save all kinds of mapping like this? The node would work the same with the same storage and data, but the saved transaction structure in case of indexer would have all this metadata ? Not for current PR, but for the long term. food for taught.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, as discussed, we have to do that on the long term.
} | ||
|
||
func newErrCannotSaveMiniblockMetadata(hash []byte, originalErr error) error { | ||
return fmt.Errorf("cannot save miniblock metadata, hash [%s]: %w", hex.EncodeToString(hash), originalErr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you really need this errors ? returning original err is not enough ? keep it simple
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to have some correlation info in case there's an issue. Can we keep them for the moment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is really low possibility for this to happen
@@ -56,11 +56,12 @@ func (hpf *historyRepositoryFactory) Create() (fullHistory.HistoryRepository, er | |||
} | |||
|
|||
historyRepArgs := fullHistory.HistoryRepositoryArguments{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is fullHistory in the core package ? it should not be here. core is only for simple stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. Will be moved in a future PR.
if err != nil { | ||
return fmt.Errorf("cannot save in storage history transaction %w", err) | ||
return newErrCannotSaveMiniblockMetadata(hash, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just return a constant error here - no need to add hash. this will never happen. keep it simple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to have some correlation info in case there's an issue. Can we keep it for the moment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i do not see this usable - it is pretty impossible for this to happen.
return hp.epochByHashIndex.getEpochByHash(hash) | ||
} | ||
|
||
func (hp *historyProcessor) RegisterToBlockTracker(blockTracker BlockTracker) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add comment to public function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
metaBlock, ok := header.(*block.MetaBlock) | ||
if !ok { | ||
// Question for review: why, on every round, there's a header of type = *block.Header (even if shardID = metachain)? | ||
log.Debug("onNotarizedBlocks(): cannot convert to *block.Metablock", "type", fmt.Sprintf("%T", header)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete this log - no need for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
return | ||
} | ||
|
||
for i := 0; i < len(headers); i++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for i, header := range headers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
return | ||
} | ||
|
||
log.Trace("onNotarizedBlocks()", "index", i, "len(ShardInfo)", len(metaBlock.ShardInfo)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really need these log trace's ? if they will not be used, delete them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
} | ||
|
||
func (hp *historyProcessor) onNotarizedBlock(metaBlockNonce uint64, metaBlockHash []byte, blockHeader block.ShardData) { | ||
log.Trace("onNotarizedBlock()", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logging this data already exist - please delete
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
storer storage.Storer | ||
} | ||
|
||
func newMiniblockHashByTxHashIndex(storer storage.Storer) *miniblockHashByTxHashIndex { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no need for this class. this in only a storer. Add a named variable which says miniblockByHashIndexStorer and you are fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, removed.
…ond-go into hyperblock-coordinates
1e441f4
899e8b1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
System tests passed
miniblock metadata
storage (used for API). These extra fields refer to the metablock that included the miniblock in question at source / at destination.NotarizedAtDestinationInMeta*
are used to populate the hyperblock coordinates at proxy-side.invalidBlock
)How to test:
/transaction/abracadabra
, and inspect the fields:Limitations:
cannot populateFixed.NotarizedAtSourceInMetaNonce / NotarizedAtSourceInMetaHash
when running in destination shard if the notification of "notarized at source" comes before committing the block (at destination) - since there will be no miniblock metadata in the storer yet. Can be easily fixed though.