Open ruseinov opened 3 months ago
Yeah, it is clearly a nonce collision which is a common thing in all the tooling we currently have in NEAR when you need to submit several concurrent transactions from a single account, you have to sign them with difference access keys to avoid such errors:
The best solution would be to fix it on the tooling side instead of letting developers to bump into these issues and rediscover them this way. There is also a proposal to solve it on the protocol level: https://github.com/near/NEPs/pull/522
I have tried parallelizing transaction execution in two different manners.
Account
andContract
.use near_gas::NearGas; use near_primitives_core::types::Gas; use near_workspaces::types::GasMeter; use near_workspaces::Account; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use strum::IntoEnumIterator; use strum_macros::EnumIter; use tokio::join; use tokio::task::JoinSet;
[derive(Serialize, Deserialize, EnumIter, Copy, Clone)]
[serde(crate = "near_sdk::serde")]
pub enum Collection { IterableSet, IterableMap, UnorderedSet, UnorderedMap, LookupMap, LookupSet, TreeMap, Vector, }
[derive(Serialize, Deserialize)]
[serde(crate = "near_sdk::serde")]
pub enum Op { Insert(u32), Remove(u32), Flush, Contains(u32), Iter(usize), }
[tokio::test]
// TODO: Parallelize async fn combined_test() -> anyhow::Result<()> { let worker = near_workspaces::sandbox().await?; let contract = worker.dev_deploy(include_bytes!("test-contracts/store/res/store.wasm")).await?; let account: Account = worker.dev_create_account().await?;
}
Error: unable to broadcast the transaction to the network
Caused by: handler error: [An error happened during transaction execution: InvalidNonce { tx_nonce: 12000019, ak_nonce: 12000033 }]
This works perfectly fine.