etclabscore / core-geth

A highly configurable Go implementation of the Ethereum protocol.
https://etclabscore.github.io/core-geth
GNU Lesser General Public License v3.0
267 stars 147 forks source link

Merge/foundation release/1.12.2 #560

Closed ziogaschr closed 1 year ago

ziogaschr commented 1 year ago

Merges ethereum/go-ethereum branch release/1.12.2 to core-geth master.

Notes


TODO

ziogaschr commented 1 year ago

Note: I still want to test the functionality while running in --dev mode

meowsbits commented 1 year ago

Two new fields are added to the Genesis type: ExcessBlobGas and BlobGasUsed. While these, along with BaseFee, are relevant to ETHereum chains, they are not relevant for all chains that core-geth supports, resulting in empty (null) fields.

What do you think about adding omitempty tags for these fields?

diff --git a/params/types/genesisT/gen_genesis.go b/params/types/genesisT/gen_genesis.go
index 0136309ee6..12f3d10b05 100644
--- a/params/types/genesisT/gen_genesis.go
+++ b/params/types/genesisT/gen_genesis.go
@@ -33,9 +33,9 @@ func (g Genesis) MarshalJSON() ([]byte, error) {
        Number        math.HexOrDecimal64                         `json:"number"`
        GasUsed       math.HexOrDecimal64                         `json:"gasUsed"`
        ParentHash    common.Hash                                 `json:"parentHash"`
-       BaseFee       *math.HexOrDecimal256                       `json:"baseFeePerGas"`
-       ExcessBlobGas *math.HexOrDecimal64                        `json:"excessBlobGas"`
-       BlobGasUsed   *math.HexOrDecimal64                        `json:"blobGasUsed"`
+       BaseFee       *math.HexOrDecimal256                       `json:"baseFeePerGas,omitempty"`
+       ExcessBlobGas *math.HexOrDecimal64                        `json:"excessBlobGas,omitempty"`
+       BlobGasUsed   *math.HexOrDecimal64                        `json:"blobGasUsed,omitempty"`
    }
    var enc Genesis
    enc.Config = g.Config
diff --git a/params/types/genesisT/genesis.go b/params/types/genesisT/genesis.go
index f2be54ec74..97676daee0 100644
--- a/params/types/genesisT/genesis.go
+++ b/params/types/genesisT/genesis.go
@@ -55,9 +55,9 @@ type Genesis struct {
    Number        uint64      `json:"number"`
    GasUsed       uint64      `json:"gasUsed"`
    ParentHash    common.Hash `json:"parentHash"`
-   BaseFee       *big.Int    `json:"baseFeePerGas"` // EIP-1559
-   ExcessBlobGas *uint64     `json:"excessBlobGas"` // EIP-4844
-   BlobGasUsed   *uint64     `json:"blobGasUsed"`   // EIP-4844
+   BaseFee       *big.Int    `json:"baseFeePerGas,omitempty"` // EIP-1559
+   ExcessBlobGas *uint64     `json:"excessBlobGas,omitempty"` // EIP-4844
+   BlobGasUsed   *uint64     `json:"blobGasUsed,omitempty"`   // EIP-4844
 }

 func (g *Genesis) GetElasticityMultiplier() uint64 {
ziogaschr commented 1 year ago

Two new fields are added to the Genesis type: ExcessBlobGas and BlobGasUsed. While these, along with BaseFee, are relevant to ETHereum chains, they are not relevant for all chains that core-geth supports, resulting in empty (null) fields.

What do you think about adding omitempty tags for these fields?

diff --git a/params/types/genesisT/gen_genesis.go b/params/types/genesisT/gen_genesis.go
index 0136309ee6..12f3d10b05 100644
--- a/params/types/genesisT/gen_genesis.go
+++ b/params/types/genesisT/gen_genesis.go
@@ -33,9 +33,9 @@ func (g Genesis) MarshalJSON() ([]byte, error) {
      Number        math.HexOrDecimal64                         `json:"number"`
      GasUsed       math.HexOrDecimal64                         `json:"gasUsed"`
      ParentHash    common.Hash                                 `json:"parentHash"`
-     BaseFee       *math.HexOrDecimal256                       `json:"baseFeePerGas"`
-     ExcessBlobGas *math.HexOrDecimal64                        `json:"excessBlobGas"`
-     BlobGasUsed   *math.HexOrDecimal64                        `json:"blobGasUsed"`
+     BaseFee       *math.HexOrDecimal256                       `json:"baseFeePerGas,omitempty"`
+     ExcessBlobGas *math.HexOrDecimal64                        `json:"excessBlobGas,omitempty"`
+     BlobGasUsed   *math.HexOrDecimal64                        `json:"blobGasUsed,omitempty"`
  }
  var enc Genesis
  enc.Config = g.Config
diff --git a/params/types/genesisT/genesis.go b/params/types/genesisT/genesis.go
index f2be54ec74..97676daee0 100644
--- a/params/types/genesisT/genesis.go
+++ b/params/types/genesisT/genesis.go
@@ -55,9 +55,9 @@ type Genesis struct {
  Number        uint64      `json:"number"`
  GasUsed       uint64      `json:"gasUsed"`
  ParentHash    common.Hash `json:"parentHash"`
- BaseFee       *big.Int    `json:"baseFeePerGas"` // EIP-1559
- ExcessBlobGas *uint64     `json:"excessBlobGas"` // EIP-4844
- BlobGasUsed   *uint64     `json:"blobGasUsed"`   // EIP-4844
+ BaseFee       *big.Int    `json:"baseFeePerGas,omitempty"` // EIP-1559
+ ExcessBlobGas *uint64     `json:"excessBlobGas,omitempty"` // EIP-4844
+ BlobGasUsed   *uint64     `json:"blobGasUsed,omitempty"`   // EIP-4844
 }

 func (g *Genesis) GetElasticityMultiplier() uint64 {

Makes sense to me too. Might be that a test can break, in case they check for this fields, but maybe it makes sense to modify those tests as well.

meowsbits commented 1 year ago

Yea, my rationale for removing them is mostly based on the pattern of extensive use of omitempty in the chain config types, which is obviously a closely related data type. So I would infer and assume that similar tests would be used for both data types, and that therefore checks for the existence or absence of fields should have similar expectations (permitting, or even expecting, that zero-value fields are omitted).