From 6f041bc1a069c3271f98d931cadbc3e95779026d Mon Sep 17 00:00:00 2001 From: hourglasshoro Date: Tue, 27 Feb 2024 10:19:51 -0700 Subject: [PATCH 1/6] add a rpc batch size param --- packages/cli/src/runDeploy.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/runDeploy.ts b/packages/cli/src/runDeploy.ts index 90e4ff556e..31009fc593 100644 --- a/packages/cli/src/runDeploy.ts +++ b/packages/cli/src/runDeploy.ts @@ -22,6 +22,10 @@ export const deployOptions = { profile: { type: "string", desc: "The foundry profile to use" }, saveDeployment: { type: "boolean", desc: "Save the deployment info to a file", default: true }, rpc: { type: "string", desc: "The RPC URL to use. Defaults to the RPC url from the local foundry.toml" }, + rpcBatchSize: { + type: "number", + desc: "Number of JSON-RPC HTTP requests processed in batch per second", + }, worldAddress: { type: "string", desc: "Deploy to an existing World at the given address" }, srcDir: { type: "string", desc: "Source directory. Defaults to foundry src directory." }, skipBuild: { type: "boolean", desc: "Skip rebuilding the contracts before deploying" }, @@ -81,7 +85,12 @@ in your contracts directory to use the default anvil private key.` const resolvedConfig = resolveConfig({ config, forgeSourceDir: srcDir, forgeOutDir: outDir }); const client = createWalletClient({ - transport: http(rpc), + transport: http(rpc, { + batch: opts.rpcBatchSize != 0 && { + batchSize: opts.rpcBatchSize, + wait: 1000, + }, + }), account: privateKeyToAccount(privateKey), }); console.log("Deploying from", client.account.address); From 03d4159655abb72b4c7acc3aee486c9cd9b5916a Mon Sep 17 00:00:00 2001 From: hourglasshoro Date: Thu, 29 Feb 2024 00:06:56 -0700 Subject: [PATCH 2/6] change opt to a fixed value flag instead of variable --- packages/cli/src/runDeploy.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/cli/src/runDeploy.ts b/packages/cli/src/runDeploy.ts index 4d32e590d8..df6468c929 100644 --- a/packages/cli/src/runDeploy.ts +++ b/packages/cli/src/runDeploy.ts @@ -22,10 +22,10 @@ export const deployOptions = { profile: { type: "string", desc: "The foundry profile to use" }, saveDeployment: { type: "boolean", desc: "Save the deployment info to a file", default: true }, rpc: { type: "string", desc: "The RPC URL to use. Defaults to the RPC url from the local foundry.toml" }, - rpcBatchSize: { - type: "number", - desc: "Number of JSON-RPC HTTP requests processed in batch per second", - ), + rpcBatch: { + type: "boolean", + desc: "Enable batch processing of RPC requests", + }, deployerAddress: { type: "string", desc: "Deploy using an existing deterministic deployer (https://github.com/Arachnid/deterministic-deployment-proxy)", @@ -90,8 +90,8 @@ in your contracts directory to use the default anvil private key.` const client = createWalletClient({ transport: http(rpc, { - batch: opts.rpcBatchSize != 0 && { - batchSize: opts.rpcBatchSize, + batch: opts.rpcBatch && { + batchSize: 100, wait: 1000, }, }), From e88997f471aacef9474eebf61b307c67a0d97681 Mon Sep 17 00:00:00 2001 From: hourglasshoro Date: Thu, 29 Feb 2024 00:07:15 -0700 Subject: [PATCH 3/6] fix docs --- docs/pages/cli/deploy.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/pages/cli/deploy.mdx b/docs/pages/cli/deploy.mdx index 568bc921dd..083c64b80d 100644 --- a/docs/pages/cli/deploy.mdx +++ b/docs/pages/cli/deploy.mdx @@ -43,6 +43,7 @@ These are the command line options you can specify on `mud deploy`: | `--saveDeployment | Save the deployment info to a file | boolean | `true` | | `--profile` | The foundry profile to use | string | `local` | | `--rpc`1 | The RPC URL to use | string | RPC url from `foundry.toml` | +| `--rpcBatch` | Enable batch processing of RPC requests | boolean | `false` | | `--worldAddress` | Deploy to an existing World at the given address | string | Empty, deploy new `World` | | `--srcDir` | Source directory | string | Foundry `src` directory | | `--skipBuild` | Skip rebuilding the contracts before deploying | boolean | `false` | From baa4d116f5e77777c5c9d4fa66a420e0827f3af4 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Tue, 5 Mar 2024 11:11:31 +0000 Subject: [PATCH 4/6] small tweak --- packages/cli/src/runDeploy.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/runDeploy.ts b/packages/cli/src/runDeploy.ts index b9c7760b83..cc9804db7b 100644 --- a/packages/cli/src/runDeploy.ts +++ b/packages/cli/src/runDeploy.ts @@ -24,7 +24,7 @@ export const deployOptions = { rpc: { type: "string", desc: "The RPC URL to use. Defaults to the RPC url from the local foundry.toml" }, rpcBatch: { type: "boolean", - desc: "Enable batch processing of RPC requests", + desc: "Enable batch processing of RPC requests in viem client (defaults to batch size of 100 and wait of 1s)", }, deployerAddress: { type: "string", @@ -90,10 +90,12 @@ in your contracts directory to use the default anvil private key.`, const client = createWalletClient({ transport: http(rpc, { - batch: opts.rpcBatch && { - batchSize: 100, - wait: 1000, - }, + batch: opts.rpcBatch + ? { + batchSize: 100, + wait: 1000, + } + : undefined, }), account: privateKeyToAccount(privateKey), }); From a134b6e26887a2ce24de42e876336381e05664a1 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Tue, 5 Mar 2024 11:13:55 +0000 Subject: [PATCH 5/6] add changeset --- .changeset/angry-buses-dress.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/angry-buses-dress.md diff --git a/.changeset/angry-buses-dress.md b/.changeset/angry-buses-dress.md new file mode 100644 index 0000000000..ac7b4e2238 --- /dev/null +++ b/.changeset/angry-buses-dress.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/cli": minor +--- + +Added an `--rpcBatch` option to `mud deploy` command to batch RPC calls for rate limited RPCs. From c8121100728a7b0f9be70b504d3d9a14bf512983 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Tue, 5 Mar 2024 11:14:05 +0000 Subject: [PATCH 6/6] fix dev contracts deploy args --- packages/cli/src/commands/dev-contracts.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/cli/src/commands/dev-contracts.ts b/packages/cli/src/commands/dev-contracts.ts index 23b7b1d03c..61b6b75431 100644 --- a/packages/cli/src/commands/dev-contracts.ts +++ b/packages/cli/src/commands/dev-contracts.ts @@ -83,6 +83,7 @@ const commandModule: CommandModule