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

feat/refactor: Multi-Provider improvements #842

Merged
merged 19 commits into from
Sep 29, 2021
Merged

Conversation

anna-carroll
Copy link
Contributor

@anna-carroll anna-carroll commented Sep 24, 2021

Closes #835 #827 #815

@anna-carroll anna-carroll added the typescript Typescript dev work required label Sep 24, 2021
@anna-carroll anna-carroll self-assigned this Sep 24, 2021
@anna-carroll anna-carroll linked an issue Sep 24, 2021 that may be closed by this pull request
@prestwich
Copy link
Contributor

Initially it was instantiated from an event. The reason I changed it to be instantiated from a receipt was to preserve blockheight, and other tx confirmation info. Does this PR preserve those?

@anna-carroll
Copy link
Contributor Author

anna-carroll commented Sep 27, 2021

you know what, i will just pass in the event and the transaction receipt

@anna-carroll anna-carroll changed the title refactor: instantiate OpticsMessage with event instead of transaction receipt feat/refactor: Multi-Provider improvements Sep 27, 2021
This was linked to issues Sep 27, 2021
@ErinHales
Copy link
Contributor

Going to look over this first thing after I get some coffee, but wanted to say thanks for stepping in here. Absolutely incredible 🌸

};
}

export async function getRichEvents(context: OpticsContext, nameOrDomain: string | number, contract: BaseContract, logFilter: TypedEventFilter<any, any>, startBlock?: number, endBlock?: number): Promise<Array<RichEvent>> {
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 module-level functions, seems like they ought to be methods on the MultiProvider or OpticsContext?

const POLYGON_FIRST_BLOCK = 18895794;
const POLYGON_MAX_BLOCKS = 2500;

export async function getPolygonEvents(context: OpticsContext, nameOrDomain: string | number, contract: BaseContract, logFilter: TypedEventFilter<any, any>, startBlock?: number, endBlock?: number): Promise<Array<Event>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

proposed additional kludge:
allow user to specify an early exit after finding a single event. E.g. a singleton: bool = false argument. this allows us to prevent crawling the entire range if we're looking for a particular event

Dispatched = 0,
Included = 1,
Relayed = 2,
Processed = 3
Copy link
Contributor

Choose a reason for hiding this comment

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

inconsistent enum declaration. either use explicit = on all elements of both enums or on just the first element of both


this.context = context;
async homeUpdateEvent(): Promise<UpdateEvent | undefined> {
Copy link
Contributor

Choose a reason for hiding this comment

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

need to note in docs that this function may produce false positives, if the updater has signed an update on the committedRoot that does not include this message. these should be uncommon in practice. The only way to know for sure is to keep an indexed set of updates and leaves :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah shoot, you are right.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ugh.

@prestwich
Copy link
Contributor

@anna-carroll please put me out of my misery and/or review this PR

Copy link
Contributor

@yourbuddyconner yourbuddyconner left a comment

Choose a reason for hiding this comment

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

I want to use this.

Please add .env to .gitignore.

@prestwich
Copy link
Contributor

-_-

refactor: make event queries rely on ethers type system

refactor: generic Annotated type

refactor: improve event cache in Optics message

refactor: non-looping array concat

refactor: use Annotated events for message instantiation

refactor: add concurrency limit to paginated event retrieval

refactor: break up annotate and rely on event.getTransactionReceipt

refactor: use annotated lifecycle events throughout

refactor: break out events into a folder

bug: check for id, not domain

bug: check for id, not domain (again)

bug: check for id, not domain (again)

Revert "bug: check for id, not domain (again)"

This reverts commit 8304985.

bug: pass through signer in fromObject

bug: improper fromObject checking re: domain

refactor: break trace out into its own package

remove .env
@prestwich
Copy link
Contributor

merging as it's blocking GUI work. can fix up anything in separate PRs

@prestwich prestwich merged commit c146d76 into main Sep 29, 2021
Copy link
Contributor Author

@anna-carroll anna-carroll left a comment

Choose a reason for hiding this comment

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

looking beautiful 😭 thank you @prestwich

@@ -1,4 +1,10 @@
export interface Pagination {
blocks: number;
from: number;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we could have a from block for every domain (but no real need - simpler this way)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tangential musing, i wonder if RPC providers are actually smart about this and automatically use from the block that the contract being queried was deployed at

domain,
receipt,
name: event.eventSignature?.split('(')[0],
event,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i wonder if it wouldn't be beneficial to have the annotatedEvent have all the same fields as a regular event (e.g. do ...event here) so that people can interact with it as if its a normal event (with a few extra fields)

lastBlock = endBlock;
}
// query domain pagination limit at a time, concurrently
const callArgs = [];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this loop isn't used. i'll open a PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Typescript dev work required
Projects
None yet
4 participants