@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.
- package/dest/amm_bot.d.ts +32 -0
- package/dest/amm_bot.d.ts.map +1 -0
- package/dest/amm_bot.js +108 -0
- package/dest/base_bot.d.ts +21 -0
- package/dest/base_bot.d.ts.map +1 -0
- package/dest/base_bot.js +79 -0
- package/dest/bot.d.ts +13 -18
- package/dest/bot.d.ts.map +1 -1
- package/dest/bot.js +26 -84
- package/dest/config.d.ts +106 -66
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +89 -39
- package/dest/cross_chain_bot.d.ts +54 -0
- package/dest/cross_chain_bot.d.ts.map +1 -0
- package/dest/cross_chain_bot.js +134 -0
- package/dest/factory.d.ts +43 -29
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +380 -139
- package/dest/index.d.ts +5 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +4 -1
- package/dest/interface.d.ts +12 -1
- package/dest/interface.d.ts.map +1 -1
- package/dest/interface.js +5 -0
- package/dest/l1_to_l2_seeding.d.ts +8 -0
- package/dest/l1_to_l2_seeding.d.ts.map +1 -0
- package/dest/l1_to_l2_seeding.js +63 -0
- package/dest/rpc.d.ts +1 -7
- package/dest/rpc.d.ts.map +1 -1
- package/dest/rpc.js +0 -11
- package/dest/runner.d.ts +15 -11
- package/dest/runner.d.ts.map +1 -1
- package/dest/runner.js +457 -51
- package/dest/store/bot_store.d.ts +69 -0
- package/dest/store/bot_store.d.ts.map +1 -0
- package/dest/store/bot_store.js +138 -0
- package/dest/store/index.d.ts +2 -0
- package/dest/store/index.d.ts.map +1 -0
- package/dest/store/index.js +1 -0
- package/dest/utils.d.ts +8 -5
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +14 -5
- package/package.json +30 -23
- package/src/amm_bot.ts +129 -0
- package/src/base_bot.ts +82 -0
- package/src/bot.ts +52 -101
- package/src/config.ts +129 -71
- package/src/cross_chain_bot.ts +203 -0
- package/src/factory.ts +476 -152
- package/src/index.ts +4 -1
- package/src/interface.ts +9 -0
- package/src/l1_to_l2_seeding.ts +79 -0
- package/src/rpc.ts +0 -13
- package/src/runner.ts +51 -21
- package/src/store/bot_store.ts +196 -0
- package/src/store/index.ts +1 -0
- package/src/utils.ts +17 -6
package/src/bot.ts
CHANGED
|
@@ -1,40 +1,47 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 {
|
|
13
|
-
import {
|
|
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
|
-
|
|
30
|
-
|
|
20
|
+
node: AztecNode,
|
|
21
|
+
wallet: EmbeddedWallet,
|
|
22
|
+
defaultAccountAddress: AztecAddress,
|
|
23
|
+
public readonly token: TokenContract | PrivateTokenContract,
|
|
31
24
|
public readonly recipient: AztecAddress,
|
|
32
|
-
|
|
33
|
-
) {
|
|
25
|
+
config: BotConfig,
|
|
26
|
+
) {
|
|
27
|
+
super(node, wallet, defaultAccountAddress, config);
|
|
28
|
+
}
|
|
34
29
|
|
|
35
|
-
static async create(
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
46
|
-
this.
|
|
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
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
99
|
-
|
|
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.
|
|
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.
|
|
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/
|
|
13
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
10
14
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
11
|
-
import {
|
|
12
|
-
import { type
|
|
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', '
|
|
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
|
-
|
|
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
|
|
29
|
-
|
|
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
|
-
/**
|
|
39
|
-
|
|
40
|
-
/** Salt for the token contract
|
|
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 =
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
|
|
118
|
-
env: '
|
|
119
|
-
description: 'URL to the
|
|
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
|
-
|
|
170
|
+
...secretFrConfigHelper(),
|
|
138
171
|
},
|
|
139
|
-
|
|
140
|
-
env: '
|
|
141
|
-
description: '
|
|
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: '
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
313
|
+
l2ProtocolContractsHash: protocolContractsHash.toString(),
|
|
256
314
|
l2CircuitsVkTreeRoot: getVKTreeRoot().toString(),
|
|
257
315
|
};
|
|
258
316
|
}
|