This makes account creation extremely slow at genesis. One workaround is to create accounts one by one. Specifically, let's change the function "create_accounts" in aptos_move/vm_genesis/src/lib.rs to as follows:
fn create_accounts(session: &mut SessionExt, accounts: &[AccountBalance]) {
for account in accounts {
let accounts = vec![account];
let accounts_bytes = bcs::to_bytes(accounts.as_slice()).expect("AccountMaps can be serialized");
let mut serialized_values = serialize_values(&vec![MoveValue::Signer(CORE_CODE_ADDRESS)]);
serialized_values.push(accounts_bytes);
exec_function(
session,
GENESIS_MODULE_NAME,
"create_accounts",
vec![],
serialized_values,
);
}
}
With this change, account creation has linear complexity and thus is much faster.
The following function in genesis.move incurs quadratic complexity, due to duplicate checking:
This makes account creation extremely slow at genesis. One workaround is to create accounts one by one. Specifically, let's change the function "create_accounts" in aptos_move/vm_genesis/src/lib.rs to as follows:
fn create_accounts(session: &mut SessionExt, accounts: &[AccountBalance]) { for account in accounts { let accounts = vec![account]; let accounts_bytes = bcs::to_bytes(accounts.as_slice()).expect("AccountMaps can be serialized"); let mut serialized_values = serialize_values(&vec![MoveValue::Signer(CORE_CODE_ADDRESS)]); serialized_values.push(accounts_bytes); exec_function( session, GENESIS_MODULE_NAME, "create_accounts", vec![], serialized_values, ); } }
With this change, account creation has linear complexity and thus is much faster.