Fix: zero-valued BigInt tx fields encode as non-canonical RLP (0x00)#34
Merged
mrtnetwork merged 1 commit intoJun 18, 2026
Merged
Conversation
ETHTransactionUtils.bigintToBytes returned a single 0x00 byte for a zero value, which RLP treats as a non-canonical integer. Nodes reject such transactions with "rlp: non-canonical integer (leading zero bytes)". This surfaced after bumping blockchain_utils to ^6.0.0, where BigintUtils.bitlengthInBytes(0) now returns 1 (was 0), so toBytes(0) yields [0] instead of []. It broke Arbitrum (and other L2) transfers where maxPriorityFeePerGas is normally 0. Guard zero before encoding, mirroring intToBytes. This fixes every zero-able BigInt field across all tx types (including the commonly-zero EIP-7702 authorization nonce). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
|
Hi, @mrtnetwork ! When you have a chance, could you please take a look at #33 and #34 ? |
This was referenced Jun 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: zero-valued BigInt tx fields encode as non-canonical RLP (
0x00)Summary
ETHTransactionUtils.bigintToBytes()encoded a zeroBigIntas a single0x00byte instead of an empty byte string. RLP requires the canonical emptyform for integers, so nodes reject these transactions:
The regression came in with the v8.0.0 bump of
blockchain_utilsto^6.0.0:bitlengthInBytes(0)changed from0to1, sotoBytes(0)now yields[0]instead of
[]. It broke L2 transfers like Arbitrum, wheremaxPriorityFeePerGas(GasTipCap) is normally0; mainnet was unaffectedonly because the tip there is effectively always
> 0.The fix guards the zero case in
bigintToBytes, mirroring the guard alreadypresent in the sibling
intToBytes, so encoding is correct independent of thedependency's internals.
Change
static List<int> bigintToBytes(BigInt value) { + if (value == BigInt.zero) return []; final toBytes = BigintUtils.toBytes( value, length: BigintUtils.bitlengthInBytes(value), );Impact
BigIntfield across all txtypes (legacy / 1559 / 2930 / 4844 / 7702 / 712) — including the commonly-zero
EIP-7702 authorization nonce.
[]and[0]both map back to0).Testing
Added tests in
test/etherum/transaction_test.dartcovering the helper and thereal Arbitrum zero-tip EIP-1559 case. They fail pre-fix, pass post-fix; the
test/etherum/suite is green.