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

V2 #14

Open
wants to merge 125 commits into
base: main
Choose a base branch
from
Open

V2 #14

wants to merge 125 commits into from

Conversation

dbrajovic
Copy link
Contributor

@dbrajovic dbrajovic commented Sep 6, 2023

Description

Major refactor of the module.

  • 3 packages: sequencer message engine
  • client interfaces greatly simplified (root packageibft.go file)

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)

Breaking changes

Everything

Checklist

  • I have assigned this PR to myself
  • I have added at least 1 reviewer
  • I have added the relevant labels
  • I have added sufficient documentation in code

@dbrajovic dbrajovic self-assigned this Mar 11, 2024
Base automatically changed from fix/audit to main December 27, 2024 12:19
@zivkovicmilos zivkovicmilos marked this pull request as ready for review December 30, 2024 13:12
Copy link
Member

@zivkovicmilos zivkovicmilos left a 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 🙏

}

// Keccak hash engine for arbitrary input
type Keccak interface {
Copy link
Member

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)
Copy link
Member

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

},

{
expectedErrStr: "ok",
Copy link
Member

Choose a reason for hiding this comment

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

Please drop this pattern :)

// 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
Copy link
Member

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

Feed message.Feed
Keccak message.Keccak
SignatureVerifier message.SignatureVerifier
Round0Duration time.Duration
Copy link
Member

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

Copy link
Member

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) {
Copy link
Member

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

}

// SignMsg returns msg with updated Signature field
func SignMsg[M IBFTMessage](msg M, signer Signer) M {
Copy link
Member

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

Copy link
Member

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

}

// WrapMessages wraps concrete message types into Message type
func WrapMessages[M IBFTMessage](messages ...M) []Message {
Copy link
Member

Choose a reason for hiding this comment

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

Thank you golang

Subscription[M IBFTMessage] chan MsgNotification[M]
)

func (r MsgNotificationFn[M]) Unwrap() []M {
Copy link
Member

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?

Copy link
Member

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
Copy link
Member

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

@zivkovicmilos
Copy link
Member

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants