-
Notifications
You must be signed in to change notification settings - Fork 0
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
V2 #14
base: main
Are you sure you want to change the base?
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 solid ✅
I think you got a bit carried away with the generics, and we ended up complicating things that didn't need to be complicated.
Please see the comments, and we can merge after resolving them 🙏
message/message.go
Outdated
} | ||
|
||
// Keccak hash engine for arbitrary input | ||
type Keccak interface { |
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 doesn't have to be a custom interface, we can keccak internally
func (s *MsgStore) Add(m message.Message) error { | ||
info := m.GetInfo() | ||
if info == nil { | ||
return fmt.Errorf("%w: missing info field", ErrInvalidMessage) |
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 not have these as custom errors instead of wrapping ErrInvalidMessage
every time?
It forces custom parsing on the caller side
message/store/store_test.go
Outdated
}, | ||
|
||
{ | ||
expectedErrStr: "ok", |
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.
Please drop this pattern :)
message/message.go
Outdated
// Signer is identified by its Address and used to generate signature for arbitrary payload | ||
type Signer interface { | ||
// Address returns the public ID of Signer | ||
Address() []byte |
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'm not entirely convinced it should be in the Signer
interface. If we can move it, then Sign
can just be a callback instead of an abstraction
sequencer/options.go
Outdated
Feed message.Feed | ||
Keccak message.Keccak | ||
SignatureVerifier message.SignatureVerifier | ||
Round0Duration time.Duration |
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 should have a default instead of being required to be specified explicitly
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.
We can just configure it through an option
return bz | ||
} | ||
|
||
func (rcc *RoundChangeCertificate) HighestRoundBlock() ([]byte, uint64) { |
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.
Having this here feels random
message/message.go
Outdated
} | ||
|
||
// SignMsg returns msg with updated Signature field | ||
func SignMsg[M IBFTMessage](msg M, signer Signer) M { |
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 this insane indirection.
You generate the message signature when you want to send the message, and you have custom handlers for each message type (broadcasts)...why not just define a method on the message type called SignaturePayload
and pipe it into the Sign
function, inside those custom message type multicast funcs
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 function is literally called from those very same handlers where you know the exact message type, and yet there is typecasting here -- useless
message/message.go
Outdated
} | ||
|
||
// WrapMessages wraps concrete message types into Message type | ||
func WrapMessages[M IBFTMessage](messages ...M) []Message { |
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.
Thank you golang
message/message.go
Outdated
Subscription[M IBFTMessage] chan MsgNotification[M] | ||
) | ||
|
||
func (r MsgNotificationFn[M]) Unwrap() []M { |
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 do we need this?
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.
Asking because the subscription already has type information on what it should return
@@ -59,15 +59,13 @@ linters: | |||
- gocheckcompilerdirectives # Checks that compiler directive comments (//go:) are valid | |||
- gochecknoinits # Checks for init methods | |||
- whitespace # Tool for detection of leading and trailing whitespace | |||
- wsl # Forces you to use empty lines |
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.
Please bring back this + nlreturn
We can configure wsl
if it's too noisy
I won't block the PR for the following reason, but I think we did one downgrade in terms of v1, which is the removal of full cluster tests (arbitrary cluster sizes) |
Description
Major refactor of the module.
sequencer
message
engine
ibft.go
file)Changes include
Breaking changes
Everything
Checklist