@aztec/bot 0.0.0-test.1 → 0.0.1-commit.001888fc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dest/amm_bot.d.ts +32 -0
  2. package/dest/amm_bot.d.ts.map +1 -0
  3. package/dest/amm_bot.js +108 -0
  4. package/dest/base_bot.d.ts +21 -0
  5. package/dest/base_bot.d.ts.map +1 -0
  6. package/dest/base_bot.js +79 -0
  7. package/dest/bot.d.ts +13 -18
  8. package/dest/bot.d.ts.map +1 -1
  9. package/dest/bot.js +26 -84
  10. package/dest/config.d.ts +106 -66
  11. package/dest/config.d.ts.map +1 -1
  12. package/dest/config.js +89 -39
  13. package/dest/cross_chain_bot.d.ts +54 -0
  14. package/dest/cross_chain_bot.d.ts.map +1 -0
  15. package/dest/cross_chain_bot.js +134 -0
  16. package/dest/factory.d.ts +43 -29
  17. package/dest/factory.d.ts.map +1 -1
  18. package/dest/factory.js +380 -139
  19. package/dest/index.d.ts +5 -2
  20. package/dest/index.d.ts.map +1 -1
  21. package/dest/index.js +4 -1
  22. package/dest/interface.d.ts +12 -1
  23. package/dest/interface.d.ts.map +1 -1
  24. package/dest/interface.js +5 -0
  25. package/dest/l1_to_l2_seeding.d.ts +8 -0
  26. package/dest/l1_to_l2_seeding.d.ts.map +1 -0
  27. package/dest/l1_to_l2_seeding.js +63 -0
  28. package/dest/rpc.d.ts +1 -7
  29. package/dest/rpc.d.ts.map +1 -1
  30. package/dest/rpc.js +0 -11
  31. package/dest/runner.d.ts +15 -11
  32. package/dest/runner.d.ts.map +1 -1
  33. package/dest/runner.js +457 -51
  34. package/dest/store/bot_store.d.ts +69 -0
  35. package/dest/store/bot_store.d.ts.map +1 -0
  36. package/dest/store/bot_store.js +138 -0
  37. package/dest/store/index.d.ts +2 -0
  38. package/dest/store/index.d.ts.map +1 -0
  39. package/dest/store/index.js +1 -0
  40. package/dest/utils.d.ts +8 -5
  41. package/dest/utils.d.ts.map +1 -1
  42. package/dest/utils.js +14 -5
  43. package/package.json +30 -23
  44. package/src/amm_bot.ts +129 -0
  45. package/src/base_bot.ts +82 -0
  46. package/src/bot.ts +52 -101
  47. package/src/config.ts +129 -71
  48. package/src/cross_chain_bot.ts +203 -0
  49. package/src/factory.ts +476 -152
  50. package/src/index.ts +4 -1
  51. package/src/interface.ts +9 -0
  52. package/src/l1_to_l2_seeding.ts +79 -0
  53. package/src/rpc.ts +0 -13
  54. package/src/runner.ts +51 -21
  55. package/src/store/bot_store.ts +196 -0
  56. package/src/store/index.ts +1 -0
  57. package/src/utils.ts +17 -6
