@aztec/bot 0.0.1-commit.a89ec08 → 0.0.1-commit.aa0c64f
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 +4 -3
- package/dest/amm_bot.d.ts.map +1 -1
- package/dest/amm_bot.js +2 -2
- package/dest/base_bot.d.ts +2 -2
- package/dest/base_bot.d.ts.map +1 -1
- package/dest/bot.d.ts +3 -2
- package/dest/bot.d.ts.map +1 -1
- package/dest/bot.js +2 -2
- package/dest/config.d.ts +29 -80
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +4 -5
- package/dest/cross_chain_bot.d.ts +6 -4
- package/dest/cross_chain_bot.d.ts.map +1 -1
- package/dest/cross_chain_bot.js +13 -9
- package/dest/factory.d.ts +17 -7
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +235 -168
- package/dest/interface.d.ts +2 -6
- package/dest/interface.d.ts.map +1 -1
- package/dest/interface.js +30 -7
- package/dest/runner.d.ts +3 -2
- package/dest/runner.d.ts.map +1 -1
- package/dest/runner.js +6 -4
- package/package.json +16 -16
- package/src/amm_bot.ts +4 -1
- package/src/base_bot.ts +2 -1
- package/src/bot.ts +3 -0
- package/src/config.ts +4 -4
- package/src/cross_chain_bot.ts +11 -6
- package/src/factory.ts +233 -187
- package/src/interface.ts +7 -7
- package/src/runner.ts +26 -3
package/dest/interface.js
CHANGED
|
@@ -5,11 +5,34 @@ export const BotInfoSchema = z.object({
|
|
|
5
5
|
botAddress: AztecAddress.schema
|
|
6
6
|
});
|
|
7
7
|
export const BotRunnerApiSchema = {
|
|
8
|
-
start: z.function(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
start: z.function({
|
|
9
|
+
input: z.tuple([]),
|
|
10
|
+
output: z.void()
|
|
11
|
+
}),
|
|
12
|
+
stop: z.function({
|
|
13
|
+
input: z.tuple([]),
|
|
14
|
+
output: z.void()
|
|
15
|
+
}),
|
|
16
|
+
run: z.function({
|
|
17
|
+
input: z.tuple([]),
|
|
18
|
+
output: z.void()
|
|
19
|
+
}),
|
|
20
|
+
setup: z.function({
|
|
21
|
+
input: z.tuple([]),
|
|
22
|
+
output: z.void()
|
|
23
|
+
}),
|
|
24
|
+
getInfo: z.function({
|
|
25
|
+
input: z.tuple([]),
|
|
26
|
+
output: BotInfoSchema
|
|
27
|
+
}),
|
|
28
|
+
getConfig: z.function({
|
|
29
|
+
input: z.tuple([]),
|
|
30
|
+
output: BotConfigSchema
|
|
31
|
+
}),
|
|
32
|
+
update: z.function({
|
|
33
|
+
input: z.tuple([
|
|
34
|
+
BotConfigSchema
|
|
35
|
+
]),
|
|
36
|
+
output: z.void()
|
|
37
|
+
})
|
|
15
38
|
};
|
package/dest/runner.d.ts
CHANGED
|
@@ -13,13 +13,14 @@ export declare class BotRunner implements BotRunnerApi, Traceable {
|
|
|
13
13
|
private readonly telemetry;
|
|
14
14
|
private readonly aztecNodeAdmin;
|
|
15
15
|
private readonly store;
|
|
16
|
+
private readonly syncChainTip?;
|
|
16
17
|
private log;
|
|
17
18
|
private bot?;
|
|
18
19
|
private runningPromise;
|
|
19
20
|
private consecutiveErrors;
|
|
20
21
|
private healthy;
|
|
21
22
|
readonly tracer: Tracer;
|
|
22
|
-
constructor(config: BotConfig, wallet: EmbeddedWallet, aztecNode: AztecNode, telemetry: TelemetryClient, aztecNodeAdmin: AztecNodeAdmin | undefined, store: BotStore);
|
|
23
|
+
constructor(config: BotConfig, wallet: EmbeddedWallet, aztecNode: AztecNode, telemetry: TelemetryClient, aztecNodeAdmin: AztecNodeAdmin | undefined, store: BotStore, syncChainTip?: "checkpointed" | "finalized" | "latest" | "proposed" | "proven" | undefined);
|
|
23
24
|
/** Initializes the bot if needed. Blocks until the bot setup is finished. */
|
|
24
25
|
setup(): Promise<void>;
|
|
25
26
|
private doSetup;
|
|
@@ -50,4 +51,4 @@ export declare class BotRunner implements BotRunnerApi, Traceable {
|
|
|
50
51
|
/** Returns the bot sender address. */
|
|
51
52
|
getInfo(): Promise<BotInfo>;
|
|
52
53
|
}
|
|
53
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
54
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicnVubmVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvcnVubmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBSXRELE9BQU8sS0FBSyxFQUFFLGNBQWMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ3RFLE9BQU8sRUFBRSxLQUFLLGVBQWUsRUFBRSxLQUFLLFNBQVMsRUFBRSxLQUFLLE1BQU0sRUFBYSxNQUFNLHlCQUF5QixDQUFDO0FBQ3ZHLE9BQU8sS0FBSyxFQUFFLGNBQWMsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBSzlELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUU3QyxPQUFPLEtBQUssRUFBRSxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sZ0JBQWdCLENBQUM7QUFDNUQsT0FBTyxFQUFFLFFBQVEsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRTVDLHFCQUFhLFNBQVUsWUFBVyxZQUFZLEVBQUUsU0FBUzs7SUFVckQsT0FBTyxDQUFDLE1BQU07SUFDZCxPQUFPLENBQUMsUUFBUSxDQUFDLE1BQU07SUFDdkIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxTQUFTO0lBQzFCLE9BQU8sQ0FBQyxRQUFRLENBQUMsU0FBUztJQUMxQixPQUFPLENBQUMsUUFBUSxDQUFDLGNBQWM7SUFDL0IsT0FBTyxDQUFDLFFBQVEsQ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,KAAK,EAAE,QAAQ,EACf,YAAY,CAAC,6EAAU,EAKzC;IAED,6EAA6E;IAChE,KAAK,kBAIjB;YAGa,OAAO;IAMrB;;;OAGG;IACU,KAAK,kBAMjB;IAED;;OAEG;IACU,IAAI,kBAOhB;IAEM,SAAS,YAEf;IAED,0CAA0C;IACnC,SAAS,YAEf;IAED;;;OAGG;IACU,MAAM,CAAC,MAAM,EAAE,SAAS,iBAapC;IAED;;;OAGG;IACU,GAAG,kBAsBf;IAED,qDAAqD;IAC9C,SAAS,uBAGf;IAED,sCAAsC;IACzB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAMvC;CAwEF"}
|
package/dest/runner.js
CHANGED
|
@@ -386,6 +386,7 @@ export class BotRunner {
|
|
|
386
386
|
telemetry;
|
|
387
387
|
aztecNodeAdmin;
|
|
388
388
|
store;
|
|
389
|
+
syncChainTip;
|
|
389
390
|
static{
|
|
390
391
|
({ e: [_call_work, _initProto] } = _apply_decs_2203_r(this, [
|
|
391
392
|
[
|
|
@@ -428,13 +429,14 @@ export class BotRunner {
|
|
|
428
429
|
consecutiveErrors;
|
|
429
430
|
healthy;
|
|
430
431
|
tracer;
|
|
431
|
-
constructor(config, wallet, aztecNode, telemetry, aztecNodeAdmin, store){
|
|
432
|
+
constructor(config, wallet, aztecNode, telemetry, aztecNodeAdmin, store, syncChainTip){
|
|
432
433
|
this.config = config;
|
|
433
434
|
this.wallet = wallet;
|
|
434
435
|
this.aztecNode = aztecNode;
|
|
435
436
|
this.telemetry = telemetry;
|
|
436
437
|
this.aztecNodeAdmin = aztecNodeAdmin;
|
|
437
438
|
this.store = store;
|
|
439
|
+
this.syncChainTip = syncChainTip;
|
|
438
440
|
this.log = (_initProto(this), createLogger('bot'));
|
|
439
441
|
this.consecutiveErrors = 0;
|
|
440
442
|
this.healthy = true;
|
|
@@ -538,13 +540,13 @@ export class BotRunner {
|
|
|
538
540
|
try {
|
|
539
541
|
switch(this.config.botMode){
|
|
540
542
|
case 'crosschain':
|
|
541
|
-
this.bot = CrossChainBot.create(this.config, this.wallet, this.aztecNode, this.aztecNodeAdmin, this.store);
|
|
543
|
+
this.bot = CrossChainBot.create(this.config, this.wallet, this.aztecNode, this.aztecNodeAdmin, this.store, this.syncChainTip);
|
|
542
544
|
break;
|
|
543
545
|
case 'amm':
|
|
544
|
-
this.bot = AmmBot.create(this.config, this.wallet, this.aztecNode, this.aztecNodeAdmin, this.store);
|
|
546
|
+
this.bot = AmmBot.create(this.config, this.wallet, this.aztecNode, this.aztecNodeAdmin, this.store, this.syncChainTip);
|
|
545
547
|
break;
|
|
546
548
|
case 'transfer':
|
|
547
|
-
this.bot = Bot.create(this.config, this.wallet, this.aztecNode, this.aztecNodeAdmin, this.store);
|
|
549
|
+
this.bot = Bot.create(this.config, this.wallet, this.aztecNode, this.aztecNodeAdmin, this.store, this.syncChainTip);
|
|
548
550
|
break;
|
|
549
551
|
default:
|
|
550
552
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/bot",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.aa0c64f",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -54,24 +54,24 @@
|
|
|
54
54
|
]
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@aztec/accounts": "0.0.1-commit.
|
|
58
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
59
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
60
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
61
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
62
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
63
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
64
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
65
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
66
|
-
"@aztec/noir-test-contracts.js": "0.0.1-commit.
|
|
67
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
68
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
69
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
70
|
-
"@aztec/wallets": "0.0.1-commit.
|
|
57
|
+
"@aztec/accounts": "0.0.1-commit.aa0c64f",
|
|
58
|
+
"@aztec/aztec.js": "0.0.1-commit.aa0c64f",
|
|
59
|
+
"@aztec/entrypoints": "0.0.1-commit.aa0c64f",
|
|
60
|
+
"@aztec/ethereum": "0.0.1-commit.aa0c64f",
|
|
61
|
+
"@aztec/foundation": "0.0.1-commit.aa0c64f",
|
|
62
|
+
"@aztec/kv-store": "0.0.1-commit.aa0c64f",
|
|
63
|
+
"@aztec/l1-artifacts": "0.0.1-commit.aa0c64f",
|
|
64
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.aa0c64f",
|
|
65
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.aa0c64f",
|
|
66
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.aa0c64f",
|
|
67
|
+
"@aztec/protocol-contracts": "0.0.1-commit.aa0c64f",
|
|
68
|
+
"@aztec/stdlib": "0.0.1-commit.aa0c64f",
|
|
69
|
+
"@aztec/telemetry-client": "0.0.1-commit.aa0c64f",
|
|
70
|
+
"@aztec/wallets": "0.0.1-commit.aa0c64f",
|
|
71
71
|
"source-map-support": "^0.5.21",
|
|
72
72
|
"tslib": "^2.4.0",
|
|
73
73
|
"viem": "npm:@aztec/viem@2.38.2",
|
|
74
|
-
"zod": "^
|
|
74
|
+
"zod": "^4"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@jest/globals": "^30.0.0",
|
package/src/amm_bot.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
2
|
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
3
3
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
4
|
-
import { TxHash, TxReceipt } from '@aztec/aztec.js/tx';
|
|
4
|
+
import type { TxHash, TxReceipt } from '@aztec/aztec.js/tx';
|
|
5
5
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
6
6
|
import type { AMMContract } from '@aztec/noir-contracts.js/AMM';
|
|
7
7
|
import type { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
8
|
+
import type { BlockTag } from '@aztec/stdlib/block';
|
|
8
9
|
import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
9
10
|
import type { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
10
11
|
|
|
@@ -37,6 +38,7 @@ export class AmmBot extends BaseBot {
|
|
|
37
38
|
aztecNode: AztecNode,
|
|
38
39
|
aztecNodeAdmin: AztecNodeAdmin | undefined,
|
|
39
40
|
store: BotStore,
|
|
41
|
+
syncChainTip?: BlockTag,
|
|
40
42
|
): Promise<AmmBot> {
|
|
41
43
|
const { defaultAccountAddress, token0, token1, amm } = await new BotFactory(
|
|
42
44
|
config,
|
|
@@ -44,6 +46,7 @@ export class AmmBot extends BaseBot {
|
|
|
44
46
|
store,
|
|
45
47
|
aztecNode,
|
|
46
48
|
aztecNodeAdmin,
|
|
49
|
+
syncChainTip,
|
|
47
50
|
).setupAmm();
|
|
48
51
|
return new AmmBot(aztecNode, wallet, defaultAccountAddress, amm, token0, token1, config);
|
|
49
52
|
}
|
package/src/base_bot.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
|
2
2
|
import type { SendInteractionOptions } from '@aztec/aztec.js/contracts';
|
|
3
3
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
4
4
|
import { waitForTx } from '@aztec/aztec.js/node';
|
|
5
|
-
import {
|
|
5
|
+
import { TxStatus } from '@aztec/aztec.js/tx';
|
|
6
|
+
import type { TxHash, TxReceipt } from '@aztec/aztec.js/tx';
|
|
6
7
|
import { Gas } from '@aztec/stdlib/gas';
|
|
7
8
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
8
9
|
import type { EmbeddedWallet } from '@aztec/wallets/embedded';
|
package/src/bot.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { TxHash } from '@aztec/aztec.js/tx';
|
|
|
4
4
|
import { times } from '@aztec/foundation/collection';
|
|
5
5
|
import type { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken';
|
|
6
6
|
import type { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
7
|
+
import type { BlockTag } from '@aztec/stdlib/block';
|
|
7
8
|
import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
8
9
|
import type { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
9
10
|
|
|
@@ -33,6 +34,7 @@ export class Bot extends BaseBot {
|
|
|
33
34
|
aztecNode: AztecNode,
|
|
34
35
|
aztecNodeAdmin: AztecNodeAdmin | undefined,
|
|
35
36
|
store: BotStore,
|
|
37
|
+
syncChainTip?: BlockTag,
|
|
36
38
|
): Promise<Bot> {
|
|
37
39
|
const { defaultAccountAddress, token, recipient } = await new BotFactory(
|
|
38
40
|
config,
|
|
@@ -40,6 +42,7 @@ export class Bot extends BaseBot {
|
|
|
40
42
|
store,
|
|
41
43
|
aztecNode,
|
|
42
44
|
aztecNodeAdmin,
|
|
45
|
+
syncChainTip,
|
|
43
46
|
).setup();
|
|
44
47
|
return new Bot(aztecNode, wallet, defaultAccountAddress, token, recipient, config);
|
|
45
48
|
}
|
package/src/config.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
type ConfigMappingsType,
|
|
3
3
|
SecretValue,
|
|
4
4
|
booleanConfigHelper,
|
|
5
|
+
floatConfigHelper,
|
|
5
6
|
getConfigFromMappings,
|
|
6
7
|
getDefaultConfig,
|
|
7
8
|
numberConfigHelper,
|
|
@@ -11,9 +12,9 @@ import {
|
|
|
11
12
|
secretStringConfigHelper,
|
|
12
13
|
} from '@aztec/foundation/config';
|
|
13
14
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
14
|
-
import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
|
|
15
15
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
16
16
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
17
|
+
import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
|
|
17
18
|
import { schemas, zodFor } from '@aztec/stdlib/schemas';
|
|
18
19
|
import type { ComponentsVersions } from '@aztec/stdlib/versioning';
|
|
19
20
|
|
|
@@ -103,7 +104,7 @@ export const BotConfigSchema = zodFor<BotConfig>()(
|
|
|
103
104
|
privateTransfersPerTx: z.number().int().nonnegative(),
|
|
104
105
|
publicTransfersPerTx: z.number().int().nonnegative(),
|
|
105
106
|
feePaymentMethod: z.literal('fee_juice'),
|
|
106
|
-
minFeePadding: z.number().
|
|
107
|
+
minFeePadding: z.number().nonnegative(),
|
|
107
108
|
noStart: z.boolean(),
|
|
108
109
|
txMinedWaitSeconds: z.number(),
|
|
109
110
|
followChain: z.enum(BotFollowChain),
|
|
@@ -130,7 +131,6 @@ export const BotConfigSchema = zodFor<BotConfig>()(
|
|
|
130
131
|
l1Mnemonic: undefined,
|
|
131
132
|
l1PrivateKey: undefined,
|
|
132
133
|
senderPrivateKey: undefined,
|
|
133
|
-
dataDirectory: undefined,
|
|
134
134
|
dataStoreMapSizeKb: 1_024 * 1_024,
|
|
135
135
|
...config,
|
|
136
136
|
})),
|
|
@@ -205,7 +205,7 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
|
|
|
205
205
|
minFeePadding: {
|
|
206
206
|
env: 'BOT_MIN_FEE_PADDING',
|
|
207
207
|
description: 'How much is the bot willing to overpay vs. the current base fee',
|
|
208
|
-
...
|
|
208
|
+
...floatConfigHelper(3),
|
|
209
209
|
},
|
|
210
210
|
noStart: {
|
|
211
211
|
env: 'BOT_NO_START',
|
package/src/cross_chain_bot.ts
CHANGED
|
@@ -26,11 +26,12 @@
|
|
|
26
26
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
27
27
|
import { BatchCall, NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
28
28
|
import { isL1ToL2MessageReady } from '@aztec/aztec.js/messaging';
|
|
29
|
-
import { TxHash, TxReceipt } from '@aztec/aztec.js/tx';
|
|
29
|
+
import type { TxHash, TxReceipt } from '@aztec/aztec.js/tx';
|
|
30
30
|
import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
|
|
31
31
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
32
32
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
33
33
|
import type { TestContract } from '@aztec/noir-test-contracts.js/Test';
|
|
34
|
+
import type { BlockTag } from '@aztec/stdlib/block';
|
|
34
35
|
import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
35
36
|
import type { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
36
37
|
|
|
@@ -60,6 +61,7 @@ export class CrossChainBot extends BaseBot {
|
|
|
60
61
|
private readonly rollupVersion: bigint,
|
|
61
62
|
private readonly store: BotStore,
|
|
62
63
|
config: BotConfig,
|
|
64
|
+
private readonly syncChainTip?: BlockTag,
|
|
63
65
|
) {
|
|
64
66
|
super(node, wallet, defaultAccountAddress, config);
|
|
65
67
|
}
|
|
@@ -70,11 +72,12 @@ export class CrossChainBot extends BaseBot {
|
|
|
70
72
|
aztecNode: AztecNode,
|
|
71
73
|
aztecNodeAdmin: AztecNodeAdmin | undefined,
|
|
72
74
|
store: BotStore,
|
|
75
|
+
syncChainTip?: BlockTag,
|
|
73
76
|
): Promise<CrossChainBot> {
|
|
74
77
|
if (config.followChain === 'NONE') {
|
|
75
78
|
throw new Error(`CrossChainBot requires followChain to be set (got NONE)`);
|
|
76
79
|
}
|
|
77
|
-
const factory = new BotFactory(config, wallet, store, aztecNode, aztecNodeAdmin);
|
|
80
|
+
const factory = new BotFactory(config, wallet, store, aztecNode, aztecNodeAdmin, syncChainTip);
|
|
78
81
|
const { defaultAccountAddress, contract, l1Client, rollupVersion } = await factory.setupCrossChain();
|
|
79
82
|
const l1Recipient = EthAddress.fromString(l1Client.account!.address);
|
|
80
83
|
const { l1ContractAddresses } = await aztecNode.getNodeInfo();
|
|
@@ -90,6 +93,7 @@ export class CrossChainBot extends BaseBot {
|
|
|
90
93
|
rollupVersion,
|
|
91
94
|
store,
|
|
92
95
|
config,
|
|
96
|
+
syncChainTip,
|
|
93
97
|
);
|
|
94
98
|
}
|
|
95
99
|
|
|
@@ -146,9 +150,10 @@ export class CrossChainBot extends BaseBot {
|
|
|
146
150
|
|
|
147
151
|
protected override async onTxMined(receipt: TxReceipt, logCtx: object): Promise<void> {
|
|
148
152
|
// Verify L2→L1 messages appeared in this tx's effects
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
153
|
+
const minedReceipt = await this.node.getTxReceipt(receipt.txHash, { includeTxEffect: true });
|
|
154
|
+
const l2ToL1MsgsRaw = minedReceipt.txEffect?.l2ToL1Msgs;
|
|
155
|
+
if (l2ToL1MsgsRaw) {
|
|
156
|
+
const l2ToL1Msgs = l2ToL1MsgsRaw.filter(m => !m.isZero());
|
|
152
157
|
if (l2ToL1Msgs.length >= this.config.l2ToL1MessagesPerTx) {
|
|
153
158
|
this.l2ToL1Sent += l2ToL1Msgs.length;
|
|
154
159
|
} else {
|
|
@@ -175,7 +180,7 @@ export class CrossChainBot extends BaseBot {
|
|
|
175
180
|
): Promise<PendingL1ToL2Message | undefined> {
|
|
176
181
|
const now = Date.now();
|
|
177
182
|
for (const msg of pendingMessages) {
|
|
178
|
-
const ready = await isL1ToL2MessageReady(this.node, Fr.fromHexString(msg.msgHash));
|
|
183
|
+
const ready = await isL1ToL2MessageReady(this.node, Fr.fromHexString(msg.msgHash), this.syncChainTip);
|
|
179
184
|
if (ready) {
|
|
180
185
|
return msg;
|
|
181
186
|
}
|