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

Sidecar: check user balance and nonce before sending commitments #102

Closed
thedevbirb opened this issue Jul 2, 2024 · 2 comments · Fixed by #117
Closed

Sidecar: check user balance and nonce before sending commitments #102

thedevbirb opened this issue Jul 2, 2024 · 2 comments · Fixed by #117
Labels
C: bolt-sidecar Component: bolt-sidecar

Comments

@thedevbirb
Copy link
Contributor

In the context of the recent proposal of account abstraction it may be possible that a transaction changes the balance of an EOA without increasing its nonce, since it can be originated by another entity.
As such, in the sidecar we should:

  • wait for the right slot before sending the commitments and
  • check both balance and nonce according to the current state
@thedevbirb thedevbirb added the C: bolt-sidecar Component: bolt-sidecar label Jul 2, 2024
@mempirate
Copy link
Contributor

@namn-grg another thing to research in the AA report is which incompatiblities there are with Bolt as of now

@thedevbirb
Copy link
Contributor Author

Actually some balances checks are already implemented, see unstable branch as of now:

pub fn retain(&mut self, address: Address, mut state: AccountState) {
let mut indexes = Vec::new();
for (index, tx) in self.transactions.iter().enumerate() {
let max_cost = max_transaction_cost(tx);
if tx.recover_signer().expect("passed validation") == address
&& (state.balance < max_cost || state.transaction_count > tx.nonce())
{
tracing::trace!(
%address,
"Removing transaction at index {} due to conflict with account state",
index
);
indexes.push(index);
// Continue to the next iteration, not updating the state
continue;
}
// Update intermediary state for next transaction (if the tx was not removed)
state.balance -= max_cost;
state.transaction_count += 1;
}
// Remove transactions that conflict with the account state. We start in reverse
// order to avoid invalidating the indexes.
for index in indexes.into_iter().rev() {
self.remove_transaction_at_index(index);
}
}
}

Moreover, such logic has been a bit refactored by #117 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: bolt-sidecar Component: bolt-sidecar
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants