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

Deneb Support #324

Merged
merged 43 commits into from
Jan 21, 2024
Merged

Deneb Support #324

merged 43 commits into from
Jan 21, 2024

Conversation

MatheusFranco99
Copy link
Contributor

@MatheusFranco99 MatheusFranco99 commented Dec 20, 2023

Major changes

  • Added logical support to Deneb's beacon block in consensus data.
  • Note: When submitting a proposer duty output (VersionedProposal or VersionedBlindedProposal) to the Beacon node, Deneb uses:
    • VersionedBlindedProposal: a BlindedBeaconBlock, similarly to other forks.
    • VersionedProposal: BlockContents, differently from older forks which used BeaconBlocks. Nonetheless, the validator signature is still over the beacon block (BlockContents.Block), i.e. the signing root is kept the same.

Minor changes

  • Updated Attestantio lib from 0.16.3 to 0.19.7. Purpose: use up-to-date Deneb spec types.
  • Updated Fastssz from 0.1.2 to 0.1.3 as a consequence of the Attestantio update.
  • Deneb testing utils. To-Do: define Deneb fork epoch.
  • Added type tests.
  • Remove all Bellatrix objects and use Deneb.
  • Update ssz-max sizes for ConsensusData and FullData fields, since Deneb uses a BlockContents object which contains a Beacon block, KZGProofs (288 bytes) and Blobs of 786432 bytes.

SSZ generation notes

  • Fastssz 0.1.3 is now deterministic. Because of this, when you run make generate-ssz you may see new logs INFO: Skipped ssz generated object:.
  • Fastssz 0.1.3 seems to have an error which occurs in the consensus_data_encoding.go file. It imports an unused library. For that, we created an issue in Fastssz which remains unsolved. As a temporary arrangement, we added, in the generate.go in ./types, a command to remove the unused import.

Attestantio update notes

  • The default DataVersion used to be phase0. This was was changed to become unknown. Therefore, some testing utils that didn't define the DataVersion in the ConsensusData had to be updated.

Leftovers To-Do

  • Set the correct Deneb fork epoch.

References

@MatheusFranco99 MatheusFranco99 self-assigned this Dec 20, 2023
@MatheusFranco99 MatheusFranco99 marked this pull request as ready for review December 23, 2023 14:57
@@ -47,8 +47,8 @@ require (
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/crypto v0.10.0 // indirect
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This less matters for us in the spec project, but when ssv is forced to dot he same update it may affect performance as we learnt for the RSA debacle

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true. We shall do performance tests when included. Just to remember, for the RSA case, we're actually using microsoft's openssl so it's less of an issue.

panic(err.Error())
}