package/src/bot.ts CHANGED
@@ -1,40 +1,47 @@
1
- import {
2
- type AztecAddress,
3
- BatchCall,
4
- FeeJuicePaymentMethod,
5
- type SendMethodOptions,
6
- type Wallet,
7
- createLogger,
8
- } from '@aztec/aztec.js';
9
- import { timesParallel } from '@aztec/foundation/collection';
10
- import type { EasyPrivateTokenContract } from '@aztec/noir-contracts.js/EasyPrivateToken';
1
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import { BatchCall, NO_WAIT } from '@aztec/aztec.js/contracts';
3
+ import { TxHash } from '@aztec/aztec.js/tx';
4
+ import { times } from '@aztec/foundation/collection';
5
+ import type { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken';
11
6
  import type { TokenContract } from '@aztec/noir-contracts.js/Token';
12
- import type { FunctionCall } from '@aztec/stdlib/abi';
13
- import { Gas } from '@aztec/stdlib/gas';
14
- import type { AztecNode, PXE } from '@aztec/stdlib/interfaces/client';
7
+ import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
8
+ import type { EmbeddedWallet } from '@aztec/wallets/embedded';
15
9
 
10
+ import { BaseBot } from './base_bot.js';
16
11
  import type { BotConfig } from './config.js';
17
12
  import { BotFactory } from './factory.js';
13
+ import type { BotStore } from './store/index.js';
18
14
  import { getBalances, getPrivateBalance, isStandardTokenContract } from './utils.js';
19
15
 
20
16
  const TRANSFER_AMOUNT = 1;
21
17
 
22
- export class Bot {
23
- private log = createLogger('bot');
24
-
25
- private attempts: number = 0;
26
- private successes: number = 0;
27
-
18
+ export class Bot extends BaseBot {
28
19
  protected constructor(
29
- public readonly wallet: Wallet,
30
- public readonly token: TokenContract | EasyPrivateTokenContract,
20
+ node: AztecNode,
21
+ wallet: EmbeddedWallet,
22
+ defaultAccountAddress: AztecAddress,
23
+ public readonly token: TokenContract | PrivateTokenContract,
31
24
  public readonly recipient: AztecAddress,
32
- public config: BotConfig,
33
- ) {}
25
+ config: BotConfig,
26
+ ) {
27
+ super(node, wallet, defaultAccountAddress, config);
28
+ }
34
29
 
35
- static async create(config: BotConfig, dependencies: { pxe?: PXE; node?: AztecNode } = {}): Promise<Bot> {
36
- const { wallet, token, recipient } = await new BotFactory(config, dependencies).setup();
37
- return new Bot(wallet, token, recipient, config);
30
+ static async create(
31
+ config: BotConfig,
32
+ wallet: EmbeddedWallet,
33
+ aztecNode: AztecNode,
34
+ aztecNodeAdmin: AztecNodeAdmin | undefined,
35
+ store: BotStore,
36
+ ): Promise<Bot> {
37
+ const { defaultAccountAddress, token, recipient } = await new BotFactory(
38
+ config,
39
+ wallet,
40
+ store,
41
+ aztecNode,
42
+ aztecNodeAdmin,
43
+ ).setup();
44
+ return new Bot(aztecNode, wallet, defaultAccountAddress, token, recipient, config);
38
45
  }
39
46
 
40
47
  public updateConfig(config: Partial<BotConfig>) {
@@ -42,84 +49,47 @@ export class Bot {
42
49
  this.config = { ...this.config, ...config };
43
50
  }
44
51
 
45
- public async run() {
46
- this.attempts++;
47
- const logCtx = { runId: Date.now() * 1000 + Math.floor(Math.random() * 1000) };
48
- const { privateTransfersPerTx, publicTransfersPerTx, feePaymentMethod, followChain, txMinedWaitSeconds } =
49
- this.config;
52
+ protected async createAndSendTx(logCtx: object): Promise<TxHash> {
53
+ const { privateTransfersPerTx, publicTransfersPerTx, feePaymentMethod } = this.config;
50
54
  const { token, recipient, wallet } = this;
51
- const sender = wallet.getAddress();
52
55
 
53
56
  this.log.verbose(
54
57
  `Preparing tx with ${feePaymentMethod} fee with ${privateTransfersPerTx} private and ${publicTransfersPerTx} public transfers`,
55
58
  logCtx,
56
59
  );
57
60
 
58
- const calls: FunctionCall[] = [];
59
- if (isStandardTokenContract(token)) {
60
- calls.push(
61
- ...(await timesParallel(privateTransfersPerTx, () =>
62
- token.methods.transfer(recipient, TRANSFER_AMOUNT).request(),
63
- )),
64
- );
65
- calls.push(
66
- ...(await timesParallel(publicTransfersPerTx, () =>
67
- token.methods.transfer_in_public(sender, recipient, TRANSFER_AMOUNT, 0).request(),
68
- )),
69
- );
70
- } else {
71
- calls.push(
72
- ...(await timesParallel(privateTransfersPerTx, () =>
73
- token.methods.transfer(TRANSFER_AMOUNT, sender, recipient).request(),
74
- )),
75
- );
76
- }
61
+ const calls = isStandardTokenContract(token)
62
+ ? [
63
+ times(privateTransfersPerTx, () => token.methods.transfer(recipient, TRANSFER_AMOUNT)),
64
+ times(publicTransfersPerTx, () =>
65
+ token.methods.transfer_in_public(this.defaultAccountAddress, recipient, TRANSFER_AMOUNT, 0),
66
+ ),
67
+ ].flat()
68
+ : times(privateTransfersPerTx, () =>
69
+ token.methods.transfer(TRANSFER_AMOUNT, this.defaultAccountAddress, recipient),
70
+ );
77
71
 
78
- const opts = this.getSendMethodOpts();
79
72
  const batch = new BatchCall(wallet, calls);
73
+ const opts = await this.getSendMethodOpts(batch);
80
74
 
81
75
  this.log.verbose(`Simulating transaction with ${calls.length}`, logCtx);
82
- await batch.simulate();
83
-
84
- this.log.verbose(`Proving transaction`, logCtx);
85
- const provenTx = await batch.prove(opts);
86
-
87
- this.log.verbose(`Sending tx`, logCtx);
88
- const tx = provenTx.send();
89
-
90
- const txHash = await tx.getTxHash();
91
-
92
- if (followChain === 'NONE') {
93
- this.log.info(`Transaction ${txHash} sent, not waiting for it to be mined`);
94
- return;
95
- }
76
+ await batch.simulate({ from: this.defaultAccountAddress });
96
77
 
97
- this.log.verbose(
98
- `Awaiting tx ${txHash} to be on the ${followChain} chain (timeout ${txMinedWaitSeconds}s)`,
99
- logCtx,
100
- );
101
- const receipt = await tx.wait({
102
- timeout: txMinedWaitSeconds,
103
- provenTimeout: txMinedWaitSeconds,
104
- proven: followChain === 'PROVEN',
105
- });
106
- this.log.info(
107
- `Tx #${this.attempts} ${receipt.txHash} successfully mined in block ${receipt.blockNumber} (stats: ${this.successes}/${this.attempts} success)`,
108
- logCtx,
109
- );
110
- this.successes++;
78
+ this.log.verbose(`Sending transaction`, logCtx);
79
+ const { txHash } = await batch.send({ ...opts, wait: NO_WAIT });
80
+ return txHash;
111
81
  }
112
82
 
113
83
  public async getBalances() {
114
84
  if (isStandardTokenContract(this.token)) {
115
85
  return {
116
- sender: await getBalances(this.token, this.wallet.getAddress()),
86
+ sender: await getBalances(this.token, this.defaultAccountAddress),
117
87
  recipient: await getBalances(this.token, this.recipient),
118
88
  };
119
89
  } else {
120
90
  return {
121
91
  sender: {
122
- privateBalance: await getPrivateBalance(this.token, this.wallet.getAddress()),
92
+ privateBalance: await getPrivateBalance(this.token, this.defaultAccountAddress),
123
93
  publicBalance: 0n,
124
94
  },
125
95
  recipient: {
@@ -129,23 +99,4 @@ export class Bot {
129
99
  };
130
100
  }
131
101
  }
132
-
133
- private getSendMethodOpts(): SendMethodOptions {
134
- const sender = this.wallet.getAddress();
135
- const { l2GasLimit, daGasLimit, skipPublicSimulation } = this.config;
136
- const paymentMethod = new FeeJuicePaymentMethod(sender);
137
-
138
- let gasSettings, estimateGas;
139
- if (l2GasLimit !== undefined && l2GasLimit > 0 && daGasLimit !== undefined && daGasLimit > 0) {
140
- gasSettings = { gasLimits: Gas.from({ l2Gas: l2GasLimit, daGas: daGasLimit }) };
141
- estimateGas = false;
142
- this.log.verbose(`Using gas limits ${l2GasLimit} L2 gas ${daGasLimit} DA gas`);
143
- } else {
144
- estimateGas = true;
145
- this.log.verbose(`Estimating gas for transaction`);
146
- }
147
- const baseFeePadding = 2; // Send 3x the current base fee
148
- this.log.verbose(skipPublicSimulation ? `Skipping public simulation` : `Simulating public transfers`);
149
- return { fee: { estimateGas, paymentMethod, gasSettings, baseFeePadding }, skipPublicSimulation };
150
- }
151
102
  }
package/src/config.ts CHANGED
@@ -1,43 +1,53 @@
1
1
  import {
2
2
  type ConfigMappingsType,
3
+ SecretValue,
3
4
  booleanConfigHelper,
4
5
  getConfigFromMappings,
5
6
  getDefaultConfig,
6
7
  numberConfigHelper,
7
8
  optionalNumberConfigHelper,
9
+ pickConfigMappings,
10
+ secretFrConfigHelper,
11
+ secretStringConfigHelper,
8
12
  } from '@aztec/foundation/config';
9
- import { Fr } from '@aztec/foundation/fields';
13
+ import { Fr } from '@aztec/foundation/curves/bn254';
10
14
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
11
- import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
12
- import { type ZodFor, schemas } from '@aztec/stdlib/schemas';
15
+ import { protocolContractsHash } from '@aztec/protocol-contracts';
16
+ import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
17
+ import { schemas, zodFor } from '@aztec/stdlib/schemas';
13
18
  import type { ComponentsVersions } from '@aztec/stdlib/versioning';
14
19
 
15
20
  import { z } from 'zod';
16
21
 
17
- const BotFollowChain = ['NONE', 'PENDING', 'PROVEN'] as const;
22
+ const BotFollowChain = ['NONE', 'PROPOSED', 'CHECKPOINTED', 'PROVEN'] as const;
18
23
  type BotFollowChain = (typeof BotFollowChain)[number];
19
24
 
25
+ const BotMode = ['transfer', 'amm', 'crosschain'] as const;
26
+ type BotMode = (typeof BotMode)[number];
27
+
20
28
  export enum SupportedTokenContracts {
21
29
  TokenContract = 'TokenContract',
22
- EasyPrivateTokenContract = 'EasyPrivateTokenContract',
30
+ PrivateTokenContract = 'PrivateTokenContract',
23
31
  }
24
32
 
25
33
  export type BotConfig = {
26
34
  /** The URL to the Aztec node to check for tx pool status. */
27
35
  nodeUrl: string | undefined;
28
- /** URL to the PXE for sending txs, or undefined if an in-proc PXE is used. */
29
- pxeUrl: string | undefined;
36
+ /** The URL to the Aztec node admin API to force-flush txs if configured. */
37
+ nodeAdminUrl: string | undefined;
30
38
  /** Url of the ethereum host. */
31
39
  l1RpcUrls: string[] | undefined;
32
40
  /** The mnemonic for the account to bridge fee juice from L1. */
33
- l1Mnemonic: string | undefined;
41
+ l1Mnemonic: SecretValue<string> | undefined;
34
42
  /** The private key for the account to bridge fee juice from L1. */
35
- l1PrivateKey: string | undefined;
43
+ l1PrivateKey: SecretValue<string> | undefined;
44
+ /** How long to wait for L1 to L2 messages to become available on L2 */
45
+ l1ToL2MessageTimeoutSeconds: number;
36
46
  /** Signing private key for the sender account. */
37
- senderPrivateKey: Fr | undefined;
38
- /** Encryption secret for a recipient account. */
39
- recipientEncryptionSecret: Fr;
40
- /** Salt for the token contract deployment. */
47
+ senderPrivateKey: SecretValue<Fr> | undefined;
48
+ /** Optional salt to use to instantiate the sender account */
49
+ senderSalt: Fr | undefined;
50
+ /** Salt for the token contract instantiation. */
41
51
  tokenSalt: Fr;
42
52
  /** Every how many seconds should a new tx be sent. */
43
53
  txIntervalSeconds: number;
@@ -47,6 +57,8 @@ export type BotConfig = {
47
57
  publicTransfersPerTx: number;
48
58
  /** How to handle fee payments. */
49
59
  feePaymentMethod: 'fee_juice';
60
+ /** 'How much is the bot willing to overpay vs. the current min fee' */
61
+ minFeePadding: number;
50
62
  /** True to not automatically setup or start the bot on initialization. */
51
63
  noStart: boolean;
52
64
  /** How long to wait for a tx to be mined before reporting an error. */
@@ -57,8 +69,6 @@ export type BotConfig = {
57
69
  maxPendingTxs: number;
58
70
  /** Whether to flush after sending each 'setup' transaction */
59
71
  flushSetupTransactions: boolean;
60
- /** Whether to skip public simulation of txs before sending them. */
61
- skipPublicSimulation: boolean;
62
72
  /** L2 gas limit for the tx (empty to have the bot trigger an estimate gas). */
63
73
  l2GasLimit: number | undefined;
64
74
  /** DA gas limit for the tx (empty to have the bot trigger an estimate gas). */
@@ -69,54 +79,70 @@ export type BotConfig = {
69
79
  maxConsecutiveErrors: number;
70
80
  /** Stops the bot if service becomes unhealthy */
71
81
  stopWhenUnhealthy: boolean;
72
- };
82
+ /** Bot mode: transfer, amm, or crosschain. */
83
+ botMode: BotMode;
84
+ /** Number of L2→L1 messages per tx (crosschain mode). */
85
+ l2ToL1MessagesPerTx: number;
86
+ /** Max L1→L2 messages to keep in-flight (crosschain mode). */
87
+ l1ToL2SeedCount: number;
88
+ } & Pick<DataStoreConfig, 'dataDirectory' | 'dataStoreMapSizeKb'>;
73
89
 
74
- export const BotConfigSchema = z
75
- .object({
76
- nodeUrl: z.string().optional(),
77
- pxeUrl: z.string().optional(),
78
- l1RpcUrls: z.array(z.string()).optional(),
79
- l1Mnemonic: z.string().optional(),
80
- l1PrivateKey: z.string().optional(),
81
- senderPrivateKey: schemas.Fr.optional(),
82
- recipientEncryptionSecret: schemas.Fr,
83
- tokenSalt: schemas.Fr,
84
- txIntervalSeconds: z.number(),
85
- privateTransfersPerTx: z.number().int().nonnegative(),
86
- publicTransfersPerTx: z.number().int().nonnegative(),
87
- feePaymentMethod: z.literal('fee_juice'),
88
- noStart: z.boolean(),
89
- txMinedWaitSeconds: z.number(),
90
- followChain: z.enum(BotFollowChain),
91
- maxPendingTxs: z.number().int().nonnegative(),
92
- flushSetupTransactions: z.boolean(),
93
- skipPublicSimulation: z.boolean(),
94
- l2GasLimit: z.number().int().nonnegative().optional(),
95
- daGasLimit: z.number().int().nonnegative().optional(),
96
- contract: z.nativeEnum(SupportedTokenContracts),
97
- maxConsecutiveErrors: z.number().int().nonnegative(),
98
- stopWhenUnhealthy: z.boolean(),
99
- })
100
- .transform(config => ({
101
- nodeUrl: undefined,
102
- pxeUrl: undefined,
103
- l1RpcUrls: undefined,
104
- l1Mnemonic: undefined,
105
- l1PrivateKey: undefined,
106
- senderPrivateKey: undefined,
107
- l2GasLimit: undefined,
108
- daGasLimit: undefined,
109
- ...config,
110
- })) satisfies ZodFor<BotConfig>;
90
+ export const BotConfigSchema = zodFor<BotConfig>()(
91
+ z
92
+ .object({
93
+ nodeUrl: z.string().optional(),
94
+ nodeAdminUrl: z.string().optional(),
95
+ l1RpcUrls: z.array(z.string()).optional(),
96
+ l1Mnemonic: schemas.SecretValue(z.string()).optional(),
97
+ l1PrivateKey: schemas.SecretValue(z.string()).optional(),
98
+ l1ToL2MessageTimeoutSeconds: z.number(),
99
+ senderPrivateKey: schemas.SecretValue(schemas.Fr).optional(),
100
+ senderSalt: schemas.Fr.optional(),
101
+ tokenSalt: schemas.Fr,
102
+ txIntervalSeconds: z.number(),
103
+ privateTransfersPerTx: z.number().int().nonnegative(),
104
+ publicTransfersPerTx: z.number().int().nonnegative(),
105
+ feePaymentMethod: z.literal('fee_juice'),
106
+ minFeePadding: z.number().int().nonnegative(),
107
+ noStart: z.boolean(),
108
+ txMinedWaitSeconds: z.number(),
109
+ followChain: z.enum(BotFollowChain),
110
+ maxPendingTxs: z.number().int().nonnegative(),
111
+ flushSetupTransactions: z.boolean(),
112
+ l2GasLimit: z.number().int().nonnegative().optional(),
113
+ daGasLimit: z.number().int().nonnegative().optional(),
114
+ contract: z.nativeEnum(SupportedTokenContracts),
115
+ maxConsecutiveErrors: z.number().int().nonnegative(),
116
+ stopWhenUnhealthy: z.boolean(),
117
+ botMode: z.enum(BotMode).default('transfer'),
118
+ l2ToL1MessagesPerTx: z.number().int().nonnegative().default(1),
119
+ l1ToL2SeedCount: z.number().int().nonnegative().default(1),
120
+ dataDirectory: z.string().optional(),
121
+ dataStoreMapSizeKb: z.number().optional(),
122
+ })
123
+ .transform(config => ({
124
+ nodeUrl: undefined,
125
+ nodeAdminUrl: undefined,
126
+ l1RpcUrls: undefined,
127
+ senderSalt: undefined,
128
+ l2GasLimit: undefined,
129
+ daGasLimit: undefined,
130
+ l1Mnemonic: undefined,
131
+ l1PrivateKey: undefined,
132
+ senderPrivateKey: undefined,
133
+ dataStoreMapSizeKb: 1_024 * 1_024,
134
+ ...config,
135
+ })),
136
+ );
111
137
 
112
138
  export const botConfigMappings: ConfigMappingsType<BotConfig> = {
113
139
  nodeUrl: {
114
140
  env: 'AZTEC_NODE_URL',
115
141
  description: 'The URL to the Aztec node to check for tx pool status.',
116
142
  },
117
- pxeUrl: {
118
- env: 'BOT_PXE_URL',
119
- description: 'URL to the PXE for sending txs, or undefined if an in-proc PXE is used.',
143
+ nodeAdminUrl: {
144
+ env: 'AZTEC_NODE_ADMIN_URL',
145
+ description: 'The URL to the Aztec node admin API to force-flush txs if configured.',
120
146
  },
121
147
  l1RpcUrls: {
122
148
  env: 'ETHEREUM_HOSTS',
@@ -126,25 +152,31 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
126
152
  l1Mnemonic: {
127
153
  env: 'BOT_L1_MNEMONIC',
128
154
  description: 'The mnemonic for the account to bridge fee juice from L1.',
155
+ ...secretStringConfigHelper(),
129
156
  },
130
157
  l1PrivateKey: {
131
158
  env: 'BOT_L1_PRIVATE_KEY',
132
159
  description: 'The private key for the account to bridge fee juice from L1.',
160
+ ...secretStringConfigHelper(),
161
+ },
162
+ l1ToL2MessageTimeoutSeconds: {
163
+ env: 'BOT_L1_TO_L2_TIMEOUT_SECONDS',
164
+ description: 'How long to wait for L1 to L2 messages to become available on L2',
165
+ ...numberConfigHelper(3600),
133
166
  },
134
167
  senderPrivateKey: {
135
168
  env: 'BOT_PRIVATE_KEY',
136
169
  description: 'Signing private key for the sender account.',
137
- parseEnv: (val: string) => (val ? Fr.fromHexString(val) : undefined),
170
+ ...secretFrConfigHelper(),
138
171
  },
139
- recipientEncryptionSecret: {
140
- env: 'BOT_RECIPIENT_ENCRYPTION_SECRET',
141
- description: 'Encryption secret for a recipient account.',
142
- parseEnv: (val: string) => Fr.fromHexString(val),
143
- defaultValue: Fr.fromHexString('0xcafecafe'),
172
+ senderSalt: {
173
+ env: 'BOT_ACCOUNT_SALT',
174
+ description: 'The salt to use to deploy the sender account.',
175
+ parseEnv: (val: string) => (val ? Fr.fromHexString(val) : undefined),
144
176
  },
145
177
  tokenSalt: {
146
178
  env: 'BOT_TOKEN_SALT',
147
- description: 'Salt for the token contract deployment.',
179
+ description: 'The salt to use to deploy the token contract.',
148
180
  parseEnv: (val: string) => Fr.fromHexString(val),
149
181
  defaultValue: Fr.fromHexString('1'),
150
182
  },
@@ -169,6 +201,11 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
169
201
  parseEnv: val => (val as 'fee_juice') || undefined,
170
202
  defaultValue: 'fee_juice',
171
203
  },
204
+ minFeePadding: {
205
+ env: 'BOT_MIN_FEE_PADDING',
206
+ description: 'How much is the bot willing to overpay vs. the current base fee',
207
+ ...numberConfigHelper(3),
208
+ },
172
209
  noStart: {
173
210
  env: 'BOT_NO_START',
174
211
  description: 'True to not automatically setup or start the bot on initialization.',
@@ -184,10 +221,14 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
184
221
  description: 'Which chain the bot follows',
185
222
  defaultValue: 'NONE',
186
223
  parseEnv(val) {
187
- if (!(BotFollowChain as readonly string[]).includes(val.toUpperCase())) {
224
+ const upper = val.toUpperCase();
225
+ if (upper === 'PENDING') {
226
+ return 'CHECKPOINTED';
227
+ }
228
+ if (!(BotFollowChain as readonly string[]).includes(upper)) {
188
229
  throw new Error(`Invalid value for BOT_FOLLOW_CHAIN: ${val}`);
189
230
  }
190
- return val as BotFollowChain;
231
+ return upper as BotFollowChain;
191
232
  },
192
233
  },
193
234
  maxPendingTxs: {
@@ -200,11 +241,6 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
200
241
  description: 'Make a request for the sequencer to build a block after each setup transaction.',
201
242
  ...booleanConfigHelper(false),
202
243
  },
203
- skipPublicSimulation: {
204
- env: 'BOT_SKIP_PUBLIC_SIMULATION',
205
- description: 'Whether to skip public simulation of txs before sending them.',
206
- ...booleanConfigHelper(false),
207
- },
208
244
  l2GasLimit: {
209
245
  env: 'BOT_L2_GAS_LIMIT',
210
246
  description: 'L2 gas limit for the tx (empty to have the bot trigger an estimate gas).',
@@ -240,6 +276,28 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
240
276
  description: 'Stops the bot if service becomes unhealthy',
241
277
  ...booleanConfigHelper(false),
242
278
  },
279
+ botMode: {
280
+ env: 'BOT_MODE',
281
+ description: 'Bot mode: transfer, amm, or crosschain',
282
+ defaultValue: 'transfer' as BotMode,
283
+ parseEnv(val: string) {
284
+ if (!(BotMode as readonly string[]).includes(val)) {
285
+ throw new Error(`Invalid value for BOT_MODE: ${val}`);
286
+ }
287
+ return val as BotMode;
288
+ },
289
+ },
290
+ l2ToL1MessagesPerTx: {
291
+ env: 'BOT_L2_TO_L1_MESSAGES_PER_TX',
292
+ description: 'Number of L2→L1 messages per tx (crosschain mode)',
293
+ ...numberConfigHelper(1),
294
+ },
295
+ l1ToL2SeedCount: {
296
+ env: 'BOT_L1_TO_L2_SEED_COUNT',
297
+ description: 'Max L1→L2 messages to keep in-flight (crosschain mode)',
298
+ ...numberConfigHelper(1),
299
+ },
300
+ ...pickConfigMappings(dataConfigMappings, ['dataStoreMapSizeKb', 'dataDirectory']),
243
301
  };
244
302
 
245
303
  export function getBotConfigFromEnv(): BotConfig {
@@ -252,7 +310,7 @@ export function getBotDefaultConfig(): BotConfig {
252
310
 
253
311
  export function getVersions(): Partial<ComponentsVersions> {
254
312
  return {
255
- l2ProtocolContractsTreeRoot: protocolContractTreeRoot.toString(),
313
+ l2ProtocolContractsHash: protocolContractsHash.toString(),
256
314
  l2CircuitsVkTreeRoot: getVKTreeRoot().toString(),
257
315
  };
258
316
  }