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

message max size fixes + calculation #189

Merged
merged 5 commits into from
Apr 30, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion qbft/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ type SignedMessage struct {
Signers []types.OperatorID `ssz-max:"13"`
Message Message // message for which this signature is for

FullData []byte `ssz-max:"1073872896"` // 2^30+2^17
FullData []byte `ssz-max:"4219064"` // 2^22 + 2^15 (see SSV message max size)
}

func (signedMsg *SignedMessage) GetSignature() types.Signature {
Expand Down
12 changes: 6 additions & 6 deletions qbft/messages_encoding.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 18 additions & 1 deletion types/consensus_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,24 @@ type ConsensusData struct {
Duty Duty
Version spec.DataVersion
PreConsensusJustifications []*SignedPartialSignatureMessage `ssz-max:"13"`
DataSSZ []byte `ssz-max:"1073807360"` // 2^30+2^16 (considering max block size 2^30)
// DataSSZ has max size as following
// Biggest object is a full beacon block
// BeaconBlock is 2*32+2*8 + BeaconBlockBody
// BeaconBlockBody is
// 96 + ETH1Data(2*32+8) + 32 +
// 16*ProposerSlashing(2*SignedBeaconBlockHeader(96 + 3*32 + 2*8)) +
// 2*AttesterSlashing(2*IndexedAttestation(2048*8 + 96 + AttestationData(2*8 + 32 + 2*(8+32)))) +
// 128*Attestation(2048*8 + 96 + AttestationData(2*8 + 32 + 2*(8+32))) +
// 16*Deposit(33*32 + 48 + 32 + 8 + 96) +
// 16*SignedVoluntaryExit(96 + 2*8) +
// SyncAggregate(64 + 96) +
// ExecutionPayload(32 + 20 + 2*32 + 256 + 32 + 4*8 + 3*32 + 1048576*1073741824)
// = 2^21(everything but transactions) + 2^50 (transaction list)
// We do not need to support such a big DataSSZ size as 2^50 represents 1000X the actual block gas limit
// Current 30M gas limit produces 30M / 16 (call data cost) = 1,875,000 bytes (https://eips.ethereum.org/EIPS/eip-4488)
// we can upper limit transactions to 2^21, together with the rest of the data 2*2^21 = 2^22 = 4,194,304 bytes
// Exmplanation on why transaction sizes are so big https://github.com/ethereum/consensus-specs/pull/2686
DataSSZ []byte `ssz-max:"4194304"` // 2^22
}

func (cid *ConsensusData) Validate() error {
Expand Down
12 changes: 6 additions & 6 deletions types/consensus_data_encoding.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion types/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,14 @@ type MessageSignature interface {
type SSVMessage struct {
MsgType MsgType
MsgID MessageID `ssz-size:"56"`
Data []byte `ssz-max:"1074003968"` // 2^30+2^18
// Data max size as following
// Needs to support the largest ConsensusData possible which is
// Duty(8 + 48 + 6*8 + 13*8)
// Version (8)
// 13*SignedPartialSignatureMessage(8 + 96 + PartialSignatureMessages(2*8 + 13*PartialSignatureMessage(96+32+8)))
// DataSSZ max 2^22 = 4,194,304
// Max size is 4,219,064 = 2^22 + 2^15
Data []byte `ssz-max:"8421376"` // 2^23 + 2^15
}

func (msg *SSVMessage) GetType() MsgType {
Expand Down
12 changes: 6 additions & 6 deletions types/messages_encoding.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.