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

Move more more kzg functions to shared libarary in geth #38

Merged
merged 2 commits into from
Nov 16, 2022
Merged
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
8 changes: 4 additions & 4 deletions beacon-chain/core/transition/transition_no_verify_sig.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"context"
"fmt"

"github.com/ethereum/go-ethereum/crypto/kzg"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/altair"
b "github.com/prysmaticlabs/prysm/v3/beacon-chain/core/blocks"
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/transition/interop"
v "github.com/prysmaticlabs/prysm/v3/beacon-chain/core/validators"
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
"github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
"github.com/prysmaticlabs/prysm/v3/consensus-types/forks/eip4844"
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
"github.com/prysmaticlabs/prysm/v3/crypto/bls"
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
Expand Down Expand Up @@ -275,16 +275,16 @@ func ProcessBlobKzgs(ctx context.Context, state state.BeaconState, body interfac
if err != nil {
return nil, errors.Wrap(err, "could not get blob kzgs from block")
}
blobKzgsInput := make([][48]byte, len(blobKzgs))
blobKzgsInput := make(kzg.KZGCommitmentSequenceImpl, len(blobKzgs))
for i := range blobKzgs {
blobKzgsInput[i] = bytesutil.ToBytes48(blobKzgs[i])
blobKzgsInput[i] = kzg.KZGCommitment(bytesutil.ToBytes48(blobKzgs[i]))
}

txs, err := payload.Transactions()
if err != nil {
return nil, errors.Wrap(err, "could not get transactions from payload")
}
if err := eip4844.VerifyKzgsAgainstTxs(txs, blobKzgsInput); err != nil {
if err := kzg.VerifyKZGCommitmentsAgainstTransactions(txs, blobKzgsInput); err != nil {
return nil, errors.Wrap(err, "could not verify kzgs against txs")
}
return state, nil
Expand Down
15 changes: 4 additions & 11 deletions beacon-chain/sync/validate_beacon_blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"fmt"
"time"

"github.com/ethereum/go-ethereum/crypto/kzg"
"github.com/libp2p/go-libp2p-core/peer"
pubsub "github.com/libp2p/go-libp2p-pubsub"
"github.com/pkg/errors"
"github.com/protolambda/go-kzg/bls"
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/blocks"
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/feed"
blockfeed "github.com/prysmaticlabs/prysm/v3/beacon-chain/core/feed/block"
Expand All @@ -18,7 +18,6 @@ import (
"github.com/prysmaticlabs/prysm/v3/config/features"
"github.com/prysmaticlabs/prysm/v3/config/params"
consensusblocks "github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
"github.com/prysmaticlabs/prysm/v3/consensus-types/forks/eip4844"
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
Expand Down Expand Up @@ -294,21 +293,15 @@ func (s *Service) validateEIP4844BeaconBlock(ctx context.Context, parentState st
if err != nil {
return err
}
blobKzgsInput := make([][48]byte, len(blobKzgs))
blobKzgsInput := make(kzg.KZGCommitmentSequenceImpl, len(blobKzgs))
for i := range blobKzgs {
if len(blobKzgs[i]) != 48 {
return errors.New("invalid blob kzg length")
}
if _, err := bls.FromCompressedG1(blobKzgs[i]); err != nil {
return errors.Wrap(err, "invalid blob kzg encoding")
}
blobKzgsInput[i] = bytesutil.ToBytes48(blobKzgs[i])
blobKzgsInput[i] = kzg.KZGCommitment(bytesutil.ToBytes48(blobKzgs[i]))
}
txs, err := payload.Transactions()
if err != nil {
return err
}
return eip4844.VerifyKzgsAgainstTxs(txs, blobKzgsInput)
return kzg.VerifyKZGCommitmentsAgainstTransactions(txs, blobKzgsInput)
}

// validateBellatrixBeaconBlock validates the block for the Bellatrix fork.
Expand Down
101 changes: 0 additions & 101 deletions consensus-types/forks/eip4844/tx.go

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,4 @@ replace github.com/json-iterator/go => github.com/prestonvanloon/go v1.1.7-0.201
replace github.com/grpc-ecosystem/grpc-gateway/v2 => github.com/prysmaticlabs/grpc-gateway/v2 v2.3.1-0.20220721162526-0d1c40b5f064

// For eip-4844 types
replace github.com/ethereum/go-ethereum => github.com/mdehoog/go-ethereum v1.10.19-0.20221114011613-42a69e6e01ae
replace github.com/ethereum/go-ethereum => github.com/mdehoog/go-ethereum v1.10.19-0.20221116191641-aa63d265361b
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -865,8 +865,8 @@ github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsO
github.com/mattn/go-tty v0.0.0-20180907095812-13ff1204f104/go.mod h1:XPvLUNfbS4fJH25nqRHfWLMa1ONC8Amw+mIA639KxkE=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mdehoog/go-ethereum v1.10.19-0.20221114011613-42a69e6e01ae h1:2wXfDkt06PPDhG4Lxkse69fDegYljvz9fSZExd5V41c=
github.com/mdehoog/go-ethereum v1.10.19-0.20221114011613-42a69e6e01ae/go.mod h1:g+vX1+faxlr/KM1C0wybtfdcH5aPghqJAfpLGAn+Kbk=
github.com/mdehoog/go-ethereum v1.10.19-0.20221116191641-aa63d265361b h1:1+lop5PhC3ilW7lthuSFf1DWxSb5X6O+kd7I6nvbi3c=
github.com/mdehoog/go-ethereum v1.10.19-0.20221116191641-aa63d265361b/go.mod h1:g+vX1+faxlr/KM1C0wybtfdcH5aPghqJAfpLGAn+Kbk=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4=
Expand Down