Skip to content

feat(svmSpokeUtils): get fill deadline buffer implementation #978

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

Open
wants to merge 4 commits into
base: epic/svm-client
Choose a base branch
from

Conversation

melisaguevara
Copy link
Contributor

@melisaguevara melisaguevara commented Apr 10, 2025

This PR implements the utility function for getting svm fill deadline buffer. That's done by fetching the Spoke Pool's State PDA.

@melisaguevara melisaguevara force-pushed the mg/svm-getMaxFillDeadline branch from f8f8e9c to 9cf2918 Compare April 14, 2025 19:27
@melisaguevara melisaguevara changed the title WIP: svm version of get fill deadline buffer feat(svmSpokeUtils): get fill deadline buffer implementation Apr 14, 2025
@melisaguevara melisaguevara marked this pull request as ready for review April 14, 2025 19:45
@@ -19,6 +20,7 @@ export class SvmSpokePoolClient extends SpokePoolClient {
chainId: number,
deploymentSlot: bigint, // Using slot instead of block number for SVM
eventSearchConfig: MakeOptional<EventSearchConfig, "toBlock">,
protected programId: string,
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've added programId here because I think it's useful to have direct access to it. That said, I'm also not sure this is the best approach since svmSpokeEventsClient already resolves programId internally, and that value might differ from the one passed in here. To address that I think we can either (1) use the resolved value from svmEventsClient or (2) let the callers provide programId and pass that to svmSpokeEventsClient.

For option 1, we only need to make svmSpokeAddress a public property (here).

For option 2 we'll have to remove the resolution logic from svmSpokeEventsClient entirely and turn it into a constructor param instead.

I'm curious to hear other's thoughts about this. Personally, I'm leaning toward option 2. I think it's closer to what we have for EVM and it also improves flexibility. As an example, I had to override the program signature to test some Solana features while working in the Indexer and there was other way to do so than changing the svmSpokeEventsClient.

Copy link
Contributor

Choose a reason for hiding this comment

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

@melisaguevara Is it necessary for the eventsClient to be instantiated outside of the SVMSpokePoolClient? Could we instead instantiate it entirely within the .create() static method?

Copy link
Member

Choose a reason for hiding this comment

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

Fwiw I think it makes sense to also expose the svmSpokeAddress - it's not required to be private, and could theoretically be encapsulated in a getter fn

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it necessary for the eventsClient to be instantiated outside of the SVMSpokePoolClient? Could we instead instantiate it entirely within the .create() static method?

@pxrl I don't think so, I think we'll always use it through the clients. This could be a follow up if we all agree to do so.

Copy link
Contributor Author

@melisaguevara melisaguevara Apr 16, 2025

Choose a reason for hiding this comment

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

Fwiw I think it makes sense to also expose the svmSpokeAddress - it's not required to be private, and could theoretically be encapsulated in a getter fn

@james-a-morris Yes I saw you did that in your PR. I think that's also an option, though as an end user you would have to do svmSpokeClient.svmEventsClient.getSvmSpokeAddress(). I think it would be nice to have that directly as property of SvmSpokeClient. For now I'll follow your approach but I'm also including it as a spoke client property, we can revisit this later.

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 is how it looks for now: d7e3dd6

Copy link
Contributor

Choose a reason for hiding this comment

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

@pxrl I don't think so, I think we'll always use it through the clients. This could be a follow up if we all agree to do so.

Yeah; I think it's probably cleaner to incorporate it directly into the SpokePoolClient, rather than requiring it to be supplied as an external dependency. This should make it easier to instantiate.

@melisaguevara melisaguevara requested a review from pxrl April 15, 2025 15:07
* @param extraSeed An optional extra seed. Defaults to 0.
* @returns The PDA for the State account.
*/
export async function getStatePda(programId: string, extraSeed = 0): Promise<Address> {
Copy link
Member

Choose a reason for hiding this comment

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

For consistency should programId also be Address?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -19,6 +20,7 @@ export class SvmSpokePoolClient extends SpokePoolClient {
chainId: number,
deploymentSlot: bigint, // Using slot instead of block number for SVM
eventSearchConfig: MakeOptional<EventSearchConfig, "toBlock">,
protected programId: string,
Copy link
Member

Choose a reason for hiding this comment

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

Fwiw I think it makes sense to also expose the svmSpokeAddress - it's not required to be private, and could theoretically be encapsulated in a getter fn

@amateima amateima self-requested a review April 16, 2025 13:31
@@ -209,4 +209,8 @@ export class SvmSpokeEventsClient {

return events;
}

public getSvmSpokeAddress(): Address {
Copy link
Member

Choose a reason for hiding this comment

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

+1

* @param extraSeed An optional extra seed. Defaults to 0.
* @returns The PDA for the State account.
*/
export async function getStatePda(programId: Address, extraSeed = 0): Promise<Address> {
Copy link
Member

Choose a reason for hiding this comment

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

OOC how often is extraSeed set? I think it makes sense to have but if we don't need to use it it may be extra unneeded params

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