-
Notifications
You must be signed in to change notification settings - Fork 133
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
Fix: Keep track of changing permissions during transaction validation #1412
Conversation
isValidProof = await verify(proof, verificationKey); | ||
if (!isValidProof) { | ||
throw Error( | ||
`Invalid proof for account update\n${JSON.stringify(update)}` | ||
); | ||
} | ||
} catch (error) { | ||
errorTrace += '\n\n' + (error as Error).message; | ||
errorTrace += '\n\n' + (error as Error).stack; |
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.
much better to also include the stack trace here - that way you can see where the code failed
let verificationKey = account.zkapp?.verificationKey?.data; | ||
assert( | ||
verificationKey !== undefined, | ||
'Account does not have a verification key' | ||
); |
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.
ran into this being undefined
in a test and failed down the line - better to have an explicit error about it right away
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.
nice, looking forward to extending this!
This fixes a bug where a transaction that updated permissions on an existing account, and then tried to perform an action affected by the updated permissions, was incorrectly rejected by the TS pre-validation logic, because that logic didn't keep track of the changed permissions.
As a fix, we introduced a lightweight internal "ledger" on which individual account updates are applied, updating permissions.
This can be extended in the future to keep track of more account state on the TS side.
Note: There are no tests currently fixed by this. However, a unit test that would fail without this change is coming soon as part of #1384 (
token-contract.unit-test.ts
)