Fix base fee endianness (#10253)

This commit is contained in:
terence tsao
2022-02-16 09:48:55 -08:00
committed by GitHub
parent 3003f08770
commit 49f989e342
2 changed files with 3 additions and 2 deletions

View File

@@ -187,7 +187,7 @@ func (e *ExecutionPayload) MarshalJSON() ([]byte, error) {
for i, tx := range e.Transactions {
transactions[i] = tx
}
baseFee := new(big.Int).SetBytes(e.BaseFeePerGas)
baseFee := new(big.Int).SetBytes(bytesutil.ReverseByteOrder(e.BaseFeePerGas))
baseFeeHex := hexutil.EncodeBig(baseFee)
return json.Marshal(executionPayloadJSON{
ParentHash: e.ParentHash,

View File

@@ -79,6 +79,7 @@ func TestJsonMarshalUnmarshal(t *testing.T) {
})
t.Run("execution payload", func(t *testing.T) {
baseFeePerGas := big.NewInt(6)
baseFeePerGasBytes := bytesutil.ReverseByteOrder(baseFeePerGas.Bytes())
parentHash := bytesutil.PadTo([]byte("parent"), fieldparams.RootLength)
feeRecipient := bytesutil.PadTo([]byte("feeRecipient"), fieldparams.FeeRecipientLength)
stateRoot := bytesutil.PadTo([]byte("stateRoot"), fieldparams.RootLength)
@@ -99,7 +100,7 @@ func TestJsonMarshalUnmarshal(t *testing.T) {
GasUsed: 3,
Timestamp: 4,
ExtraData: extra,
BaseFeePerGas: baseFeePerGas.Bytes(),
BaseFeePerGas: baseFeePerGasBytes,
BlockHash: hash,
Transactions: [][]byte{[]byte("hi")},
}