mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 13:58:09 -05:00
Compare commits
4 Commits
concurrent
...
blob-verif
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1220ede880 | ||
|
|
7d06463758 | ||
|
|
867cabfb09 | ||
|
|
ccc451c6dc |
@@ -45,6 +45,22 @@ var GossipSidecarRequirements = []Requirement{
|
||||
RequireSidecarProposerExpected,
|
||||
}
|
||||
|
||||
// GossipSidecarRequirements defines the set of requirements that BlobSidecars received on gossip
|
||||
// must satisfy in order to upgrade an ROBlob to a VerifiedROBlob.
|
||||
var SpectestSidecarRequirements = []Requirement{
|
||||
RequireBlobIndexInBounds,
|
||||
//RequireNotFromFutureSlot,
|
||||
//RequireSlotAboveFinalized,
|
||||
// RequireValidProposerSignature,
|
||||
//RequireSidecarParentSeen,
|
||||
//RequireSidecarParentValid,
|
||||
//RequireSidecarParentSlotLower,
|
||||
//RequireSidecarDescendsFromFinalized,
|
||||
RequireSidecarInclusionProven,
|
||||
RequireSidecarKzgProofVerified,
|
||||
//RequireSidecarProposerExpected,
|
||||
}
|
||||
|
||||
// InitsyncSidecarRequirements is the list of verification requirements to be used by the init-sync service
|
||||
// for batch-mode syncing. Because we only perform batch verification as part of the IsDataAvailable method
|
||||
// for blobs after the block has been verified, and the blobs to be verified are keyed in the cache by the
|
||||
@@ -261,7 +277,7 @@ func (bv *ROBlobVerifier) SidecarDescendsFromFinalized() (err error) {
|
||||
func (bv *ROBlobVerifier) SidecarInclusionProven() (err error) {
|
||||
defer bv.recordResult(RequireSidecarInclusionProven, &err)
|
||||
if err = blocks.VerifyKZGInclusionProof(bv.blob); err != nil {
|
||||
log.WithError(err).WithFields(logging.BlobFields(bv.blob)).Debug("sidecar inclusion proof verification failed")
|
||||
log.WithError(err).WithFields(logging.BlobFields(bv.blob)).Error("sidecar inclusion proof verification failed")
|
||||
return ErrSidecarInclusionProofInvalid
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -13,11 +13,17 @@ type VerificationMultiError struct {
|
||||
|
||||
// Unwrap is used by errors.Is to unwrap errors.
|
||||
func (ve VerificationMultiError) Unwrap() error {
|
||||
if ve.err == nil {
|
||||
return nil
|
||||
}
|
||||
return ve.err
|
||||
}
|
||||
|
||||
// Error satisfies the standard error interface.
|
||||
func (ve VerificationMultiError) Error() string {
|
||||
if ve.err == nil {
|
||||
return ""
|
||||
}
|
||||
return ve.err.Error()
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,5 @@ import (
|
||||
)
|
||||
|
||||
func TestMainnet_Deneb_Forkchoice(t *testing.T) {
|
||||
t.Skip("This will fail until we re-integrate proof verification")
|
||||
forkchoice.Run(t, "mainnet", version.Deneb)
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ go_library(
|
||||
"//beacon-chain/db/filesystem:go_default_library",
|
||||
"//beacon-chain/db/testing:go_default_library",
|
||||
"//beacon-chain/execution:go_default_library",
|
||||
"//beacon-chain/forkchoice:go_default_library",
|
||||
"//beacon-chain/forkchoice/doubly-linked-tree:go_default_library",
|
||||
"//beacon-chain/operations/attestations:go_default_library",
|
||||
"//beacon-chain/startup:go_default_library",
|
||||
@@ -36,6 +37,7 @@ go_library(
|
||||
"//consensus-types/payload-attribute:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
"//math:go_default_library",
|
||||
"//proto/engine/v1:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//runtime/version:go_default_library",
|
||||
|
||||
@@ -10,7 +10,9 @@ import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/execution"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/startup"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/verification"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
@@ -23,16 +25,20 @@ type Builder struct {
|
||||
service *blockchain.Service
|
||||
lastTick int64
|
||||
execMock *engineMock
|
||||
vwait *verification.InitializerWaiter
|
||||
}
|
||||
|
||||
func NewBuilder(t testing.TB, initialState state.BeaconState, initialBlock interfaces.ReadOnlySignedBeaconBlock) *Builder {
|
||||
execMock := &engineMock{
|
||||
powBlocks: make(map[[32]byte]*ethpb.PowBlock),
|
||||
}
|
||||
service := startChainService(t, initialState, initialBlock, execMock)
|
||||
cw := startup.NewClockSynchronizer()
|
||||
service, sg, fc := startChainService(t, initialState, initialBlock, execMock, cw)
|
||||
bvw := verification.NewInitializerWaiter(cw, fc, sg)
|
||||
return &Builder{
|
||||
service: service,
|
||||
execMock: execMock,
|
||||
vwait: bvw,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,9 @@ func runTest(t *testing.T, config string, fork int, basePath string) {
|
||||
|
||||
for _, folder := range testFolders {
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
if folder.Name() != "simple_blob_data" {
|
||||
t.Skip("Skipping test folder")
|
||||
}
|
||||
preStepsFile, err := util.BazelFileBytes(testsFolderPath, folder.Name(), "steps.yaml")
|
||||
require.NoError(t, err)
|
||||
var steps []Step
|
||||
@@ -305,22 +308,15 @@ func runBlobStep(t *testing.T,
|
||||
require.NoError(t, err)
|
||||
sh, err := beaconBlock.Header()
|
||||
require.NoError(t, err)
|
||||
for index := uint64(0); index*fieldparams.BlobLength < uint64(len(blobsSSZ)); index++ {
|
||||
for index := 0; index*fieldparams.BlobLength < len(blobsSSZ); index++ {
|
||||
var proof []byte
|
||||
if index < uint64(len(proofs)) {
|
||||
if index < len(proofs) {
|
||||
proofPTR := proofs[index]
|
||||
require.NotNil(t, proofPTR)
|
||||
proof, err = hexutil.Decode(*proofPTR)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
var kzg []byte
|
||||
if uint64(len(kzgs)) < index {
|
||||
kzg = kzgs[index]
|
||||
}
|
||||
if len(kzg) == 0 {
|
||||
kzg = make([]byte, 48)
|
||||
}
|
||||
blob := [fieldparams.BlobLength]byte{}
|
||||
copy(blob[:], blobsSSZ[index*fieldparams.BlobLength:])
|
||||
fakeProof := make([][]byte, fieldparams.KzgCommitmentInclusionProofDepth)
|
||||
@@ -330,18 +326,47 @@ func runBlobStep(t *testing.T,
|
||||
if len(proof) == 0 {
|
||||
proof = make([]byte, 48)
|
||||
}
|
||||
|
||||
inclusionProof, err := blocks.MerkleProofKZGCommitment(block.Body(), index)
|
||||
require.NoError(t, err)
|
||||
pb := ðpb.BlobSidecar{
|
||||
Index: index,
|
||||
Index: uint64(index),
|
||||
Blob: blob[:],
|
||||
KzgCommitment: kzg,
|
||||
KzgCommitment: kzgs[index],
|
||||
KzgProof: proof,
|
||||
SignedBlockHeader: sh,
|
||||
CommitmentInclusionProof: fakeProof,
|
||||
CommitmentInclusionProof: inclusionProof,
|
||||
}
|
||||
ro, err := blocks.NewROBlobWithRoot(pb, root)
|
||||
require.NoError(t, err)
|
||||
vsc, err := verification.BlobSidecarNoop(ro)
|
||||
ini, err := builder.vwait.WaitForInitializer(context.Background())
|
||||
require.NoError(t, err)
|
||||
bv := ini.NewBlobVerifier(ro, verification.SpectestSidecarRequirements)
|
||||
// WIP: still skipped
|
||||
// //RequireNotFromFutureSlot,
|
||||
// //RequireSlotAboveFinalized,
|
||||
// //RequireSidecarParentSeen,
|
||||
// //RequireSidecarParentValid,
|
||||
// //RequireSidecarParentSlotLower,
|
||||
// //RequireSidecarDescendsFromFinalized,
|
||||
// //RequireSidecarProposerExpected,
|
||||
require.NoError(t, bv.BlobIndexInBounds())
|
||||
require.NoError(t, bv.SidecarInclusionProven())
|
||||
require.NoError(t, bv.SidecarKzgProofVerified())
|
||||
//require.NoError(t, bv.ValidProposerSignature(ctx))
|
||||
vsc, err := bv.VerifiedROBlob()
|
||||
if err != nil {
|
||||
require.ErrorIs(t, err, verification.ErrBlobInvalid)
|
||||
me, ok := err.(verification.VerificationMultiError)
|
||||
require.Equal(t, true, ok)
|
||||
fails := me.Failures()
|
||||
// we haven't performed any verification, so all the results should be this type
|
||||
msg := ""
|
||||
for _, v := range fails {
|
||||
msg += fmt.Sprintf("; %s", v.Error())
|
||||
}
|
||||
t.Fatal(msg)
|
||||
}
|
||||
require.NoError(t, builder.service.ReceiveBlob(context.Background(), vsc))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
coreTime "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/time"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/db/filesystem"
|
||||
testDB "github.com/prysmaticlabs/prysm/v5/beacon-chain/db/testing"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/forkchoice"
|
||||
doublylinkedtree "github.com/prysmaticlabs/prysm/v5/beacon-chain/forkchoice/doubly-linked-tree"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/operations/attestations"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/startup"
|
||||
@@ -34,7 +35,8 @@ func startChainService(t testing.TB,
|
||||
st state.BeaconState,
|
||||
block interfaces.ReadOnlySignedBeaconBlock,
|
||||
engineMock *engineMock,
|
||||
) *blockchain.Service {
|
||||
clockSync *startup.ClockSynchronizer,
|
||||
) (*blockchain.Service, *stategen.State, forkchoice.ForkChoicer) {
|
||||
ctx := context.Background()
|
||||
db := testDB.SetupDB(t)
|
||||
require.NoError(t, db.SaveBlock(ctx, block))
|
||||
@@ -58,28 +60,30 @@ func startChainService(t testing.TB,
|
||||
require.NoError(t, err)
|
||||
|
||||
fc := doublylinkedtree.New()
|
||||
sg := stategen.New(db, fc)
|
||||
opts := append([]blockchain.Option{},
|
||||
blockchain.WithExecutionEngineCaller(engineMock),
|
||||
blockchain.WithFinalizedStateAtStartUp(st),
|
||||
blockchain.WithDatabase(db),
|
||||
blockchain.WithAttestationService(attPool),
|
||||
blockchain.WithForkChoiceStore(fc),
|
||||
blockchain.WithStateGen(stategen.New(db, fc)),
|
||||
blockchain.WithStateGen(sg),
|
||||
blockchain.WithStateNotifier(&mock.MockStateNotifier{}),
|
||||
blockchain.WithAttestationPool(attestations.NewPool()),
|
||||
blockchain.WithDepositCache(depositCache),
|
||||
blockchain.WithTrackedValidatorsCache(cache.NewTrackedValidatorsCache()),
|
||||
blockchain.WithPayloadIDCache(cache.NewPayloadIDCache()),
|
||||
blockchain.WithClockSynchronizer(startup.NewClockSynchronizer()),
|
||||
blockchain.WithClockSynchronizer(clockSync),
|
||||
blockchain.WithBlobStorage(filesystem.NewEphemeralBlobStorage(t)),
|
||||
blockchain.WithSyncChecker(mock.MockChecker{}),
|
||||
blockchain.WithBlobStorage(filesystem.NewEphemeralBlobStorage(t)),
|
||||
)
|
||||
service, err := blockchain.NewService(context.Background(), opts...)
|
||||
require.NoError(t, err)
|
||||
// force start kzg context here until Deneb fork epoch is decided
|
||||
require.NoError(t, kzg.Start())
|
||||
require.NoError(t, service.StartFromSavedState(st))
|
||||
return service
|
||||
return service, sg, fc
|
||||
}
|
||||
|
||||
type engineMock struct {
|
||||
|
||||
Reference in New Issue
Block a user