From 4ae8724a94d68a37cd68a153f023a958a7632a7d Mon Sep 17 00:00:00 2001 From: "Sebastijan K." <58827427+sebastijankuzner@users.noreply.github.com> Date: Wed, 7 Aug 2024 12:54:01 +0200 Subject: [PATCH] fix(validator): process transaction if enough gas is left (#678) * check gas left * emoty commit --- packages/validator/source/validator.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/packages/validator/source/validator.ts b/packages/validator/source/validator.ts index fa68ed152..8c310dd9e 100644 --- a/packages/validator/source/validator.ts +++ b/packages/validator/source/validator.ts @@ -155,22 +155,17 @@ export class Validator implements Contracts.Validator.Validator { } try { + const gasLimit = transaction.data.asset?.evmCall?.gasLimit || 0; + + if (gasLeft - gasLimit < 0) { + break; + } + const result = await validator.validate( { commitKey, gasLimit: milestone.block.maxGasLimit, generatorPublicKey, timestamp }, transaction, ); - // We received transactions from the pool without taking gas usage into account yet. - // Therefore only include transactions that fit into the block. - if (gasLeft - result.gasUsed < 0) { - if (gasLeft >= 21_000) { - continue; // another transaction potentially still fits - } - - // block is full - break; - } - gasLeft -= result.gasUsed; transaction.data.gasUsed = result.gasUsed;