-
Notifications
You must be signed in to change notification settings - Fork 440
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 timeboosted information to broadcast feed #2695
base: express-lane-timeboost
Are you sure you want to change the base?
Add timeboosted information to broadcast feed #2695
Conversation
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.
Overall it looks good, just a few comments.
broadcaster/message/message.go
Outdated
maxTxCount := (len(m.Timeboosted) - 1) * 8 | ||
if txIndex >= maxTxCount { | ||
return false | ||
} | ||
return m.Timeboosted[1+(txIndex/8)]&(1<<(txIndex%8)) != 0 |
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 think it's worth making a special type for the []byte
representing Timeboosted to encapsulate this functionality.
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 think the idea behind the versioning is that what we're storing in this byte buffer is supposed to be block metadata which may grow to include more things than just whether txs were timeboosted or not. See NIT-2779. So it should be called block metadata or something similar, and schema.go should change too.
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.
Agreed, fixed 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.
What I mean is having the logic for checking if a tx is timeboosted being a function on the type you currently have called Timeboosted
(which should probably also be called BlockMetadata
. This goes for anywhere the is logic that cares about the bitwise representation of the block metadata.
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.
Ahh that makes a lot of sense, i'll rename the type and have the func defined on that
This PR adds a new field
blockMetadata
to theBroadcastFeedMessage
struct that represents whether a particular transaction in the block was time-boosted or not.The field
blockMetadata
is an array of bytes and it starts with a 0 (version) followed by ceil(N/8) number of bytes where N is the number of txs in the block. Basicallyn
th bit of thek
th byte of blockMetadata byte array represents the status of8*(k-1)+(n+1)
th transaction, if its 1 means the tx was timeboosted else it wasn't.Example: if blockMetadata array viewed as bits is
00000000 01100101
then 2nd, 3rd, 6th and 8th transactions in the block were timeboosted.Resolves NIT-2779