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

Break out chainio and crypto #805

Merged
merged 3 commits into from
Oct 17, 2024

Conversation

mooselumph
Copy link
Collaborator

Why are these changes needed?

Breaks out chainio and crypto from the core library?

Checks

  • I've made sure the lint is passing in this PR.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, in that case, please comment that they are not relevant.
  • I've checked the new test coverage and the coverage percentage didn't drop.
  • Testing Strategy
    • Unit tests
    • Integration tests
    • This PR is not tested :(

@mooselumph mooselumph changed the title Add chainio and crypto Break out chainio and crypto Oct 14, 2024
@mooselumph mooselumph mentioned this pull request Oct 14, 2024
6 tasks
Copy link
Contributor

@hopeyen hopeyen left a comment

Choose a reason for hiding this comment

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

💯

chainio/eth/reader.go Show resolved Hide resolved
chainio/eth/reader.go Show resolved Hide resolved
chainio/eth/reader.go Outdated Show resolved Hide resolved
}

// ChainState is an interface for getting information about the current chain state.
type IndexedChainState interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering why IndexedOperatorState and IndexedChainState would be under indexer.go instead of state.go. Maybe we could rename this file to indexed.go?

chainio/types.go Show resolved Hide resolved
Tx core.Transactor
}

func NewChainState(tx core.Transactor, client common.EthClient) *ChainState {
Copy link
Contributor

Choose a reason for hiding this comment

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

Have we thought about just moving these methods to reader? These are just thin wrapper over operator state onchain?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'd like to do this, but could we do it in a follow-up PR?


type ChainState struct {
Client common.EthClient
Tx core.Transactor
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use reader instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated

Comment on lines 33 to 35
EthClient common.EthClient
Logger logging.Logger
Bindings *ContractBindings
Copy link
Contributor

Choose a reason for hiding this comment

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

should these be private?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed to private


func NewReader(
logger logging.Logger,
client common.EthClient,
Copy link
Contributor

Choose a reason for hiding this comment

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

As we're separating reader & writer, one thing that would be nice to handle is how eth client is set up. Configuring private key in eth client is bit awkward right now. Definitely out of scope of this PR, but we could probably enforce that the client doesn't have pk configured in reader (and vice versa for writer)

@@ -0,0 +1,203 @@
package bn254
Copy link
Contributor

Choose a reason for hiding this comment

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

is this just copy paste of existing logic or is there logic changes here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

copy paste from core. We can clean up in future PR.

Comment on lines +9 to +18
const (
// We use uint8 to count the number of quorums, so we can have at most 255 quorums,
// which means the max ID can not be larger than 254 (from 0 to 254, there are 255
// different IDs).
MaxQuorumID = 254
)

type QuorumID = uint8

type OperatorID = [32]byte
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like these types (and helper methods) should belong somewhere outside than chainio. Why do we want to redefine them outside existing core package?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Where should they be defined? Currently, core/v2 depends on chainio for operator state types, and chainio is meant to depend only on chain bindings.

We could potentially reverse the ordering, but thi is inconvenient because it means core can use the chainio objects. Any other ideas?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Conceptually, I thought it made sense for chainio to depend on core, but I guess the argument can be made the other way too. I'm fine either way.
It's bit confusing having the same types (OperatorID, QuorumID) defined again here though, in addition to the existing core. Is having this duplicate type perferred over reusing core.OperatorID?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These are simply type aliases, not type definitions. I'm using this just as a tool for maintaining easy consistency and upgradeability within this package. From that perspective, I wonder if it is less confusing?

I'd prefer not to have any dependencies on core as this will be deprecated.

@mooselumph mooselumph merged commit 8a67143 into Layr-Labs:master Oct 17, 2024
7 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