-
Notifications
You must be signed in to change notification settings - Fork 5
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
Improve migration process #80
Conversation
#[cfg(feature = "integration-test")] | ||
#[result_serializer(borsh)] | ||
#[must_use] | ||
pub fn ft_balances_of( |
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.
Why we don't create a real ft_balance_of
function?
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.
Because we are going to migrate accounts batches, so we need to get balances for multiple accounts at once to reduce the time that is needed for migration and gas usage.
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.
My question was not about that. This function exists only if the integration-test
feature turns on. But why don't we just support this function in the eth-connector
contract? Why do we need to create a fake one?
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 function returns mock values for tests and simulates the Aurora engine contract.
It is the same as the verify_log_entry_in_bound
that simulates the Prover contract.
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.
Overall looks good.
if let Some(previous_balance) = self.ft.accounts.insert(account, amount) { | ||
self.ft.total_supply -= previous_balance; | ||
} | ||
self.ft.total_supply += amount; |
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 would move the line self.ft.total_supply += amount;
to the beginning of the loop to prevent overflow.
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.
Logically, it is impossible to get overflow(underflow) here. If we got it, then it means that we did something wrong, and the migration process should be stopped. The contract will panic because the flag overflow-checks
is enabled.
Description
This PR improves the migration process and makes it more trustless by retrieving the balances on-chain instead of off-chain.
Changes:
contract_state.borsh
Performance / NEAR gas cost considerations
Testing
How should this be reviewed
Additional information