Skip to content

Commit a80ba8a

Browse files
committed
ci: batch accountant VAAs
1 parent edbb89e commit a80ba8a

File tree

3 files changed

+33
-33
lines changed

3 files changed

+33
-33
lines changed

sdk/__tests__/accountant.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const url = process.env["CI"]
1919
? "http://wormchain:26657"
2020
: "http://localhost:26659";
2121

22-
export async function submitAccountantVAA(vaa: Uint8Array) {
22+
export async function submitAccountantVAAs(vaas: Uint8Array[]) {
2323
if (!signer) {
2424
// NttAccountantTest = wormhole18s5lynnmx37hq4wlrw9gdn68sg2uxp5rwf5k3u
2525
const wallet = await getWallet(privateKey);
@@ -34,15 +34,15 @@ export async function submitAccountantVAA(vaa: Uint8Array) {
3434
msg: encoding.bytes.encode(
3535
JSON.stringify({
3636
submit_vaas: {
37-
vaas: [encoding.b64.encode(vaa)],
37+
vaas: vaas.map((vaa) => encoding.b64.encode(vaa)),
3838
},
3939
})
4040
),
4141
funds: [],
4242
});
4343
const result = await client.signAndBroadcast(signer, [msg], {
4444
...ZERO_FEE,
45-
gas: "10000000",
45+
gas: (BigInt("10000000") * BigInt(vaas.length)).toString(),
4646
});
4747
if (result.code !== 0) {
4848
throw new Error(`Bad result: ${result.rawLog}`);

sdk/__tests__/index.test.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Chain } from "@wormhole-foundation/sdk-base";
22
import { deploy, link, transferWithChecks, wh } from "./utils.js";
3-
import { submitAccountantVAA } from "./accountant.js";
3+
import { submitAccountantVAAs } from "./accountant.js";
44

55
// Note: Currently, in order for this to run, the evm bindings with extra contracts must be build
66
// To do that, at the root, run `npm run generate:test`
@@ -13,23 +13,20 @@ const cases = [
1313

1414
async function registerRelayers() {
1515
try {
16-
await submitAccountantVAA(
17-
Buffer.from(
18-
"01000000000100a4f34c530ff196c060ff349f2bf7bcb16865771a7165ca84fb5e263f148a01b03592b9af46a410a3760f39097d7380e4e72b6e1da4fa25c2d7b2d00f102d0cae0100000000000000000001000000000000000000000000000000000000000000000000000000000000000400000000001ce9cf010000000000000000000000000000000000576f726d686f6c6552656c617965720100000002000000000000000000000000cc680d088586c09c3e0e099a676fa4b6e42467b4",
19-
"hex"
20-
)
21-
);
22-
} catch (e) {
23-
console.log(e);
24-
}
25-
26-
try {
27-
await submitAccountantVAA(
28-
Buffer.from(
29-
"010000000001000fd839cfdbea0f43a35dbb8cc0219b55cd5ec9f59b7e4a7183dbeebd522f7c673c866a218bfa108d8c7606acb5fc6b94a7a4c3be06f10836c242afecdb80da6e00000000000000000000010000000000000000000000000000000000000000000000000000000000000004000000000445fb0b010000000000000000000000000000000000576f726d686f6c6552656c617965720100000004000000000000000000000000cc680d088586c09c3e0e099a676fa4b6e42467b4",
30-
"hex"
31-
)
32-
);
16+
await submitAccountantVAAs([
17+
new Uint8Array(
18+
Buffer.from(
19+
"01000000000100a4f34c530ff196c060ff349f2bf7bcb16865771a7165ca84fb5e263f148a01b03592b9af46a410a3760f39097d7380e4e72b6e1da4fa25c2d7b2d00f102d0cae0100000000000000000001000000000000000000000000000000000000000000000000000000000000000400000000001ce9cf010000000000000000000000000000000000576f726d686f6c6552656c617965720100000002000000000000000000000000cc680d088586c09c3e0e099a676fa4b6e42467b4",
20+
"hex"
21+
)
22+
),
23+
new Uint8Array(
24+
Buffer.from(
25+
"010000000001000fd839cfdbea0f43a35dbb8cc0219b55cd5ec9f59b7e4a7183dbeebd522f7c673c866a218bfa108d8c7606acb5fc6b94a7a4c3be06f10836c242afecdb80da6e00000000000000000000010000000000000000000000000000000000000000000000000000000000000004000000000445fb0b010000000000000000000000000000000000576f726d686f6c6552656c617965720100000004000000000000000000000000cc680d088586c09c3e0e099a676fa4b6e42467b4",
26+
"hex"
27+
)
28+
),
29+
]);
3330
} catch (e) {
3431
console.log(e);
3532
}

sdk/__tests__/utils.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ import { WormholeTransceiver__factory } from "../../evm/ts/ethers-ci-contracts/f
3434

3535
import solanaTiltKey from "./solana-tilt.json"; // from https://github.com/wormhole-foundation/wormhole/blob/main/solana/keys/solana-devnet.json
3636

37-
import { Ntt } from "../definitions/src/index.js";
3837
import "../../evm/ts/src/index.js";
3938
import "../../solana/ts/sdk/index.js";
4039
import { NTT } from "../../solana/ts/lib/index.js";
4140
import { SolanaNtt } from "../../solana/ts/sdk/index.js";
42-
import { submitAccountantVAA } from "./accountant.js";
41+
import { Ntt } from "../definitions/src/index.js";
42+
import { submitAccountantVAAs } from "./accountant.js";
4343

4444
// Note: Currently, in order for this to run, the evm bindings with extra contracts must be build
4545
// To do that, at the root, run `npm run generate:test`
@@ -134,7 +134,7 @@ export async function link(chainInfos: Ctx[]) {
134134
};
135135

136136
const vaa = await wh.getVaa(msgId, "Ntt:TransceiverInfo");
137-
await submitAccountantVAA(serialize(vaa!));
137+
const vaas: Uint8Array[] = [serialize(vaa!)];
138138

139139
// [target, peer, vaa]
140140
const registrations: [string, string, VAA<"Ntt:TransceiverRegistration">][] =
@@ -164,47 +164,50 @@ export async function link(chainInfos: Ctx[]) {
164164
}
165165
}
166166

167-
// Submit Hub to Spoke registrations
167+
// Push Hub to Spoke registrations
168168
const hubToSpokeRegistrations = registrations.filter(
169169
([_, peer]) => peer === hubChain
170170
);
171171
for (const [, , vaa] of hubToSpokeRegistrations) {
172172
console.log(
173-
"Submitting hub to spoke registrations: ",
173+
"Pushing hub to spoke registrations: ",
174174
vaa.emitterChain,
175175
vaa.payload.chain,
176176
vaa.payload.transceiver.toString()
177177
);
178-
await submitAccountantVAA(serialize(vaa));
178+
vaas.push(serialize(vaa));
179179
}
180180

181-
// Submit Spoke to Hub registrations
181+
// Push Spoke to Hub registrations
182182
const spokeToHubRegistrations = registrations.filter(
183183
([target, _]) => target === hubChain
184184
);
185185
for (const [, , vaa] of spokeToHubRegistrations) {
186186
console.log(
187-
"Submitting spoke to hub registrations: ",
187+
"Pushing spoke to hub registrations: ",
188188
vaa.emitterChain,
189189
vaa.payload.chain,
190190
vaa.payload.transceiver.toString()
191191
);
192-
await submitAccountantVAA(serialize(vaa));
192+
vaas.push(serialize(vaa));
193193
}
194194

195-
// Submit all other registrations
195+
// Push all other registrations
196196
const spokeToSpokeRegistrations = registrations.filter(
197197
([target, peer]) => target !== hubChain && peer !== hubChain
198198
);
199199
for (const [, , vaa] of spokeToSpokeRegistrations) {
200200
console.log(
201-
"Submitting spoke to spoke registrations: ",
201+
"Pushing spoke to spoke registrations: ",
202202
vaa.emitterChain,
203203
vaa.payload.chain,
204204
vaa.payload.transceiver.toString()
205205
);
206-
await submitAccountantVAA(serialize(vaa));
206+
vaas.push(serialize(vaa));
207207
}
208+
209+
// Submit all registrations at once
210+
await submitAccountantVAAs(vaas);
208211
}
209212

210213
export async function transferWithChecks(sourceCtx: Ctx, destinationCtx: Ctx) {

0 commit comments

Comments
 (0)