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

Validation logic for Quark Builder #3

Merged
merged 7 commits into from
Jun 11, 2024

Conversation

kevincheng96
Copy link
Contributor

No description provided.

Copy link
Contributor

@fluffywaffles fluffywaffles left a comment

Choose a reason for hiding this comment

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

seems like we duplicate quite a lot of code between BridgeRoutes.sol and QuarkBuilder.sol?

I'm sure it's just a matter of organizing common structs and functions into a shared library or something, but perhaps we should go ahead and do that.

src/builder/BridgeRoutes.sol Outdated Show resolved Hide resolved
src/builder/BridgeRoutes.sol Outdated Show resolved Hide resolved
src/builder/BridgeRoutes.sol Outdated Show resolved Hide resolved
src/builder/BridgeRoutes.sol Outdated Show resolved Hide resolved
src/builder/BridgeRoutes.sol Outdated Show resolved Hide resolved
src/builder/BridgeRoutes.sol Outdated Show resolved Hide resolved
src/builder/BridgeRoutes.sol Outdated Show resolved Hide resolved
src/builder/BridgeRoutes.sol Outdated Show resolved Hide resolved
src/builder/QuarkBuilder.sol Outdated Show resolved Hide resolved
src/builder/QuarkBuilder.sol Outdated Show resolved Hide resolved
Comment on lines 220 to 125
if (payment.chainIds.length != payment.maxCosts.length) {
revert InvalidInput();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This will be obviated by refactoring the max costs data into an array-of-structs.

However, raises the question: if a chain id is not included in maxCosts, does that mean we should not consider assets on that chain? It is easily possible for the chainAccountsList to contain chains that have no specified max costs.

So, is that an error?
Or is that informative? Ie., if maxCosts is not empty, are those the only chains we should consider using?

Copy link
Contributor Author

@kevincheng96 kevincheng96 Jun 6, 2024

Choose a reason for hiding this comment

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

This will be obviated by refactoring the max costs data into an array-of-structs.

Yeah, this was removed after I added the MaxPaymentCost struct.

However, raises the question: if a chain id is not included in maxCosts, does that mean we should not consider assets on that chain? It is easily possible for the chainAccountsList to contain chains that have no specified max costs.

So, is that an error? Or is that informative? Ie., if maxCosts is not empty, are those the only chains we should consider using?

Hmm, interesting question. I don't think we should require the client to supply max costs for every chain. So, we could either 1) not construct Quark Operations on chains where max cost is unset or 2) choose some default value if max cost is unset.

I do prefer 1, since there really isn't a good default value that works for all Quark Operations and payment tokens for 2. It's also a bit scary to set a value for it that's not specified by the client.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, I think if no max is provided, we should assume a max of 0.

Copy link
Contributor

Choose a reason for hiding this comment

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

With the edge case that, if maxCosts is empty, we must still return a result that can be provided to simulate.

We may expect the client to explicitly pass in some large numbers for maxCosts, alternatively. 🤷

It's also perhaps a situation that will overlap with our handling of "maximum" or "unlimited" in the case of "transfer max" -- if we choose a sigil like uint256(-1) to represent "max" or "no limit," then maybe that's what we should use to explicitly construct simulations ignoring cost limits...

src/builder/QuarkBuilder.sol Outdated Show resolved Hide resolved
src/builder/QuarkBuilder.sol Outdated Show resolved Hide resolved
Copy link
Contributor

@fluffywaffles fluffywaffles left a comment

Choose a reason for hiding this comment

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

lgtm on tests in a follow-up 👍

@kevincheng96 kevincheng96 force-pushed the kevin/quark-builder branch from da7d9bc to b04f11e Compare June 7, 2024 15:47
had to rebase on main so that I had access to bridger code

---------

Co-authored-by: Kevin Cheng <[email protected]>
@kevincheng96 kevincheng96 merged commit 73b4618 into kevin/quark-builder Jun 11, 2024
4 checks passed
@kevincheng96 kevincheng96 deleted the kevin/validation branch June 11, 2024 20:29
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