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

core,miner: add ability to build block with blobs #27875

Merged
merged 8 commits into from
Aug 23, 2023

Conversation

lightclient
Copy link
Member

@lightclient lightclient commented Aug 7, 2023

I'm ripping out the changes that allow the miner to build 4844 blocks from #27511.

@lightclient lightclient force-pushed the 4844-miner branch 2 times, most recently from 790c229 to ba83d18 Compare August 7, 2023 23:40
@lightclient
Copy link
Member Author

This is now rebased and waiting on merging #27841

@lightclient lightclient changed the title core,miner: add ability to build block with blobs (wip) core,miner: add ability to build block with blobs Aug 7, 2023
@lightclient lightclient force-pushed the 4844-miner branch 3 times, most recently from 2097e28 to 543e90c Compare August 16, 2023 13:49
@lightclient lightclient marked this pull request as ready for review August 16, 2023 13:55
@lightclient
Copy link
Member Author

Rebased against master, this is now ready for review.

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments

Comment on lines 263 to 270
for i := range sidecars {
for j := range sidecars[i].Blobs {
blobsBundle.Blobs = append(blobsBundle.Blobs, hexutil.Bytes(sidecars[i].Blobs[j][:]))
blobsBundle.Commitments = append(blobsBundle.Commitments, hexutil.Bytes(sidecars[i].Commitments[j][:]))
blobsBundle.Proofs = append(blobsBundle.Proofs, hexutil.Bytes(sidecars[i].Proofs[j][:]))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for i := range sidecars {
for j := range sidecars[i].Blobs {
blobsBundle.Blobs = append(blobsBundle.Blobs, hexutil.Bytes(sidecars[i].Blobs[j][:]))
blobsBundle.Commitments = append(blobsBundle.Commitments, hexutil.Bytes(sidecars[i].Commitments[j][:]))
blobsBundle.Proofs = append(blobsBundle.Proofs, hexutil.Bytes(sidecars[i].Proofs[j][:]))
}
for _, sidecar := range sidecars {
for j, blob := range sidecar.Blobs {
bundle.Blobs = append(bundle.Blobs, hexutil.Bytes(sidecar.Blobs[j][:]))
bundle.Commitments = append(bundle.Commitments, hexutil.Bytes(sidecar.Commitments[j][:]))
bundle.Proofs = append(bundle.Proofs, hexutil.Bytes(sidecar.Proofs[j][:]))
}

make it a bit less dense, and remove the possibility of mixing up i and j

miner/worker.go Outdated
Comment on lines 751 to 752
// TODO (MariusVanDerWijden): Move this check
if (len(env.sidecars)+len(tx.BlobHashes()))*params.BlobTxBlobGasPerBlob > params.BlobTxMaxBlobGasPerBlock {
return nil, errors.New("max data blobs reached")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not move it already? Where do we want it?

// isn't really a better place right now. The blob gas limit is checked at block validation time
// and not during execution. This means core.ApplyTransaction will not return an error if the
// tx has too many blobs. So we have to explicitly check it here.
if (env.blobs+len(tx.BlobHashes()))*params.BlobTxBlobGasPerBlob > params.MaxBlobGasPerBlock {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can be treated as block.GasLeft.

Block has a gasPool and we can create a blobGasPool for blobTx. The benefit of this approach is: this check can be used in both (1) block generation and (2) block import.

Right now, we check the blob validity in (v *BlockValidator) ValidateBody when import a new block, and here when generate a new block. They can be in the same place I think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me and @lightclient tried making this change yesterday, adding blobGas into core.GasPool. I think it's not worth it right now. There are too many places in the code where we would need to suddenly care about blobGas. It would be better to refactor the state transition first, to remove duplication across the codebase.

@fjl fjl merged commit feb8f41 into ethereum:master Aug 23, 2023
1 check passed
devopsbo3 pushed a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023

---------

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
Co-authored-by: Felix Lange <fjl@twurst.com>
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
sduchesneau pushed a commit to streamingfast/go-ethereum that referenced this pull request Feb 26, 2024
miner: add to build block with EIP-4844 blobs

 Conflicts:
  miner/worker.go
simple conflict because we added a return param. accepted both changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants