-
Notifications
You must be signed in to change notification settings - Fork 44
Conversation
@@ -0,0 +1,50 @@ | |||
#!/usr/bin/env -S deno run --allow-net --allow-env --allow-read --allow-write --unstable |
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.
This is just a script to trigger an error in a bundle for testing
@@ -235,11 +235,16 @@ export default class AggregationStrategy { | |||
let success: boolean; | |||
|
|||
if (bundleResult.success) { | |||
const [operationResults] = bundleResult.returnValue; | |||
const [operationStatuses, results] = bundleResult.returnValue; |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
errorArgBytesString, | ||
)[0]; // decoded bytes is a string of the action index that errored. | ||
|
||
console.error(errorString) |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
// TODO: is it possible to decode this? | ||
// Here is an example when I try to send more ETH than an account has:results = | ||
// results = [ "0x4e487b710000000000000000000000000000000000000000000000000000000000000011" ] |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
This reverts commit 44fec67.
@@ -444,3 +461,89 @@ export default class AggregationStrategy { | |||
return left; | |||
} | |||
} | |||
|
|||
// The below code is temporary till the functions are exposed in the client module |
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.
After this is merged and a new version is published, I will delete the below code and use the function from the client module
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.
@blakecduncan You can do that now #407 . You can use https://github.com/web3well/bls-wallet/blob/main/docs/local_development.md#aggregator-1 as a guide, but feel free to ping me if you need help.
|
||
return { success, fee }; | ||
return { success, fee, errorReason }; |
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.
Returning the error reason here so that we can link it to a failed row later when we check the index of the failed bundle
aggregator/src/app/BundleRouter.ts
Outdated
@@ -24,6 +24,16 @@ export default function BundleRouter(bundleService: BundleService) { | |||
router.get( | |||
"bundleReceipt/:hash", | |||
async (ctx) => { | |||
// check pending |
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.
Return 202 error message if the bundle is in the DB. Also, pass a submit error in the body
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.
Would be good to have an integration test case(s) for the HTTP 202
path that ensures the bundle lifecycle & error decoding works as expected.
Yeah good call, I'll write some tests for this 👍 |
😄. How's your IDE set-up? Are the linting errors showing? Is autofix-on-save working? |
@@ -176,6 +178,10 @@ export default class AggregationStrategy { | |||
|
|||
if (firstFailureIndex !== nil) { | |||
const failedRow = includedRows[firstFailureIndex]; | |||
const errorReason = fees[firstFailureIndex].errorReason; | |||
if (errorReason) { | |||
failedRow.submitError = errorReason.message || ''; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
@voltrevo Yeah that makes sense I'll switch it. I was doing this because I didn't make the column nullable in the DB, so it was setting it by default to an empty string. I updated that per your comment below and was able to make this more consistent with the undefined/nil
@@ -207,6 +213,7 @@ export default class AggregationStrategy { | |||
async #measureFees(bundles: Bundle[]): Promise<{ | |||
success: boolean; | |||
fee: BigNumber; | |||
errorReason: OperationResultError | null; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
const fee = after.returnValue[0].sub(before.returnValue[0]); | ||
const [operationStatuses, results] = bundleResult.returnValue; | ||
|
||
let errorReason: OperationResultError | null = null; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
return; | ||
} | ||
}); | ||
errorReason = error[0] ?? null; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
aggregator/src/app/BundleRouter.ts
Outdated
@@ -24,14 +24,29 @@ export default function BundleRouter(bundleService: BundleService) { | |||
router.get( | |||
"bundleReceipt/:hash", | |||
async (ctx) => { | |||
const pendingBundle = await bundleService.lookupBundle(ctx.params.hash!); | |||
if (pendingBundle) { | |||
ctx.response.status = 202; |
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 don't think 202 is appropriate here. It's the bundle that's been accepted, not the receipt. Also 'accepted' is supposed to refer to the current request, not the resource you're asking about. More info.
(Possibly 202 is appropriate for the original POST to /bundle, but I'm not actually a fan of worrying about these HTTP nuances.)
On a practical note, if we keep 404 here we can still also provide the submitError
, and this way it wouldn't be a breaking change. Wdyt?
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.
Yeah, I get what you're saying. I do like the idea of not doing a breaking change, as there are a good amount of things that have to be updated at this point.
However, I think the /bundleReceipt
API call is often used as a status check for a bundle. So my question would be, what should we expect to be returned from this API call? With the approach you recommended, we would keep a 200 status as is (i.e. returns the bundle receipt) and pass the submit error in a 404 response body. That would be fine by me - I think the only thing we aren't communicating explicitly is the bundle status. For example, we could communicate a pending or a failed state (ex: even if it failed once, we may still retry it). Maybe we don't care about that though or it should be a different API endpoint.
@voltrevo What do you think? I'd be happy to hop on a call tomorrow when I get online if you are still around. Also, @jacque006 not sure if you have any thoughts?
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'm not sure we're on the same page here. Definitely sounds like a call is in order.
With the approach you recommended, we would keep a 200 status as is (i.e. returns the bundle receipt) and pass the submit error in a 404 response body.
Did you mean to say 'keep a 200 status'? It seems wrong, and also contradicts the second half of this sentence. At least my reading of it.
To rephrase my suggestion, I think if the bundle is pending, then /bundleReceipt
should 404, since there isn't a bundle receipt, but we can also put the submitError in the body of this response. Meaning: "No, there's no receipt (404), and here's why (submitError)".
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.
Ahh my response was poorly worded. We are on the same page. When I said keep the 200 status, I really meant get rid of my logic to add the 202. You worded it better than I did - that is what I meant to say.
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.
Yep, we can discuss offline. In general, I have seen services go one of two ways:
- Use a variety/specific HTTP codes to communicate the state of a resource (200/201/202/403/404/418)
- Use a limited number of status codes (200/403/404) and use a
status
field or similar to communicate the state of the resource (pending/failed/succeeded). Some Google Cloud APIs go this route
I think either is fine as long as we are consistent with that pattern on our endpoints and document the possible responses in code. Hopefully most consumers use our clients which can abstract a lot of that away.
const bundleRow: BundleRow = { | ||
id: 0, | ||
hash: "0x0", | ||
submitError: "", |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
aggregator/test/BundleTable.test.ts
Outdated
@@ -49,6 +49,7 @@ const sampleRows: BundleRow[] = [ | |||
], | |||
signature: ["0x00", "0x00"], | |||
}, | |||
submitError: "", |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
contracts/clients/src/Aggregator.ts
Outdated
|
||
export type BundleReceiptResponse = { | ||
status: string; | ||
submitError: string | null; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
contracts/clients/src/Aggregator.ts
Outdated
export type BundleReceiptResponse = { | ||
status: string; | ||
submitError: string | null; | ||
receipt: BundleReceipt | null; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
const bundleReceiptResponse = await aggregator.lookupReceipt(hash); | ||
// If receipt doesn't exist, set to undefined to be consistent with | ||
// the return type | ||
const bundleReceipt = bundleReceiptResponse?.receipt || undefined; |
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.
|| undefined
is unnecessary (obj?.field
produces undefined
when field is not there, even when obj
is null
).
Also prefer ??
over ||
.
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.
Yeah I was getting a typescript error the BundleReceipt | undefined
does not equal BundleReceipt | undefined | null
. I think with the changes you recommended above I can fix this.
aggregator/src/app/BundleTable.ts
Outdated
eligibleAfter: { type: DataType.VarChar }, | ||
nextEligibilityDelay: { type: DataType.VarChar }, | ||
}; | ||
|
||
function fromRawRow(rawRow: RawRow): Row { | ||
const parseResult = parseBundleDto(JSON.parse(rawRow.bundle)); | ||
|
||
console.log('blake..', parseResult); |
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.
debug log left here
# Conflicts: # contracts/clients/src/Aggregator.ts
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.
👍 from me. once @voltrevo is satisfied
https://loom.com/share/2a2039a17af04e23838561a08b0c6aaf
What is this PR doing?
Additional work
/bundleReceipt
API call to return a 404 when a bundle is pending.Future improvements
How can these changes be manually tested?
You can run the zeroAddressError script to trigger a bundle error and log out a message
Does this PR resolve or contribute to any issues?
Resolves #301
Checklist
Guidelines
resolve conversation
button is for reviewers, not authors