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

Handle underfunded claims #22

Merged
merged 10 commits into from
May 11, 2021
Merged

Handle underfunded claims #22

merged 10 commits into from
May 11, 2021

Conversation

lalexgap
Copy link
Contributor

@lalexgap lalexgap commented May 7, 2021

This updates the claim method to take into account the order of guarantees. We iterate through guarantees that occur before the target one and tally the amount of funds reserved by guarantees.

The amount on the guarantee is now used to store the funding available for the guarantee.

We also now return a updatedGuaranteeOutcome that has the amount adjusted after the funds have been claimed.

Currently there are only typescript versions of the tests/changes but this should be pretty easy to copy over to solidity.

@@ -14,7 +14,11 @@ export function claim(
) {
if (initialTargetOutcome.length !== initialHoldings.length) throw Error;
const updatedTargetOutcome: Exit = [];
let updatedHoldings = initialHoldings;
// We want to create a clone of the original values to prevent mutation
const updatedHoldings = initialHoldings.map((h) => BigNumber.from(h));
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 think previously we were mutating the values passed in

Copy link
Contributor

@geoknee geoknee left a comment

Choose a reason for hiding this comment

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

Looking good aside from one comment about how to update the guarantor channel.

I think we ought to add in the corresponding solidity code, too, before merging (to keep everything in step).

Comment on lines +71 to +74
const guarantee = createGuarantee([
["C2", "0x03", ["A"]],
["C1", "0x0A", ["A", "I", "B"]],
]);
Copy link
Contributor

@geoknee geoknee May 8, 2021

Choose a reason for hiding this comment

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

I like this notation a lot, it's easy to parse the important information.

Any reason why you chose C2 as the higher priority and C1 as the lower priority (just wondering about notation)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No strong reason.

In my mind, C1 is the "main" channel (with allocations to A,I,B) and we're using C2 ahead of it to test the underfunded claim scenario. It keeps it consistent-ish with other tests that use C1 as the only channel.

nitro-src/claim.ts Outdated Show resolved Hide resolved
nitro-src/claim.ts Outdated Show resolved Hide resolved
nitro-src/claim.ts Show resolved Hide resolved
@lalexgap lalexgap merged commit d7da7b9 into main May 11, 2021
@lalexgap lalexgap deleted the ag/underfunded-claim branch May 11, 2021 17:39
@lalexgap lalexgap restored the ag/underfunded-claim branch May 11, 2021 18:13
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.

None yet

2 participants