-
Notifications
You must be signed in to change notification settings - Fork 12
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
[Miner] feat: add Miner
component
#168
Conversation
0f4cf29
to
e91ff82
Compare
e91ff82
to
175f220
Compare
175f220
to
38329bb
Compare
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.
servicetypes.Relay
is a struct, we should work with its pointer
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.
@bryanchriswhite NOT a complete review, but just a preliminary one to give early feedback.
- Fixed helpers for localnet regenesis - Added an application & supplier to the genesis file - Initializing appMap & supplierMap in E2E tests - Add support for the app's codec (for unmarshaling responses) in E2E tests - Adding a placeholder for `e2e/tests/relay.feature` --- Co-authored-by: harry <[email protected]>
* refactor: `MapFn`s receive context arg * feat: add `MapExpand` observable operator * refactor: `RelayerSessionsManager` to be more reactive * chore: add godoc comment * chore: review feedback improvements * trigger CI
pkg/relayer/miner/miner.go
Outdated
earliestCreateClaimHeight := | ||
protocol.GetEarliestCreateClaimHeight(createClaimWindowStartBlock) | ||
|
||
log.Printf("earliest claim submission createClaimWindowStartBlock height for this supplier: %d", earliestCreateClaimHeight) |
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.
So are we going to have a bunch of blocking calls to this at any point in time?
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.
There will be blocking calls made in map functions to delay downstream notifications to happen at precise times.
b38aa81
to
efb8a4e
Compare
MinedRelays( | ||
ctx context.Context, | ||
servedRelayObs observable.Observable[*servicetypes.Relay], | ||
) (minedRelaysObs observable.Observable[*MinedRelay]) |
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.
UNRELATED OPTION NIT: Thoughts on adding a TODO_TECHDEBT: Add the Obs suffix to all Observables in the codebase
.
Might be worthing putting it in observable.go
if you also agree that it's the right pattern to follow.
pkg/relayer/interface.go
Outdated
EnsureSessionTree(sessionHeader *sessiontypes.SessionHeader) (SessionTree, error) | ||
// IncludeRelays receives an observable of relays that should be included | ||
// in their respective session's SMST (tree). | ||
IncludeRelays(relayObs observable.Observable[*MinedRelay]) |
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.
Thoughts on this rename?
IncludeRelays(relayObs observable.Observable[*MinedRelay]) | |
ClaimRelays(minedRelaysObs observable.Observable[*MinedRelay]) |
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.
My hesitation with ClaimRelays
is that while claming is a consequence of having relays in the SMST by a certain time, that's something that happens as an indirect consequence of IncludeRelays
. What this method does directly is insert the observed relays in to the respective session's SMST. Start
is where the observable mapping happens such that claims and proofs are created/submitted.
What about InsertRelays
?
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.
pkg/relayer/interface.go
Outdated
// network as necessary. | ||
Start(ctx context.Context) | ||
|
||
// Stop unsubscribes all observables from the RelaysToInclude observable which |
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 couldn't find RelaysToInclude
so should this be minedRelaysObs
if we rename the parameter above appropriatelY?
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.
Nice catch, thanks! The method was renamed to IncludeRelays
. It's defined on the RelayerSessionManger
interface and receives minedRelaysObs
. I intentionally avoided referencing mining on that side of the RelayerSessionManager
interface because it doesn't need to know anything about mining other than the fact that the MinedRelay
provides bytes
and hash
fields (which could be replaced with and interface in future refactoring).
@bryanchriswhite All of my comments are only related to naming, comment updates, etc... Overall, great work and thank you for iterating on top of yesterday's feedback. I feel like this is MUCH MUCH easier to read and understand! |
Co-authored-by: Daniel Olshansky <[email protected]>
Co-authored-by: Daniel Olshansky <[email protected]>
Co-authored-by: Daniel Olshansky <[email protected]>
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.
LGTM! Splitting responsibilities this way makes it way easier to reason about.
I'll base RelayMiner
on this work.
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.
* pokt/relayer/cli: [AppGate] Implement the MVP AppGateServer (#108) chore: Improve comment about startig relayer proxy [Relayer] feat: Add Relayer struct (#172) feat: Use relay miner to start chore: Reflect responsibility changes of session manager [Miner] feat: add `Miner` component (#168) fix: Update Miner interface chore: update start mining comment chore: Remove unused RelayerOption parameter chore: Rename relay miner file chore: Rename to RelayMiner feat: Add Relayer struct
* refactor: `MapFn`s receive context arg * chore: add `ForEach` map shorthand operator * chore: add `/pkg/observable/filter` * chore: add `/pkg/observable/logging` * chore: add `/pkg/relayer/protocol` * chore: add `Miner` interface * feat: add `Miner` implementation * test: `Miner` implementation * chore: fix comment * chore: add godoc comments * [Test] First step for automated E2E Relay test (#167) - Fixed helpers for localnet regenesis - Added an application & supplier to the genesis file - Initializing appMap & supplierMap in E2E tests - Add support for the app's codec (for unmarshaling responses) in E2E tests - Adding a placeholder for `e2e/tests/relay.feature` --- Co-authored-by: harry <[email protected]> * [Relayer] refactor: simplify `RelayerSessionsManager` (#169) * refactor: `MapFn`s receive context arg * feat: add `MapExpand` observable operator * refactor: `RelayerSessionsManager` to be more reactive * chore: add godoc comment * chore: review feedback improvements * trigger CI * chore: review feedback improvements Co-authored-by: Daniel Olshansky <[email protected]> * chore: review feedback improvements * fix: import cycle & goimports * chore: review feedback improvements * chore: cleanup TODO_THIS_COMMIT comments * chore: improve var & func names for clarity and consistency * refactor: move claim/proof lifecycle concerns to `relayerSessionsManager`. * chore: review feedback improvements * chore: review feedback improvements * refactor: `miner#hash()` method * chore: tidy up * chore: simplify * chore: review feedback improvements Co-authored-by: Daniel Olshansky <[email protected]> * chore: review feedback improvements Co-authored-by: Daniel Olshansky <[email protected]> * chore: review feedback improvements Co-authored-by: Daniel Olshansky <[email protected]> * chore: review feedback improvements * chore: review feedback improvements * fix: incomplete refactor * chore: simplify --------- Co-authored-by: Daniel Olshansky <[email protected]> Co-authored-by: harry <[email protected]>
Summary
Human Summary
Ports and refactors the
Miner
component from poktroll-alpha.AI Summary
Summary generated by Reviewpad on 10 Nov 23 20:30 UTC
This pull request includes the following changes:
The
interface.go
file in thepkg/relayer
package has been modified to add a new import statement and several interface definitions and updates. These changes are related to the implementation of the relayer's session lifecycles and the introduction of a new miner interface.A new file named "miner.go" has been added in the "pkg/relayer/miner" directory. This file defines a package called "miner" and includes the implementation of the
relayer.Miner
interface. It also contains some utility functions and a constructor for creating a new miner.The
relayerSessionsManager
struct, defined in a separate file, has been modified to include a new field,relayObs
, of typeobservable.Observable[*relayer.MinedRelay]
. The struct also includes methods for managing the relayer's session lifecycles, such as starting and stopping sessions, inserting relays, and ensuring the session tree.Another file named "claim.go" has been added in the
pkg/relayer/session
package. This file defines therelayerSessionsManager
struct and includes methods for creating claims for relayer sessions. These methods use observables to handle asynchronous operations and error handling.A new file named "miner_test.go" has been added in the
pkg/relayer/miner
package. This file includes a single test function that is currently skipped, indicating that more test coverage needs to be added for the miner implementation.The
types.go
file in thepkg/relayer
package has been modified to introduce a new struct calledMinedRelay
, which is a wrapper around a serialized and hashed relay. This struct contains two fields,Bytes
andHash
, which are of type[]byte
.The
types.go
file in thepkg/either
package has been modified to add a new import statement and update theSessionTree
type, which is now anEither
type wrappingrelayer.SessionTree
. Some type aliases have also been reformatted for clarity.A new file named "difficulty.go" has been added in the
pkg/relayer/protocol
directory. This file includes the implementation of a function that checks if a given byte slice exceeds a specified difficulty. This function is used to determine if a relay is volume applicable.These changes are related to the implementation of the relayer's session lifecycles, the introduction of a new miner interface, and the handling of relay claims and proofs. Some areas, such as test coverage and algorithm optimization, have been identified for future improvements.
Please let me know if you need any further assistance!
Issue
Adds the miner component.
Type of change
Select one or more:
Testing
make go_develop_and_test
Sanity Checklist