return &SSZSpecTest{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we only created an SSZSpecTest for Withdrawals because we had some custom logic for it (don't remember why). I think because the latest go-eth2-client release at the time didn't have it.
I think if BeaconBlock now supports withdrawals (and also Deneb blobs) we can remove the old withdrawals test and code (maybe in separate PR after this because we have enough code here)

Anyhow, you are aware of my evil plan with value check that will make all this logic/tests unnecessary 😈

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

types/ssz.go Outdated
Comment on lines 160 to 177
func (b SSZBlobZGCommitments) GetTree() (*ssz.Node, error) {
return ssz.ProofTree(b)
}

func (b SSZBlobZGCommitments) HashTreeRootWith(hh ssz.HashWalker) error {
// taken from https://github.com/attestantio/go-eth2-client/blob/a05485e0e75749f2b6912db2972a35ec2ec37c3b/spec/deneb/beaconblockbody_ssz.go#L577C3-L586C49
if size := len(b); size > 4096 {
err := ssz.ErrListTooBigFn("BeaconBlockBody.BlobKZGCommitments", size, 4096)
return err
}
subIndx := hh.Index()
for _, i := range b {
hh.PutBytes(i[:])
}
numItems := uint64(len(b))
hh.MerkleizeWithMixin(subIndx, numItems, 4096)
return nil
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you do this because we did the same thing with Withdrawals?

I think we did this to Withdrawals because there wasn't a release available at the time (am I correct @olegshmuelov ?)

If the updated go-eth2-client has this logic then I don't think we need to copy it..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see previous discussion
#234 (comment)

@GalRogozinski
Copy link
Contributor

GalRogozinski commented Dec 28, 2023

There seems to be some epoch activation epochs here

Not sure if it is final but maybe let's put this in and later change it so we can all approve this PR

@MatheusFranco99
Copy link
Contributor Author

@GalRogozinski If I update it, I start getting:

panic: can't start new duty runner instance for duty: input data invalid: duty invalid: duty epoch is into far future

because of the dutyValueCheck.

case spec.DataVersionCapella:
require.NotNil(t, vBlk.Capella)
blkSSZ, err = vBlk.Capella.MarshalSSZ()
require.NoError(t, err)
case spec.DataVersionDeneb:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you scroll up you see a comment for issue 219. IMO you can delete the comment and close the issue

@GalRogozinski
Copy link
Contributor

Closes #219

types/testingutils/beacon_node.go Outdated Show resolved Hide resolved
types/testingutils/beacon_node.go Outdated Show resolved Hide resolved
if vBlk.Deneb.Block == nil {
panic("empty block")
}
return &deneb.SignedBeaconBlock{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: there is also api/v1/deneb/signedblindedbeaconblock.go
shouldn't this one be used here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well noticed. I'm fixing it now. At first, I used version.SignedBeaconBlock because it was already being used for the blinded proposer beacon roots, strangely enough. But the correct one should be the SignedBlindedBeaconBlock indeed.

// 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
// we can upper limit transactions to 2^21, together with the rest of the data 1315964 + 2^21 = 3,413,116 bytes
Copy link
Contributor

@moshe-blox moshe-blox Jan 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did the max decrease from ~4MB to ~3MB (2*2^21 to 2^21)? If anything, the introduction of blobs should have increased our ssz-max, no?

BTW, they're thinking of increasing gas size from 30M to 40M very soon, we should probably adapt our calculations (if needed).

I think we could maybe check what was Prysm's approach to this. Prior to receiving blocks from peers, they must do some sort of validation on the size, I guess.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See this comment where we corrected a previous mistake regarding attestations:
#324 (comment)

checkout the commented python script

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they're thinking of increasing gas size from 30M to 40M very soon
When they are done thinking we'll fix this

it will only be on the next hard fork (best case) so there is time

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they're thinking of increasing gas size from 30M to 40M very soon
When they are done thinking we'll fix this

it will only be on the next hard fork (best case) so there is time

I think maybe we'd like to support a probable gas increase without having to fork?

@GalRogozinski GalRogozinski merged commit f2d5899 into main Jan 21, 2024
2 checks passed
@GalRogozinski GalRogozinski deleted the deneb-support branch January 21, 2024 13:51
GalRogozinski added a commit that referenced this pull request Jan 31, 2024
GalRogozinski added a commit that referenced this pull request Feb 1, 2024
GalRogozinski added a commit that referenced this pull request Feb 1, 2024
* Revert "Revert "Deneb Support (#324)""

This reverts commit 0a559e2.

* use custom old encodings

* generate-jsons

* Add phase0 version

* Bellatrix -> Capella on a single test

* Generate jsons

* Revert Capella -> Deneb on a single test

---------

Co-authored-by: MatheusFranco99 <[email protected]>
GalRogozinski added a commit that referenced this pull request Feb 1, 2024
…compatibility (#362)

* Revert "Deneb Support (#324)"

This reverts commit f2d5899.

* Add jsons (#357)

* create jsons

* compare with jsons

* generate jsons for qbft signed message

* compare qbft signed message with json state

* fix lint error

* generate jsons for create msg test

* generate jsons for create msg test

* use correct test type

* use correct test name

* Return deneb with old encoding (#360)

* Revert "Revert "Deneb Support (#324)""

This reverts commit 0a559e2.

* use custom old encodings

* generate-jsons

* Add phase0 version

* Bellatrix -> Capella on a single test

* Generate jsons

* Revert Capella -> Deneb on a single test

---------

Co-authored-by: MatheusFranco99 <[email protected]>

---------

Co-authored-by: MatheusFranco99 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants