mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
beacon/engine: fix cell proof logic
This commit is contained in:
parent
d2c1ba024c
commit
7f8da102af
2 changed files with 58 additions and 1 deletions
|
|
@ -336,7 +336,7 @@ func BlockToExecutableData(block *types.Block, fees *big.Int, sidecars []*types.
|
||||||
for j := range sidecar.Blobs {
|
for j := range sidecar.Blobs {
|
||||||
bundle.Blobs = append(bundle.Blobs, hexutil.Bytes(sidecar.Blobs[j][:]))
|
bundle.Blobs = append(bundle.Blobs, hexutil.Bytes(sidecar.Blobs[j][:]))
|
||||||
bundle.Commitments = append(bundle.Commitments, hexutil.Bytes(sidecar.Commitments[j][:]))
|
bundle.Commitments = append(bundle.Commitments, hexutil.Bytes(sidecar.Commitments[j][:]))
|
||||||
if len(sidecar.CellProofs[j]) == 0 {
|
if len(sidecar.CellProofs) == 0 {
|
||||||
bundle.Proofs = append(bundle.Proofs, hexutil.Bytes(sidecar.Proofs[j][:]))
|
bundle.Proofs = append(bundle.Proofs, hexutil.Bytes(sidecar.Proofs[j][:]))
|
||||||
} else {
|
} else {
|
||||||
for _, proof := range sidecar.CellProofs[j] {
|
for _, proof := range sidecar.CellProofs[j] {
|
||||||
|
|
|
||||||
57
beacon/engine/types_test.go
Normal file
57
beacon/engine/types_test.go
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
// Copyright 2025 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package engine
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
"github.com/ethereum/go-ethereum/crypto/kzg4844"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestBlobs(t *testing.T) {
|
||||||
|
var (
|
||||||
|
emptyBlob = new(kzg4844.Blob)
|
||||||
|
emptyBlobCommit, _ = kzg4844.BlobToCommitment(emptyBlob)
|
||||||
|
emptyBlobProof, _ = kzg4844.ComputeBlobProof(emptyBlob, emptyBlobCommit)
|
||||||
|
emptyCellProof, _ = kzg4844.ComputeCells(emptyBlob)
|
||||||
|
)
|
||||||
|
header := types.Header{}
|
||||||
|
block := types.NewBlock(&header, &types.Body{}, nil, nil)
|
||||||
|
|
||||||
|
sidecarWithoutCellProofs := &types.BlobTxSidecar{
|
||||||
|
Blobs: []kzg4844.Blob{*emptyBlob},
|
||||||
|
Commitments: []kzg4844.Commitment{emptyBlobCommit},
|
||||||
|
Proofs: []kzg4844.Proof{emptyBlobProof},
|
||||||
|
}
|
||||||
|
env := BlockToExecutableData(block, common.Big0, []*types.BlobTxSidecar{sidecarWithoutCellProofs}, nil)
|
||||||
|
if len(env.BlobsBundle.Proofs) != 1 {
|
||||||
|
t.Fatalf("Expect 1 proof in blobs bundle, got %v", len(env.BlobsBundle.Proofs))
|
||||||
|
}
|
||||||
|
|
||||||
|
sidecarWithCellProofs := &types.BlobTxSidecar{
|
||||||
|
Blobs: []kzg4844.Blob{*emptyBlob},
|
||||||
|
Commitments: []kzg4844.Commitment{emptyBlobCommit},
|
||||||
|
Proofs: []kzg4844.Proof{emptyBlobProof},
|
||||||
|
CellProofs: [][]kzg4844.Proof{emptyCellProof},
|
||||||
|
}
|
||||||
|
env = BlockToExecutableData(block, common.Big0, []*types.BlobTxSidecar{sidecarWithCellProofs}, nil)
|
||||||
|
if len(env.BlobsBundle.Proofs) != 128 {
|
||||||
|
t.Fatalf("Expect 128 proofs in blobs bundle, got %v", len(env.BlobsBundle.Proofs))
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue