hedera-json-rpc-relay icon indicating copy to clipboard operation
hedera-json-rpc-relay copied to clipboard

Leading zeros in Hex values causing incompatibilities with Hex Parsing

Open simsonraj opened this issue 1 year ago • 3 comments

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

image

Additional context

No response

Hedera network

testnet

Version

0.47.0-rc3

Operating system

None

simsonraj avatar May 07 '24 18:05 simsonraj

@simsonraj Do you have the block number that you are seeing this on?

ebadiere avatar May 09 '24 14:05 ebadiere

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())
				}
			}
		}
	}

ebadiere avatar May 09 '24 15:05 ebadiere

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

simsonraj avatar May 10 '24 09:05 simsonraj

Addressed by #2495

ebadiere avatar May 20 '24 13:05 ebadiere

Addressed by #2495

replaced with https://github.com/hashgraph/hedera-json-rpc-relay/pull/2499

quiet-node avatar May 21 '24 18:05 quiet-node