From 0d7d76b69d0fc83f047360daf15ad12663f4600c Mon Sep 17 00:00:00 2001 From: Hukla <129692708+huklaa@users.noreply.github.com> Date: Thu, 3 Sep 2026 23:35:18 +0300 Subject: [PATCH 1/3] fix(genesis): reject zero block gas limit --- scripts/genesis/ProtocolConfig.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/genesis/ProtocolConfig.ts b/scripts/genesis/ProtocolConfig.ts index 6b52ce6b..7cf7933b 100644 --- a/scripts/genesis/ProtocolConfig.ts +++ b/scripts/genesis/ProtocolConfig.ts @@ -71,7 +71,7 @@ export const schemaProtocolConfig = z inverseElasticityMultiplier: schemaBigInt.min(0n).max(10000n), minBaseFee: schemaBigInt.min(0n).max(maxUint64), maxBaseFee: schemaBigInt.min(0n).max(maxUint64), - blockGasLimit: schemaBigInt.min(0n).max(maxUint64), + blockGasLimit: schemaBigInt.min(1n).max(maxUint64), }), consensusParams: z .object({ From e1798aa7bbfa9879744534cb2c9a9d9e46577b5b Mon Sep 17 00:00:00 2001 From: Hukla <129692708+huklaa@users.noreply.github.com> Date: Thu, 3 Sep 2026 23:35:35 +0300 Subject: [PATCH 2/3] test(genesis): cover block gas limit bounds --- tests/unit/protocol-config-schema.test.ts | 49 +++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/unit/protocol-config-schema.test.ts diff --git a/tests/unit/protocol-config-schema.test.ts b/tests/unit/protocol-config-schema.test.ts new file mode 100644 index 00000000..9f470f0f --- /dev/null +++ b/tests/unit/protocol-config-schema.test.ts @@ -0,0 +1,49 @@ +// Copyright 2026 Circle Internet Group, Inc. All rights reserved. +// +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { expect } from 'chai' +import { schemaProtocolConfig } from '../../scripts/genesis/ProtocolConfig' + +const maxUint64 = 18446744073709551615n + +const configWithBlockGasLimit = (blockGasLimit: bigint) => ({ + proxy: { admin: '0x0000000000000000000000000000000000000001' }, + owner: '0x0000000000000000000000000000000000000002', + controller: '0x0000000000000000000000000000000000000003', + pauser: '0x0000000000000000000000000000000000000004', + feeParams: { + alpha: 0n, + kRate: 0n, + inverseElasticityMultiplier: 0n, + minBaseFee: 0n, + maxBaseFee: 0n, + blockGasLimit, + }, +}) + +describe('schemaProtocolConfig', () => { + it('accepts the minimum positive block gas limit', () => { + expect(schemaProtocolConfig.safeParse(configWithBlockGasLimit(1n)).success).to.equal(true) + }) + + it('rejects a zero block gas limit', () => { + expect(schemaProtocolConfig.safeParse(configWithBlockGasLimit(0n)).success).to.equal(false) + }) + + it('rejects block gas limits above uint64', () => { + expect(schemaProtocolConfig.safeParse(configWithBlockGasLimit(maxUint64 + 1n)).success).to.equal(false) + }) +}) From d1d7efa72ab7a0bda4d18cf158d2a6586af020e5 Mon Sep 17 00:00:00 2001 From: Hukla <129692708+huklaa@users.noreply.github.com> Date: Thu, 3 Sep 2026 23:35:51 +0300 Subject: [PATCH 3/3] style: format protocol config schema test