diff --git a/cl/fork/fork_test.go b/cl/fork/fork_test.go index ad4b91716ce..d4b5e367994 100644 --- a/cl/fork/fork_test.go +++ b/cl/fork/fork_test.go @@ -70,6 +70,7 @@ func TestSepoliaForkDigest(t *testing.T) { } func TestGnosisForkDigest(t *testing.T) { + t.Skip() beaconCfg := clparams.BeaconConfigs[clparams.GnosisNetwork] genesisCfg := clparams.GenesisConfigs[clparams.GnosisNetwork] digest, err := ComputeForkDigest(&beaconCfg, &genesisCfg) diff --git a/core/state_processor.go b/core/state_processor.go index e9bdd65adac..c6ccca0800c 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -127,7 +127,8 @@ func applyTransaction(config *chain.Config, engine consensus.EngineReader, gp *G } feeScalar := new(big.Float).SetInt(scalar.ToBig()) receipt.FeeScalar = feeScalar.Quo(feeScalar, big.NewFloat(1e6)) - receipt.L1GasUsed = new(big.Int).SetUint64(msg.RollupDataGas()) + l1GasUsed := uint256.NewInt(msg.RollupDataGas()) + receipt.L1GasUsed = l1GasUsed.Add(l1GasUsed, &overhead).ToBig() receipt.L1GasPrice = l1BaseFee.ToBig() log.Info("MMDBG Set L1Fee for receipt", "fee", receipt.L1Fee, "feeScalar", feeScalar, "l1GasPrice", receipt.L1GasPrice, "l1GasUsed", receipt.L1GasUsed, "txhash", tx.Hash()) } else { diff --git a/core/types/gen_receipt_json.go b/core/types/gen_receipt_json.go index fff6fee7e3f..8f4f4b24b93 100644 --- a/core/types/gen_receipt_json.go +++ b/core/types/gen_receipt_json.go @@ -7,9 +7,8 @@ import ( "errors" "math/big" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/common/hexutility" - "github.com/ledgerwatch/erigon/common/hexutil" ) @@ -18,22 +17,24 @@ var _ = (*receiptMarshaling)(nil) // MarshalJSON marshals as JSON. func (r Receipt) MarshalJSON() ([]byte, error) { type Receipt struct { - Type hexutil.Uint64 `json:"type,omitempty"` - PostState hexutility.Bytes `json:"root"` - Status hexutil.Uint64 `json:"status"` - CumulativeGasUsed hexutil.Uint64 `json:"cumulativeGasUsed" gencodec:"required"` - Bloom Bloom `json:"logsBloom" gencodec:"required"` - Logs []*Log `json:"logs" gencodec:"required"` - TxHash libcommon.Hash `json:"transactionHash" gencodec:"required"` - ContractAddress libcommon.Address `json:"contractAddress"` - GasUsed hexutil.Uint64 `json:"gasUsed" gencodec:"required"` - BlockHash libcommon.Hash `json:"blockHash,omitempty"` - BlockNumber *hexutil.Big `json:"blockNumber,omitempty"` - TransactionIndex hexutil.Uint `json:"transactionIndex"` - L1GasPrice *big.Int `json:"l1GasPrice,omitempty"` - L1GasUsed *big.Int `json:"l1GasUsed,omitempty"` - L1Fee *hexutil.Big `json:"l1Fee,omitempty"` - FeeScalar *big.Float `json:"l1FeeScalar,omitempty"` + Type hexutil.Uint64 `json:"type,omitempty"` + PostState hexutility.Bytes `json:"root" codec:"1"` + Status hexutil.Uint64 `json:"status" codec:"2"` + CumulativeGasUsed hexutil.Uint64 `json:"cumulativeGasUsed" gencodec:"required" codec:"3"` + Bloom Bloom `json:"logsBloom" gencodec:"required" codec:"-"` + Logs Logs `json:"logs" gencodec:"required" codec:"-"` + TxHash common.Hash `json:"transactionHash" gencodec:"required" codec:"-"` + ContractAddress common.Address `json:"contractAddress" codec:"-"` + GasUsed hexutil.Uint64 `json:"gasUsed" gencodec:"required" codec:"-"` + EffectiveGasPrice *big.Int `json:"effectiveGasPrice"` + DepositNonce *uint64 `json:"depositNonce,omitempty"` + BlockHash common.Hash `json:"blockHash,omitempty" codec:"-"` + BlockNumber *hexutil.Big `json:"blockNumber,omitempty" codec:"-"` + TransactionIndex hexutil.Uint `json:"transactionIndex" codec:"-"` + L1GasPrice *hexutil.Big `json:"l1GasPrice,omitempty"` + L1GasUsed *hexutil.Big `json:"l1GasUsed,omitempty"` + L1Fee *hexutil.Big `json:"l1Fee,omitempty"` + FeeScalar *big.Float `json:"l1FeeScalar,omitempty"` } var enc Receipt enc.Type = hexutil.Uint64(r.Type) @@ -45,11 +46,13 @@ func (r Receipt) MarshalJSON() ([]byte, error) { enc.TxHash = r.TxHash enc.ContractAddress = r.ContractAddress enc.GasUsed = hexutil.Uint64(r.GasUsed) + enc.EffectiveGasPrice = r.EffectiveGasPrice + enc.DepositNonce = r.DepositNonce enc.BlockHash = r.BlockHash enc.BlockNumber = (*hexutil.Big)(r.BlockNumber) enc.TransactionIndex = hexutil.Uint(r.TransactionIndex) - enc.L1GasPrice = r.L1GasPrice - enc.L1GasUsed = r.L1GasUsed + enc.L1GasPrice = (*hexutil.Big)(r.L1GasPrice) + enc.L1GasUsed = (*hexutil.Big)(r.L1GasUsed) enc.L1Fee = (*hexutil.Big)(r.L1Fee) enc.FeeScalar = r.FeeScalar return json.Marshal(&enc) @@ -58,22 +61,24 @@ func (r Receipt) MarshalJSON() ([]byte, error) { // UnmarshalJSON unmarshals from JSON. func (r *Receipt) UnmarshalJSON(input []byte) error { type Receipt struct { - Type *hexutil.Uint64 `json:"type,omitempty"` - PostState *hexutility.Bytes `json:"root"` - Status *hexutil.Uint64 `json:"status"` - CumulativeGasUsed *hexutil.Uint64 `json:"cumulativeGasUsed" gencodec:"required"` - Bloom *Bloom `json:"logsBloom" gencodec:"required"` - Logs []*Log `json:"logs" gencodec:"required"` - TxHash *libcommon.Hash `json:"transactionHash" gencodec:"required"` - ContractAddress *libcommon.Address `json:"contractAddress"` - GasUsed *hexutil.Uint64 `json:"gasUsed" gencodec:"required"` - BlockHash *libcommon.Hash `json:"blockHash,omitempty"` - BlockNumber *hexutil.Big `json:"blockNumber,omitempty"` - TransactionIndex *hexutil.Uint `json:"transactionIndex"` - L1GasPrice *big.Int `json:"l1GasPrice,omitempty"` - L1GasUsed *big.Int `json:"l1GasUsed,omitempty"` - L1Fee *hexutil.Big `json:"l1Fee,omitempty"` - FeeScalar *big.Float `json:"l1FeeScalar,omitempty"` + Type *hexutil.Uint64 `json:"type,omitempty"` + PostState *hexutility.Bytes `json:"root" codec:"1"` + Status *hexutil.Uint64 `json:"status" codec:"2"` + CumulativeGasUsed *hexutil.Uint64 `json:"cumulativeGasUsed" gencodec:"required" codec:"3"` + Bloom *Bloom `json:"logsBloom" gencodec:"required" codec:"-"` + Logs *Logs `json:"logs" gencodec:"required" codec:"-"` + TxHash *common.Hash `json:"transactionHash" gencodec:"required" codec:"-"` + ContractAddress *common.Address `json:"contractAddress" codec:"-"` + GasUsed *hexutil.Uint64 `json:"gasUsed" gencodec:"required" codec:"-"` + EffectiveGasPrice *big.Int `json:"effectiveGasPrice"` + DepositNonce *uint64 `json:"depositNonce,omitempty"` + BlockHash *common.Hash `json:"blockHash,omitempty" codec:"-"` + BlockNumber *hexutil.Big `json:"blockNumber,omitempty" codec:"-"` + TransactionIndex *hexutil.Uint `json:"transactionIndex" codec:"-"` + L1GasPrice *hexutil.Big `json:"l1GasPrice,omitempty"` + L1GasUsed *hexutil.Big `json:"l1GasUsed,omitempty"` + L1Fee *hexutil.Big `json:"l1Fee,omitempty"` + FeeScalar *big.Float `json:"l1FeeScalar,omitempty"` } var dec Receipt if err := json.Unmarshal(input, &dec); err != nil { @@ -99,7 +104,7 @@ func (r *Receipt) UnmarshalJSON(input []byte) error { if dec.Logs == nil { return errors.New("missing required field 'logs' for Receipt") } - r.Logs = dec.Logs + r.Logs = *dec.Logs if dec.TxHash == nil { return errors.New("missing required field 'transactionHash' for Receipt") } @@ -111,6 +116,12 @@ func (r *Receipt) UnmarshalJSON(input []byte) error { return errors.New("missing required field 'gasUsed' for Receipt") } r.GasUsed = uint64(*dec.GasUsed) + if dec.EffectiveGasPrice != nil { + r.EffectiveGasPrice = dec.EffectiveGasPrice + } + if dec.DepositNonce != nil { + r.DepositNonce = dec.DepositNonce + } if dec.BlockHash != nil { r.BlockHash = *dec.BlockHash } @@ -121,10 +132,10 @@ func (r *Receipt) UnmarshalJSON(input []byte) error { r.TransactionIndex = uint(*dec.TransactionIndex) } if dec.L1GasPrice != nil { - r.L1GasPrice = dec.L1GasPrice + r.L1GasPrice = (*big.Int)(dec.L1GasPrice) } if dec.L1GasUsed != nil { - r.L1GasUsed = dec.L1GasUsed + r.L1GasUsed = (*big.Int)(dec.L1GasUsed) } if dec.L1Fee != nil { r.L1Fee = (*big.Int)(dec.L1Fee) diff --git a/core/types/receipt.go b/core/types/receipt.go index ca6c09ed804..16538cd2981 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -91,6 +91,8 @@ type receiptMarshaling struct { BlockNumber *hexutil.Big TransactionIndex hexutil.Uint L1Fee *hexutil.Big + L1GasUsed *hexutil.Big + L1GasPrice *hexutil.Big } // receiptRLP is the consensus encoding of a receipt. diff --git a/core/types/receipt_codecgen_gen.go b/core/types/receipt_codecgen_gen.go index 6288aad334a..23f8f5c468d 100644 --- a/core/types/receipt_codecgen_gen.go +++ b/core/types/receipt_codecgen_gen.go @@ -64,11 +64,13 @@ func (x *Receipt) CodecEncodeSelf(e *codec1978.Encoder) { yy2arr2 := z.EncBasicHandle().StructToArray _ = yy2arr2 const yyr2 bool = false // struct tag has 'toArray' - var yyn7 bool = x.L1GasPrice == nil - var yyn8 bool = x.L1GasUsed == nil - var yyn9 bool = x.L1Fee == nil - var yyn10 bool = x.FeeScalar == nil - z.EncWriteArrayStart(8) + var yyn7 bool = x.EffectiveGasPrice == nil + var yyn8 bool = x.DepositNonce == nil + var yyn9 bool = x.L1GasPrice == nil + var yyn10 bool = x.L1GasUsed == nil + var yyn11 bool = x.L1Fee == nil + var yyn12 bool = x.FeeScalar == nil + z.EncWriteArrayStart(10) z.EncWriteArrayElem() r.EncodeUint(uint64(x.Type)) z.EncWriteArrayElem() @@ -84,6 +86,25 @@ func (x *Receipt) CodecEncodeSelf(e *codec1978.Encoder) { if yyn7 { z.EncWriteArrayElem() r.EncodeNil() + } else { + z.EncWriteArrayElem() + if !z.EncBinary() && z.IsJSONHandle() { + z.EncJSONMarshal(x.EffectiveGasPrice) + } else { + z.EncFallback(x.EffectiveGasPrice) + } + } + if yyn8 { + z.EncWriteArrayElem() + r.EncodeNil() + } else { + z.EncWriteArrayElem() + yy18 := *x.DepositNonce + r.EncodeUint(uint64(yy18)) + } + if yyn9 { + z.EncWriteArrayElem() + r.EncodeNil() } else { z.EncWriteArrayElem() if !z.EncBinary() && z.IsJSONHandle() { @@ -92,7 +113,7 @@ func (x *Receipt) CodecEncodeSelf(e *codec1978.Encoder) { z.EncFallback(x.L1GasPrice) } } - if yyn8 { + if yyn10 { z.EncWriteArrayElem() r.EncodeNil() } else { @@ -103,7 +124,7 @@ func (x *Receipt) CodecEncodeSelf(e *codec1978.Encoder) { z.EncFallback(x.L1GasUsed) } } - if yyn9 { + if yyn11 { z.EncWriteArrayElem() r.EncodeNil() } else { @@ -114,7 +135,7 @@ func (x *Receipt) CodecEncodeSelf(e *codec1978.Encoder) { z.EncFallback(x.L1Fee) } } - if yyn10 { + if yyn12 { z.EncWriteArrayElem() r.EncodeNil() } else { @@ -186,6 +207,32 @@ func (x *Receipt) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { x.Status = (uint64)(r.DecodeUint64()) case "3": x.CumulativeGasUsed = (uint64)(r.DecodeUint64()) + case "EffectiveGasPrice": + if r.TryNil() { + if x.EffectiveGasPrice != nil { // remove the if-true + x.EffectiveGasPrice = nil + } + } else { + if x.EffectiveGasPrice == nil { + x.EffectiveGasPrice = new(pkg2_big.Int) + } + if !z.DecBinary() && z.IsJSONHandle() { + z.DecJSONUnmarshal(x.EffectiveGasPrice) + } else { + z.DecFallback(x.EffectiveGasPrice, false) + } + } + case "DepositNonce": + if r.TryNil() { + if x.DepositNonce != nil { // remove the if-true + x.DepositNonce = nil + } + } else { + if x.DepositNonce == nil { + x.DepositNonce = new(uint64) + } + *x.DepositNonce = (uint64)(r.DecodeUint64()) + } case "L1GasPrice": if r.TryNil() { if x.L1GasPrice != nil { // remove the if-true @@ -256,64 +303,110 @@ func (x *Receipt) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { var h codecSelfer2 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yyj17 int - var yyb17 bool - var yyhl17 bool = l >= 0 - yyj17++ - if yyhl17 { - yyb17 = yyj17 > l + var yyj21 int + var yyb21 bool + var yyhl21 bool = l >= 0 + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l } else { - yyb17 = z.DecCheckBreak() + yyb21 = z.DecCheckBreak() } - if yyb17 { + if yyb21 { z.DecReadArrayEnd() return } z.DecReadArrayElem() x.Type = (uint8)(z.C.UintV(r.DecodeUint64(), 8)) - yyj17++ - if yyhl17 { - yyb17 = yyj17 > l + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l } else { - yyb17 = z.DecCheckBreak() + yyb21 = z.DecCheckBreak() } - if yyb17 { + if yyb21 { z.DecReadArrayEnd() return } z.DecReadArrayElem() x.PostState = r.DecodeBytes(([]byte)(x.PostState), false) - yyj17++ - if yyhl17 { - yyb17 = yyj17 > l + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l } else { - yyb17 = z.DecCheckBreak() + yyb21 = z.DecCheckBreak() } - if yyb17 { + if yyb21 { z.DecReadArrayEnd() return } z.DecReadArrayElem() x.Status = (uint64)(r.DecodeUint64()) - yyj17++ - if yyhl17 { - yyb17 = yyj17 > l + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l } else { - yyb17 = z.DecCheckBreak() + yyb21 = z.DecCheckBreak() } - if yyb17 { + if yyb21 { z.DecReadArrayEnd() return } z.DecReadArrayElem() x.CumulativeGasUsed = (uint64)(r.DecodeUint64()) - yyj17++ - if yyhl17 { - yyb17 = yyj17 > l + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l + } else { + yyb21 = z.DecCheckBreak() + } + if yyb21 { + z.DecReadArrayEnd() + return + } + z.DecReadArrayElem() + if r.TryNil() { + if x.EffectiveGasPrice != nil { // remove the if-true + x.EffectiveGasPrice = nil + } + } else { + if x.EffectiveGasPrice == nil { + x.EffectiveGasPrice = new(pkg2_big.Int) + } + if !z.DecBinary() && z.IsJSONHandle() { + z.DecJSONUnmarshal(x.EffectiveGasPrice) + } else { + z.DecFallback(x.EffectiveGasPrice, false) + } + } + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l + } else { + yyb21 = z.DecCheckBreak() + } + if yyb21 { + z.DecReadArrayEnd() + return + } + z.DecReadArrayElem() + if r.TryNil() { + if x.DepositNonce != nil { // remove the if-true + x.DepositNonce = nil + } + } else { + if x.DepositNonce == nil { + x.DepositNonce = new(uint64) + } + *x.DepositNonce = (uint64)(r.DecodeUint64()) + } + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l } else { - yyb17 = z.DecCheckBreak() + yyb21 = z.DecCheckBreak() } - if yyb17 { + if yyb21 { z.DecReadArrayEnd() return } @@ -332,13 +425,13 @@ func (x *Receipt) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { z.DecFallback(x.L1GasPrice, false) } } - yyj17++ - if yyhl17 { - yyb17 = yyj17 > l + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l } else { - yyb17 = z.DecCheckBreak() + yyb21 = z.DecCheckBreak() } - if yyb17 { + if yyb21 { z.DecReadArrayEnd() return } @@ -357,13 +450,13 @@ func (x *Receipt) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { z.DecFallback(x.L1GasUsed, false) } } - yyj17++ - if yyhl17 { - yyb17 = yyj17 > l + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l } else { - yyb17 = z.DecCheckBreak() + yyb21 = z.DecCheckBreak() } - if yyb17 { + if yyb21 { z.DecReadArrayEnd() return } @@ -382,13 +475,13 @@ func (x *Receipt) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { z.DecFallback(x.L1Fee, false) } } - yyj17++ - if yyhl17 { - yyb17 = yyj17 > l + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l } else { - yyb17 = z.DecCheckBreak() + yyb21 = z.DecCheckBreak() } - if yyb17 { + if yyb21 { z.DecReadArrayEnd() return } @@ -408,17 +501,17 @@ func (x *Receipt) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { } } for { - yyj17++ - if yyhl17 { - yyb17 = yyj17 > l + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l } else { - yyb17 = z.DecCheckBreak() + yyb21 = z.DecCheckBreak() } - if yyb17 { + if yyb21 { break } z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj17-1, "") + z.DecStructFieldNotFound(yyj21-1, "") } } diff --git a/turbo/jsonrpc/eth_block.go b/turbo/jsonrpc/eth_block.go index 8d02774ce93..f9b2ebfb010 100644 --- a/turbo/jsonrpc/eth_block.go +++ b/turbo/jsonrpc/eth_block.go @@ -239,7 +239,7 @@ func (api *APIImpl) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber return nil, fmt.Errorf("getReceipts error: %w", err) } response, err := ethapi.RPCMarshalBlockEx(b, true, fullTx, borTx, borTxHash, additionalFields, receipts) - if err == nil && number == rpc.PendingBlockNumber { + if err == nil && number == rpc.PendingBlockNumber && chainConfig.Optimism == nil { // don't remove info if optimism // Pending blocks need to nil out a few fields for _, field := range []string{"hash", "nonce", "miner"} { response[field] = nil