-
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
Handle transactions towards metachain in DbLookupExtensions #2256
Conversation
data/transaction/status.go
Outdated
TransactionData []byte | ||
SelfShard uint32 | ||
MiniblockType block.Type | ||
IsMiniblockFullyNotarized bool |
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.
IsMiniblockFinalized ?
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.
@sasurobert Isn't the block finalized only at n+1 ?
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.
IsMiniBlockFully notarized is for when even the destination processes the miniblock and the result of the process is finalized, included on meta, and meta is finalized.
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.
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.
@@ -228,27 +239,45 @@ func (hr *historyRepository) onNotarizedBlocks(shardID uint32, headers []data.He | |||
for i, header := range headers { | |||
headerHash := headersHashes[i] | |||
|
|||
metaBlock, ok := header.(*block.MetaBlock) | |||
if !ok { | |||
asMetaBlock, isMetaBlock := header.(*block.MetaBlock) |
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.
metaBlock, isMetaBlock
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.
Renamed.
return | ||
} | ||
|
||
for _, shardData := range metaBlock.ShardInfo { | ||
hr.onNotarizedBlock(metaBlock.GetNonce(), headerHash, shardData) | ||
asBlock, isBlock := header.(*block.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.
header, isHeader
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.
Renamed.
hr.onNotarizedBlock(metaBlock.GetNonce(), headerHash, shardData) | ||
asBlock, isBlock := header.(*block.Header) | ||
if isBlock { | ||
if asBlock.GetShardID() != core.MetachainShardId { |
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.
This condition is always true
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 then.
if isMetaBlock { | ||
for _, shardData := range asMetaBlock.ShardInfo { | ||
hr.onNotarizedInMetaBlock(asMetaBlock.GetNonce(), headerHash, &shardData) | ||
} | ||
return |
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.
You don't need to iterate the whole list ?
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.
@SebastianMarian, not sure what you mean - we iterate on the whole list of ShardInfo
s. What is not needed, it's discarded in onNotarizedMiniblock
, of course - see logic around iDontCare
.
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 referred to the whole list of headers, as you call return after the iteration of all the shardData from first headerHandler. It is ok ? I mean that this return should not be replaced with continue ?
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.
Oh, now I see. Will fix.
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.
continue | ||
} | ||
|
||
hr.onNotarizedInRegularBlockOfMeta(asMetaBlock.GetNonce(), headerHash, asBlock) |
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.
asBlock instead asMetaBlock? asMetaBlock will be nil and the code will panic here if asBlock is not nil and isBlock is true
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.
Good catch 🥳
My unit test was hiding that - see what I've changed there 🤯
(wasn't panicking, it returned 0 - also hidden in our system tests, because we were looking at destination for hyperblock coordinates, at source they would have been bad, nonce = 0)
} | ||
} | ||
|
||
func (hr *historyRepository) onNotarizedBlock(metaBlockNonce uint64, metaBlockHash []byte, blockHeader block.ShardData) { | ||
func (hr *historyRepository) onNotarizedInMetaBlock(metaBlockNonce uint64, metaBlockHash []byte, blockHeader *block.ShardData) { |
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.
shardData instead blockHeader
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.
Renamed.
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.
if tx, ok := txObj.(*transaction.Transaction); ok { | ||
return n.prepareNormalTx(tx) | ||
} | ||
case transaction.TxTypeInvalid: | ||
if tx, ok := txObj.(*transaction.Transaction); ok { | ||
return n.prepareInvalidTx(tx) |
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.
👍
74484ea
The metachain directly notarizes miniblocks towards it - at commit block time. Therefore, there's the time to set the hyperblock coordinates for the miniblocks in question. At the source shard, the "block notarized" notifications arrive in a slightly different manner - the payload is a
block.Header
, not ablock.MetaBlock
.Therefore,
nodeTransactions.go
unsigned
transactions (e.g. return message, original transaction hash)DatabaseLookupExtensions
are enabled (that is, returnexecuted
if hyperblock coordinates are fully set, that is, if parent miniblock is fully notarized)DatabaseLookupExtensions
, and miniblock metadata is present.How to test: