hedera-json-rpc-relay
hedera-json-rpc-relay copied to clipboard
Leading zeros in Hex values causing incompatibilities with Hex Parsing
Description
Some responses has hex values with Leading zeros that causes incompatibilities with Hex utilities Such as MaxFeePerGas in the Tx object of a Block
Steps to reproduce
Additional context
No response
Hedera network
testnet
Version
0.47.0-rc3
Operating system
None
@simsonraj Do you have the block number that you are seeing this on?
I suspect this issue is related: Error from GoEthClient when calling getBlockByNumber. There is a fix for this issue making it's way through CI. I am running the following go code that outputs maxFeePerGas on that fix, against testnet, and so far no issues:
for {
select {
case err := <-sub.Err():
log.Fatalf("Subscription error: %v", err)
case header := <-headers:
blockNumberDec := header.Number
block, err := client.BlockByNumber(context.Background(), header.Number)
if err != nil {
log.Fatalf("Failed to fetch block: %v", err)
continue
}
blockNumberHex := fmt.Sprintf("0x%x", blockNumberDec)
fmt.Printf("New block with number: %s (decimal) and %s (hex)\n", blockNumberDec.String(), blockNumberHex)
fmt.Println("Transactions in this block:")
for _, tx := range block.Transactions() {
fmt.Printf("\tTransaction Hash: %s\n", tx.Hash().Hex())
if tx.Type() == types.DynamicFeeTxType {
feeCap, tipCap := tx.GasFeeCap(), tx.GasTipCap()
maxFeePerGas := new(big.Int).Add(feeCap, tipCap)
fmt.Printf("\tMaxFeePerGas: %s\n", maxFeePerGas.String())
}
}
}
}
You can try this block to replicate that issue
block, _ := client.BlockByNumber(context.Background(), big.NewInt(3758312))
I think this is unrelated to the above-mentioned issue. But that fix would be great to have for us too
Addressed by #2495