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

Relayer nonce collisions #2157

Merged
merged 5 commits into from
Sep 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/2.build/1.chain-abstraction/meta-transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,21 @@ Progress is being made to make this possible in the future.

</details>

### High volume parallel processing

When running a relayer that handles a large number of transactions, issues will quickly arise due to each transaction requiring a unique nonce. If multiple transactions are sent from the same access key simultaneously, the process becomes error-prone.

Fortunately, this is easy to resolve. Adding multiple full access keys to the NEAR account used for relaying (up to 20 keys can make a significant difference) will help. Then, relaying transactions using instances of the Account object created from the various keypairs associated with the account.

To add a key, generate a new keypair and use the original account object to call the addKey method
SurgeCode marked this conversation as resolved.
Show resolved Hide resolved

```typescript
SurgeCode marked this conversation as resolved.
Show resolved Hide resolved
const keyPair = nearAPI.KeyPair.fromRandom("ed25519");

const receipt = await account.addKey(keyPair.getPublicKey().toString())
```

After saving these keys, its possible to rotate the private keys randomly when instantiating accounts before relaying ensuring you won't create a nonce collision.

### Gating the relayer

Expand Down
Loading