aurora-is-near / aurora-engine

⚙️ Aurora Engine implements an Ethereum Virtual Machine (EVM) on the NEAR Protocol.
https://doc.aurora.dev/develop/compat/evm
322 stars 79 forks source link

feat: add api to get ft balances for multiple accounts #905

Closed karim-en closed 4 months ago

karim-en commented 4 months ago

Description

The PR adds a public method to the engine/internal connector to get balances of multiple accounts. This is needed because we have changed the migration logic to migrate the balances based on the on-chain data, not off-chain.

Performance / NEAR gas cost considerations

The borsh is used instead of JSON to decrease gas usage and migrate more accounts in one batch.

Testing

Added a test to the crate aurora-engine-tests, not aurora-engine-tests-connector because the second one is enabled just for silo builds.

How should this be reviewed

Additional information

It's controversial whether to use HashMap<AccountId, Balance> or Vec<(AccountId, Balance)>; the HashMap prevents duplication, but on the other side, it increases gas usage.

aleksuss commented 4 months ago

It's controversial whether to use HashMap<AccountId, Balance> or Vec<(AccountId, Balance)>; the HashMap prevents duplication, but on the other side, it increases gas usage.

I guess we can use the HashMap and don't care about the gas usage since it will be invoked only once.