From e8ffb133b060d8af1532fdbbf8c8878e1657d3a7 Mon Sep 17 00:00:00 2001 From: Cesar Date: Thu, 4 Jan 2024 15:20:42 -0300 Subject: [PATCH] Fixed typo --- commontype/fee_config.go | 5 ----- utils/bytes.go | 11 +++++------ 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/commontype/fee_config.go b/commontype/fee_config.go index 4a22645e46..81b54a9a4a 100644 --- a/commontype/fee_config.go +++ b/commontype/fee_config.go @@ -205,11 +205,6 @@ func (c *FeeConfig) UnmarshalBinary(data []byte) error { return err } - c.MinBaseFee, err = utils.UnpackBigInt(&p) - if err != nil { - return err - } - c.TargetGas, err = utils.UnpackBigInt(&p) if err != nil { return err diff --git a/utils/bytes.go b/utils/bytes.go index aca98ac76c..18c20084c0 100644 --- a/utils/bytes.go +++ b/utils/bytes.go @@ -10,6 +10,8 @@ import ( "github.com/ethereum/go-ethereum/common" ) +const BigIntBytesLength = 32 + // IncrOne increments bytes value by one func IncrOne(bytes []byte) { index := len(bytes) - 1 @@ -50,11 +52,8 @@ func BytesToHashSlice(b []byte) []common.Hash { func PackBigInt(p *wrappers.Packer, number *big.Int) error { p.PackBool(number == nil) - if p.Err != nil { - return p.Err - } - if number != nil { - p.PackBytes(number.Bytes()) + if p.Err == nil && number != nil { + p.PackFixedBytes(number.FillBytes(make([]byte, BigIntBytesLength))) } return p.Err @@ -66,7 +65,7 @@ func UnpackBigInt(p *wrappers.Packer) (*big.Int, error) { return nil, p.Err } - number := big.NewInt(0).SetBytes(p.UnpackBytes()) + number := big.NewInt(0).SetBytes(p.UnpackFixedBytes(BigIntBytesLength)) return number, p.Err }