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

merge from upstream #31

Open
wants to merge 83 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
90a2c3d
P2P/ msg validation function (#132)
alonmuroch Dec 13, 2022
78e0cf0
P2P/ msg validation future messages
alonmuroch Dec 13, 2022
0a5c9e1
inconsistent partial sig signer tests + fixes (#137)
alonmuroch Dec 18, 2022
aa8e29e
qbft/ past round justification test
alonmuroch Dec 18, 2022
90d0944
qbft/ Round validation for consensus messages (#138)
amirylm Dec 26, 2022
678369e
fix postconsensus post quorum test (#143)
alonmuroch Dec 27, 2022
4cb8111
Beacon Interface Adjust (#126)
nivBlox Dec 27, 2022
9c38951
ssv/ fix start duty after future decided (#144)
alonmuroch Dec 28, 2022
17ac6f1
downgrade libp2p version (#145)
nivBlox Jan 1, 2023
70cfe04
ssv/ blinded block support (#147)
alonmuroch Jan 9, 2023
3526f38
ssv/ Slashing protection adjustments (#151)
olegshmuelov Jan 16, 2023
37a78c8
pass domain type to signBeaconObj func instead of the role (#152)
olegshmuelov Jan 18, 2023
0a41423
SSZ message struct (#168)
Mar 12, 2023
c94b6b2
fix: swap `to, from` -> `from, to` in `SyncDecidedByRange` (#141)
moshe-blox Mar 12, 2023
a55b83b
readme remove todo
alonmuroch Mar 14, 2023
dee066c
testingutils: don't ignore encoding errors (#166)
moshe-blox Mar 21, 2023
66c1585
change TestingSyncCommitteeBlockRoot to non zero (#176)
alonmuroch Mar 21, 2023
2ae3460
ssz: fix missing `Slot` in construction of `PartialSignatureMessages`…
moshe-blox Mar 21, 2023
22f5699
spec tests: comparable spec tests phase 0 (#179)
alonmuroch Apr 13, 2023
1c1da45
fixed github pipline + json testing (#184)
alonmuroch Apr 13, 2023
1604904
Spec test speed fix (#185)
alonmuroch Apr 16, 2023
234d402
to implement wrong pub key test
alonmuroch Apr 16, 2023
0e55c3e
message max size fixes + calculation (#189)
alonmuroch Apr 30, 2023
8f827ea
Pre cons liveness (#186)
alonmuroch Apr 30, 2023
2023d3c
ssz: implement non-implemented tests (#165)
nkryuchkov May 1, 2023
a2668a4
use full path for ssz (#206)
GalRogozinski May 1, 2023
f098e8c
Dynamic state comparison (#191)
olegshmuelov May 3, 2023
526b36e
Version Block Support base (#208)
olegshmuelov May 9, 2023
6af0029
SSV comparable state (#215)
olegshmuelov May 10, 2023
61f5b99
Issue D: wrong message type check (#218)
GalRogozinski May 11, 2023
b8be134
Version Block Support - testing infrastructure (#223)
olegshmuelov May 11, 2023
600805e
Version block support testing infra align tests 1 (#230)
GalRogozinski May 14, 2023
0f4bc3f
Version block support testing infra align tests 2 (#229)
GalRogozinski May 14, 2023
758283c
versioned runner/postconsensus (#231)
GalRogozinski May 14, 2023
db5dbf1
versioned runner/pre_consensus_justifications (#232)
GalRogozinski May 14, 2023
54b6af4
versioned runner/preconsensus (#236)
GalRogozinski May 14, 2023
ee80cd9
Version block support testing infra align tests 6 (#237)
GalRogozinski May 14, 2023
83995dc
crypto fixes
alonmuroch May 15, 2023
768e2ee
fix running ssv spec tests in parallel
alonmuroch May 17, 2023
0e0eb7c
remove non-versioned funcs (#238)
GalRogozinski May 21, 2023
d549a20
MEV support (#226)
nkryuchkov May 21, 2023
89abc38
SSV JSON spectest deadlock fix (#248)
olegshmuelov May 23, 2023
cc252b7
Capella support (#257)
May 24, 2023
2af3a73
Issue A - Missing Check on Quorum for the RoundChange Justification (…
GalRogozinski May 24, 2023
af449bf
Issue C: Missing Tests Could Lead to Incorrect Implementations (#216)
GalRogozinski May 24, 2023
820f72b
Disable Pre-consensus Liveness (#260)
moshe-blox May 28, 2023
054f151
Update dependencies (#265)
GalRogozinski May 31, 2023
3b3f023
State comparison - QBFT controller/processmsg (#209)
olegshmuelov Jun 6, 2023
a3c3a55
[Audit Suggestion 6] Update dependencies (#268)
nkryuchkov Jun 6, 2023
4bb9266
fix: only fetch contributions if there are aggregators (#251)
moshe-blox Jun 6, 2023
f5857d8
State comparison - QBFT controller/decided (#190)
olegshmuelov Jun 6, 2023
d39d1bb
State comparison - QBFT roundchange (#211)
olegshmuelov Jun 6, 2023
2bdb0fd
State comparison - QBFT proposal (#210)
olegshmuelov Jun 13, 2023
3ee4474
State comparison - QBFT startinstance timeout (#212)
olegshmuelov Jun 13, 2023
74a1278
State comparison - SSV runner/preconsensus (#256)
olegshmuelov Jun 13, 2023
228ad0c
State comparison - SSV runner/postconsensus (#255)
olegshmuelov Jun 19, 2023
3a3cd03
State comparison - SSV runner/duties/newduty (#254)
olegshmuelov Jun 19, 2023
befa08d
State comparison - SSV runner/consensus (#253)
olegshmuelov Jun 19, 2023
2f33257
State Comparison - QBFT controller/futuremsg controller/latemsg (#192)
olegshmuelov Jun 19, 2023
9393cbb
State comparison json (#275)
alonmuroch Jun 21, 2023
7be211a
Additional SSV GetPostState implementations (#281)
GalRogozinski Jul 6, 2023
753958e
Spec - Remove QBFT instance requirement for an instance to decide for…
alonmuroch Jul 11, 2023
7250755
[Meta] - Fix SC dir names and files (#286)
GalRogozinski Jul 12, 2023
1c00440
add missing roots (#293)
GalRogozinski Jul 19, 2023
bdee58f
no need to switch wrong sig when you tinker with signer id (#272)
GalRogozinski Jul 30, 2023
0f5af1c
Don't start lower height duty (#295)
GalRogozinski Aug 1, 2023
c41e52c
delete comment (#273)
GalRogozinski Aug 1, 2023
8b61509
fix comments (#298)
GalRogozinski Aug 1, 2023
ff93081
Meta - remove backwards compatibility (#299)
GalRogozinski Aug 8, 2023
8108014
Tests - Stop instances tests (#297)
GalRogozinski Aug 13, 2023
312afd7
Spec - Remove future msg and syncing requirements (#300)
GalRogozinski Aug 17, 2023
80c510b
Voluntary exit (#306)
MatheusFranco99 Aug 30, 2023
264723e
Add audit report
GalRogozinski Sep 7, 2023
384b025
Merge pull request #309 from bloxapp/audit
Sep 7, 2023
8fd4372
drop blinded block rejection (#305)
moshe-blox Sep 11, 2023
f6e77dd
holesky support (#314)
Oct 19, 2023
071ed76
Don't change characters in base dir when generating jsons (#313)
GalRogozinski Oct 19, 2023
58f3ed8
Spec - Consider first height in should process duty (#316)
GalRogozinski Oct 31, 2023
36b1d5e
Spec - Validator registration and voluntary exit now stop old duties …
GalRogozinski Nov 7, 2023
54513c4
Spec - Fork support (#310)
MatheusFranco99 Nov 7, 2023
312dc37
Fix beacon node call for voluntary exit (#319)
MatheusFranco99 Nov 15, 2023
95dcf83
Merge branch 'main' of github.com:bloxapp/ssv-spec into bloxapp-main
aayush-rockx Nov 27, 2023
17f15f6
fix misc tests and post merge version issue
aayush-rockx Nov 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version: 1.19

- name: Get Dependencies
run: go get -v -t -d ./...
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version: 1.19

- name: Get Dependencies
run: go get -v -t -d ./...
Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ fmt:

.PHONY: test
test:
@go test -v -race -timeout 20m "${TEST_PKG}"
@go test -v -race -timeout 25m "${TEST_PKG}"

.PHONY: generate-jsons
generate-jsons:
@go generate ./...

.PHONY: generate-ssz
generate-ssz:
@go generate ./qbft/
@go generate ./ssv/
@go generate ./types/
16 changes: 1 addition & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func ComputeSigningRoot(data MessageRoot, domain SignatureDomain) ([]byte, error
return nil, errors.Wrap(err, "could not get root from MessageRoot")
}

ret := sha256.Sum256(append(dataRoot, domain...))
ret := sha256.Sum256(append(dataRoot[:], domain...))
return ret[:], nil
}
```
Expand Down Expand Up @@ -184,17 +184,3 @@ To generate all json spec tests, run:
foo@bar:~$ go generate ./...
```
Then run all tests

## TODO
- [//] Proposal duty execution + spec test + consensus validator
- [//] Aggregator duty execution + spec test + consensus validator
- [//] Sync committee duty execution + spec test + consensus validator
- [//] Sync committee aggregator duty
- [ ] Duty data validation (how do we ensure malicious leader doesn't proposer a non slashable attestation/ block but with invalid data)
- [ ] Wait 1/3 or 2/3 of slot during duty execution? how else?
- [X] implement 7,10,13 committee sizes
- [X] improve pre-consensus partial sigs to support signed roots which are not necessarily what the local node signed (example: node 1 signed randao/ selection proof root X but nodes 2,3,4 signed Y)
- [X] pre and post consensus timeout redesign as 32 slot timeout can cause the next duty not to start (if it starts in less than 32 slots)
- [ ] Move ConsensusData struct to ssv package
- [ ] Remove? storage interface? do we use it?
- [ ] move spec structs from go-eth2-client to protolambda/zrnt?
10 changes: 0 additions & 10 deletions dkg/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion dkg/frost/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ func haveSameRoot(existingMessage, newMessage *dkg.SignedMessage) bool {
if err != nil {
return false
}
return bytes.Equal(r1, r2)
return bytes.Equal(r1[:], r2[:])
}
2 changes: 1 addition & 1 deletion dkg/frost/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func (fr *Instance) validateSignedMessage(msg *dkg.SignedMessage) error {
return errors.Wrap(err, "failed to get root")
}

if !types.Verify(operator.EncryptionPubKey, root, msg.Signature) {
if !types.Verify(operator.EncryptionPubKey, root[:], msg.Signature) {
return errors.New("invalid signature")
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion dkg/keysign/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (instance *Instance) validateSignedMessage(msg *dkg.SignedMessage) error {
return errors.Wrap(err, "failed to get root")
}

if !types.Verify(operator.EncryptionPubKey, root, msg.Signature) {
if !types.Verify(operator.EncryptionPubKey, root[:], msg.Signature) {
return errors.New("invalid signature")
}
return nil
Expand Down
71 changes: 20 additions & 51 deletions dkg/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/bloxapp/ssv-spec/types"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/herumi/bls-eth-go-binary/bls"
Expand Down Expand Up @@ -85,13 +84,12 @@ func (msg *Message) Validate() error {
return nil
}

func (msg *Message) GetRoot() ([]byte, error) {
func (msg *Message) GetRoot() ([32]byte, error) {
marshaledRoot, err := msg.Encode()
if err != nil {
return nil, errors.Wrap(err, "could not encode PartialSignatureMessage")
return [32]byte{}, errors.Wrap(err, "could not encode Message")
}
ret := sha256.Sum256(marshaledRoot)
return ret[:], nil
return sha256.Sum256(marshaledRoot), nil
}

type SignedMessage struct {
Expand All @@ -116,7 +114,7 @@ func (signedMsg *SignedMessage) Validate() error {
return signedMsg.Message.Validate()
}

func (signedMsg *SignedMessage) GetRoot() ([]byte, error) {
func (signedMsg *SignedMessage) GetRoot() ([32]byte, error) {
return signedMsg.Message.GetRoot()
}

Expand Down Expand Up @@ -245,34 +243,20 @@ type Output struct {
DepositDataSignature types.Signature
}

func (o *Output) GetRoot() ([]byte, error) {
bytesSolidity, _ := abi.NewType("bytes", "", nil)

arguments := abi.Arguments{
{
Type: bytesSolidity,
},
{
Type: bytesSolidity,
},
{
Type: bytesSolidity,
},
{
Type: bytesSolidity,
},
}
func (o *Output) Encode() ([]byte, error) {
return json.Marshal(o)
}

func (o *Output) Decode(data []byte) error {
return json.Unmarshal(data, o)
}

bytes, err := arguments.Pack(
[]byte(o.EncryptedShare),
[]byte(o.SharePubKey),
[]byte(o.ValidatorPubKey),
[]byte(o.DepositDataSignature),
)
func (o *Output) GetRoot() ([32]byte, error) {
marshaledRoot, err := o.Encode()
if err != nil {
return nil, err
return [32]byte{}, errors.Wrap(err, "could not encode Message")
}
return crypto.Keccak256(bytes), nil
return sha256.Sum256(marshaledRoot), nil
}

type SignedOutput struct {
Expand Down Expand Up @@ -314,27 +298,12 @@ func (msg *BlameData) Decode(data []byte) error {
return json.Unmarshal(data, msg)
}

func (msg *BlameData) GetRoot() ([]byte, error) {
bytesSolidity, _ := abi.NewType("bytes", "", nil)
boolSolidity, _ := abi.NewType("bool", "", nil)

arguments := abi.Arguments{
{
Type: boolSolidity,
},
{
Type: bytesSolidity,
},
}

bytes, err := arguments.Pack(
msg.Valid,
[]byte(msg.BlameMessage),
)
func (msg *BlameData) GetRoot() ([32]byte, error) {
marshaledRoot, err := msg.Encode()
if err != nil {
return nil, err
return [32]byte{}, errors.Wrap(err, "could not encode Message")
}
return crypto.Keccak256(bytes), nil
return sha256.Sum256(marshaledRoot), nil
}

func SignOutput(output *Output, privKey *ecdsa.PrivateKey) (types.Signature, error) {
Expand All @@ -343,7 +312,7 @@ func SignOutput(output *Output, privKey *ecdsa.PrivateKey) (types.Signature, err
return nil, errors.Wrap(err, "could not get root from output message")
}

return crypto.Sign(root, privKey)
return crypto.Sign(root[:], privKey)
}

// PartialDepositData contains a partial deposit data signature
Expand Down
84 changes: 0 additions & 84 deletions dkg/messages_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion dkg/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func (n *Node) validateSignedMessage(message *SignedMessage) error {
Signer: message.Signer,
}, types.ComputeSignatureDomain(n.config.SignatureDomainType, types.DKGSignatureType))

isValid := types.Verify(operator.EncryptionPubKey, root, message.Signature)
isValid := types.Verify(operator.EncryptionPubKey, root[:], message.Signature)
if !isValid {
return errors.Wrap(err, "signed message invalid")
}
Expand Down
34 changes: 16 additions & 18 deletions dkg/protocol.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package dkg

import (
"crypto/sha256"
"encoding/json"

"github.com/bloxapp/ssv-spec/types"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/crypto"
"github.com/herumi/bls-eth-go-binary/bls"
"github.com/pkg/errors"
)

type ProtocolOutcome struct {
Expand Down Expand Up @@ -50,24 +52,20 @@ type KeySignOutput struct {
ValidatorPK types.ValidatorPK
}

func (o *KeySignOutput) GetRoot() ([]byte, error) {
bytesSolidity, _ := abi.NewType("bytes", "", nil)
arguments := abi.Arguments{
{
Type: bytesSolidity,
},
{
Type: bytesSolidity,
},
}
bytes, err := arguments.Pack(
[]byte(o.ValidatorPK),
[]byte(o.Signature),
)
func (o *KeySignOutput) Encode() ([]byte, error) {
return json.Marshal(o)
}

func (o *KeySignOutput) Decode(data []byte) error {
return json.Unmarshal(data, o)
}

func (o *KeySignOutput) GetRoot() ([32]byte, error) {
marshaledRoot, err := o.Encode()
if err != nil {
return nil, err
return [32]byte{}, errors.Wrap(err, "could not encode Message")
}
return crypto.Keccak256(bytes), nil
return sha256.Sum256(marshaledRoot), nil
}

// BlameOutput is the output of blame round
Expand Down
6 changes: 4 additions & 2 deletions dkg/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package dkg

import (
"bytes"
"crypto/rand"
"crypto/rsa"
"fmt"

"github.com/bloxapp/ssv-spec/types"
Expand Down Expand Up @@ -232,7 +234,7 @@ func (r *runner) validateSignedOutput(msg *SignedOutput) error {
return errors.Wrap(err, "fail to get root")
}

isValid := types.Verify(operator.EncryptionPubKey, root, msg.Signature)
isValid := types.Verify(operator.EncryptionPubKey, root[:], msg.Signature)
if !isValid {
return errors.New("invalid signature")
}
Expand Down Expand Up @@ -310,7 +312,7 @@ func (r *runner) prepareAndBroadcastKeyGenOutput() error {
// TODO: this is encryped in such manner so that cli can generate a compatible
// keyshares file
// https://docs.ssv.network/developers/tools/ssv-key-distributor/ssv-keys-cli
encryptedShare, err := r.config.Signer.Encrypt(r.Operator.EncryptionPubKey, []byte("0x"+r.KeygenOutcome.ProtocolOutput.Share.SerializeToHexStr()))
encryptedShare, err := rsa.EncryptPKCS1v15(rand.Reader, r.Operator.EncryptionPubKey, []byte("0x"+r.KeygenOutcome.ProtocolOutput.Share.SerializeToHexStr()))
if err != nil {
return errors.Wrap(err, "could not encrypt share")
}
Expand Down
Loading
Loading