Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed proto definition along with converting system. #24

Merged
merged 12 commits into from
Aug 7, 2024

Conversation

cristure
Copy link

No description provided.

@cristure cristure self-assigned this Jul 12, 2024
@cristure cristure marked this pull request as draft July 12, 2024 12:02
@cristure cristure marked this pull request as ready for review July 18, 2024 17:03
@cristure cristure marked this pull request as draft July 18, 2024 17:04
@cristure cristure marked this pull request as ready for review July 25, 2024 16:11
string NotarizedHeaderHash = 1;
ShardOutportBlock OutportBlock = 2 ;
string NotarizedHeaderHash = 1;
ShardOutportBlock OutportBlock = 2;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we need to reference ShardOutportBlockV2 here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, changed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chenged back. let's keep the structure untouched for now, and actually remove versioning for the shardblocks altogether in a separate PR. What do you think?

@@ -13,3 +13,14 @@ func (x *ShardOutportBlock) GetHeaderNonce() (uint64, error) {

return x.BlockData.Header.Nonce, nil
}

func (y *ShardOutportBlockV2) GetHeaderNonce() (uint64, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add missing comment

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we can remove the structs that will not be used anymore

Comment on lines 71 to 73
if err != nil {
panic(err)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use instead require.Nil(t, err)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same to all other places where panic is used

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, sorry for that. leftovers when I was testing ad-hoc.

IntraShardMiniBlocks: intraShardMiniBlocks,
}

var err error
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need to declare this error variable here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right. removed

}

func (o *outportBlockConverter) handleBlockData(blockData *outport.BlockData, shardOutportBlock *hyperOutportBlocks.ShardOutportBlockV2) error {
if blockData == nil {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a case where blockData can be nil? if yes, shouldn't we return an error if that's happending, instead of returning nil?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember why I put that check. But I'll switch to error.

@@ -184,6 +760,24 @@ func (o *outportBlockConverter) castBigInt(i *big.Int) ([]byte, error) {
return buf, err
}

func copyMiniBlocks(sourceMiniBlocks []*block.MiniBlock) []*hyperOutportBlocks.MiniBlock {
var destMiniBlocks []*hyperOutportBlocks.MiniBlock
if sourceMiniBlocks != nil {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need this nil check, ranging over sourceMiniBlocks will "treat" the nil case

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, but if they are not nil but empty, the destMiniBlock will be nil instead of empty.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but if you remove also L764, i think it will be fine; or maybe you can init like make([]*hyperOutportBlocks.MiniBlock, len(sourceMiniBlocks)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if I init, I won't have parity between the two, since the initialized will never be nil, even though the source is nil.

Comment on lines 124 to 125
shardBlockData.Header = &hyperOutportBlocks.Header{}
header := shardBlockData.Header
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can construct header variable at first, and the set to shardBlockData.Header, no need to set empty header first and then reference the header with a new variable

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional suggestion: set simple fields directly when creating new header variable &hyperOutportBlocks.Header{} and set slices later on

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same applies to handleShardV2

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done,

destTxInfo := &hyperOutportBlocks.TxInfoV2{}

// TxInfo - Transaction
if txInfo.Transaction != nil {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert if condition to avoid indentation? if transaction == nil --> continue

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea.

@@ -40,6 +42,347 @@ func NewOutportBlockConverter(
}, nil
}

func (o *outportBlockConverter) HandleShardOutportBlockV2(outportBlock *outport.OutportBlock) (*hyperOutportBlocks.ShardOutportBlockV2, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comments for exported methods

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added.

@cristure cristure requested a review from ssd04 August 7, 2024 14:27
@cristure cristure merged commit 8f76917 into feat/hyperblock Aug 7, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants