-
Notifications
You must be signed in to change notification settings - Fork 247
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!: avoid deploying a contract to an account with existing state #802
fix!: avoid deploying a contract to an account with existing state #802
Conversation
@bowenwang1996 Is there a chance that fetching a list of state keys can be faster than fetching the key-values? |
I don't think so, at least with the current implementation |
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 work on identifying all of the underlying behaviours we've been encountering with this logic 💖 Added a few questions/concerns in-line...
Co-authored-by: Daryl Collins <daryl@darylcollins.com>
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.
We're just about there - just a few things in-line and then we can get this landed 👍 <3
Co-authored-by: Daryl Collins <daryl@darylcollins.com>
9236623
to
fedd3d5
Compare
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 work! Excited to get this landed :)
This PR addresses near/near-wallet#2261 and avoids bricking accounts with arbitrary contract state left over by doing the following:
The disable 2fa procedure will clear all contract state after itself in 2 atomic steps:
delete_request
to ensure that the rpcview_state
call needed to use the state cleanup contract's clean method does not throw a TOO_LARGE_CONTRACT_STATE error due to the state size limit.The enable 2fa procedure will submit a transaction that will always fail designed to identify the current state of the contract it is interacting with. The transaction has 2 actions, one that deploys the multisig contract and the second calls
delete_request
with therequest_id
argument set tou32::MAX
.new
function call at the end of the action batch.contractHasExistingStateError
.This was tested with different combinations of contract states and
code_hash
es here