Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO-NOT-MERGE] Implement EIP-7742 related changes #13066

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/integration/commands/stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,7 @@ func newSync(ctx context.Context, db kv.RwDB, miningConfig *params.MiningConfig,
nil,
),
stagedsync.StageSendersCfg(db, sentryControlServer.ChainConfig, cfg.Sync, false, dirs.Tmp, cfg.Prune, blockReader, sentryControlServer.Hd),
stagedsync.StageMiningExecCfg(db, miner, events, *chainConfig, engine, &vm.Config{}, dirs.Tmp, nil, 0, nil, blockReader),
stagedsync.StageMiningExecCfg(db, miner, events, *chainConfig, engine, &vm.Config{}, dirs.Tmp, nil, 0, &core.BlockBuilderParameters{}, nil, blockReader),
stagedsync.StageMiningFinishCfg(db, *chainConfig, engine, miner, miningCancel, blockReader, builder.NewLatestBlockBuiltStore()),
),
stagedsync.MiningUnwindOrder,
Expand Down
11 changes: 8 additions & 3 deletions consensus/misc/eip4844.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,24 @@ import (
)

// CalcExcessBlobGas implements calc_excess_blob_gas from EIP-4844
// This was updated later with EIP-7742
func CalcExcessBlobGas(config *chain.Config, parent *types.Header) uint64 {
var excessBlobGas, blobGasUsed uint64
var excessBlobGas, blobGasUsed, targetBlobGas uint64

if parent.TargetBlobsPerBlock != nil {
targetBlobGas = *parent.TargetBlobsPerBlock * fixedgas.BlobGasPerBlob
}
if parent.ExcessBlobGas != nil {
excessBlobGas = *parent.ExcessBlobGas
}
if parent.BlobGasUsed != nil {
blobGasUsed = *parent.BlobGasUsed
}

if excessBlobGas+blobGasUsed < config.GetTargetBlobGasPerBlock() {
if excessBlobGas+blobGasUsed < targetBlobGas {
return 0
}
return excessBlobGas + blobGasUsed - config.GetTargetBlobGasPerBlock()
return excessBlobGas + blobGasUsed - targetBlobGas
}

// FakeExponential approximates factor * e ** (num / denom) using a taylor expansion
Expand Down
2 changes: 2 additions & 0 deletions core/block_builder_parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ type BlockBuilderParameters struct {
SuggestedFeeRecipient libcommon.Address
Withdrawals []*types.Withdrawal // added in Shapella (EIP-4895)
ParentBeaconBlockRoot *libcommon.Hash // added in Dencun (EIP-4788)
TargetBlobsPerBlock uint64
MaxBlobsPerBlock uint64
}
6 changes: 0 additions & 6 deletions core/types/blob_tx_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,6 @@ func (txw *BlobTxWrapper) ValidateBlobTransactionWrapper() error {
if l1 != l2 || l1 != l3 || l1 != l4 {
return fmt.Errorf("lengths don't match %v %v %v %v", l1, l2, l3, l4)
}
// the following check isn't strictly necessary as it would be caught by blob gas processing
// (and hence it is not explicitly in the spec for this function), but it doesn't hurt to fail
// early in case we are getting spammed with too many blobs or there is a bug somewhere:
if uint64(l1) > fixedgas.DefaultMaxBlobsPerBlock {
return fmt.Errorf("number of blobs exceeds max: %v", l1)
}
kzgCtx := libkzg.Ctx()
err := kzgCtx.VerifyBlobKZGProofBatch(toBlobs(txw.Blobs), toComms(txw.Commitments), toProofs(txw.Proofs))
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions core/types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ type Header struct {
BlobGasUsed *uint64 `json:"blobGasUsed"`
ExcessBlobGas *uint64 `json:"excessBlobGas"`

TargetBlobsPerBlock *uint64 `json:"targetBlobsPerBlock"` // EIP-7742

ParentBeaconBlockRoot *libcommon.Hash `json:"parentBeaconBlockRoot"` // EIP-4788

RequestsHash *libcommon.Hash `json:"requestsHash"` // EIP-7685
Expand Down
2 changes: 1 addition & 1 deletion erigon-lib/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ replace (

require (
github.com/erigontech/erigon-snapshot v1.3.1-0.20241023024258-f64407a77e8e
github.com/erigontech/interfaces v0.0.0-20241116035842-5d396f10468e
github.com/erigontech/interfaces v0.0.0-20241209135058-8558be1868f8
github.com/erigontech/mdbx-go v0.38.4
github.com/erigontech/secp256k1 v1.1.0
github.com/rs/dnscache v0.0.0-20211102005908-e0241e321417
Expand Down
4 changes: 2 additions & 2 deletions erigon-lib/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/erigontech/erigon-snapshot v1.3.1-0.20241023024258-f64407a77e8e h1:ZpIO6HeopuZPYDLldL6zR0qyRezj80kQrDOGEF779ts=
github.com/erigontech/erigon-snapshot v1.3.1-0.20241023024258-f64407a77e8e/go.mod h1:ooHlCl+eEYzebiPu+FP6Q6SpPUeMADn8Jxabv3IKb9M=
github.com/erigontech/interfaces v0.0.0-20241116035842-5d396f10468e h1:KD/yuduvNJDKkdmEaaiDYb9RQstnkJn5ZcSZHjH/C/w=
github.com/erigontech/interfaces v0.0.0-20241116035842-5d396f10468e/go.mod h1:N7OUkhkcagp9+7yb4ycHsG2VWCOmuJ1ONBecJshxtLE=
github.com/erigontech/interfaces v0.0.0-20241209135058-8558be1868f8 h1:e1RvhAIFjNzejGv4MIjtlGXyEIbSsM/agdtFnkb0Y5Y=
github.com/erigontech/interfaces v0.0.0-20241209135058-8558be1868f8/go.mod h1:N7OUkhkcagp9+7yb4ycHsG2VWCOmuJ1ONBecJshxtLE=
github.com/erigontech/mdbx-go v0.38.4 h1:S9T7mTe9KPcFe4dOoOtVdI6gPzht9y7wMnYfUBgrQLo=
github.com/erigontech/mdbx-go v0.38.4/go.mod h1:IcOLQDPw3VM/asP6T5JVPPN4FHHgJtY16XfYjzWKVNI=
github.com/erigontech/secp256k1 v1.1.0 h1:mO3YJMUSoASE15Ya//SoHiisptUhdXExuMUN1M0X9qY=
Expand Down
Loading
Loading