mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
fixed deneb for devnet 6 (#7650)
This commit is contained in:
parent
999c0ba214
commit
e11c8192f8
@ -13,33 +13,15 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
MaxAttesterSlashings = 2
|
||||
MaxProposerSlashings = 16
|
||||
MaxAttestations = 128
|
||||
MaxDeposits = 16
|
||||
MaxVoluntaryExits = 16
|
||||
MaxExecutionChanges = 16
|
||||
MaxBlobsPerBlock = 4
|
||||
MaxAttesterSlashings = 2
|
||||
MaxProposerSlashings = 16
|
||||
MaxAttestations = 128
|
||||
MaxDeposits = 16
|
||||
MaxVoluntaryExits = 16
|
||||
MaxExecutionChanges = 16
|
||||
MaxBlobsCommittmentsPerBlock = 4096
|
||||
)
|
||||
|
||||
func getBeaconBlockMinimumSize(v clparams.StateVersion) (size uint32) {
|
||||
switch v {
|
||||
case clparams.DenebVersion:
|
||||
size = 392
|
||||
case clparams.CapellaVersion:
|
||||
size = 388
|
||||
case clparams.BellatrixVersion:
|
||||
size = 384
|
||||
case clparams.AltairVersion:
|
||||
size = 380
|
||||
case clparams.Phase0Version:
|
||||
size = 220
|
||||
default:
|
||||
panic("unimplemented version")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type SignedBeaconBlock struct {
|
||||
Signature [96]byte
|
||||
Block *BeaconBlock
|
||||
@ -100,7 +82,6 @@ func (b *BeaconBody) EncodeSSZ(dst []byte) ([]byte, error) {
|
||||
}
|
||||
|
||||
func (b *BeaconBody) EncodingSizeSSZ() (size int) {
|
||||
size = int(getBeaconBlockMinimumSize(b.Version))
|
||||
|
||||
if b.Eth1Data == nil {
|
||||
b.Eth1Data = &Eth1Data{}
|
||||
@ -133,7 +114,7 @@ func (b *BeaconBody) EncodingSizeSSZ() (size int) {
|
||||
b.ExecutionChanges = solid.NewStaticListSSZ[*SignedBLSToExecutionChange](MaxExecutionChanges, 172)
|
||||
}
|
||||
if b.BlobKzgCommitments == nil {
|
||||
b.BlobKzgCommitments = solid.NewStaticListSSZ[*KZGCommitment](MaxBlobsPerBlock, 48)
|
||||
b.BlobKzgCommitments = solid.NewStaticListSSZ[*KZGCommitment](MaxBlobsCommittmentsPerBlock, 48)
|
||||
}
|
||||
|
||||
size += b.ProposerSlashings.EncodingSizeSSZ()
|
||||
@ -161,7 +142,8 @@ func (b *BeaconBody) DecodeSSZ(buf []byte, version int) error {
|
||||
return fmt.Errorf("[BeaconBody] err: %s", ssz.ErrLowBufferSize)
|
||||
}
|
||||
|
||||
return ssz2.UnmarshalSSZ(buf, version, b.getSchema()...)
|
||||
err := ssz2.UnmarshalSSZ(buf, version, b.getSchema()...)
|
||||
return err
|
||||
}
|
||||
|
||||
func (b *BeaconBody) HashSSZ() ([32]byte, error) {
|
||||
|
@ -24,7 +24,7 @@ func TestBeaconBody(t *testing.T) {
|
||||
voluntaryExits := solid.NewStaticListSSZ[*SignedVoluntaryExit](MaxVoluntaryExits, 112)
|
||||
syncAggregate := &SyncAggregate{}
|
||||
executionChanges := solid.NewStaticListSSZ[*SignedBLSToExecutionChange](MaxExecutionChanges, 172)
|
||||
blobKzgCommitments := solid.NewStaticListSSZ[*KZGCommitment](MaxBlobsPerBlock, 48)
|
||||
blobKzgCommitments := solid.NewStaticListSSZ[*KZGCommitment](MaxBlobsCommittmentsPerBlock, 48)
|
||||
version := clparams.DenebVersion
|
||||
block := types.NewBlock(&types.Header{
|
||||
BaseFee: big.NewInt(1),
|
||||
@ -57,7 +57,7 @@ func TestBeaconBody(t *testing.T) {
|
||||
// Test HashSSZ
|
||||
root, err := body.HashSSZ()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, libcommon.HexToHash("17892e0144f88a0aa3e19f8b5f55129aed3fce23f1f32a08518ccd47b6ecbcf9"), libcommon.Hash(root))
|
||||
assert.Equal(t, libcommon.HexToHash("918d1ee08d700e422fcce6319cd7509b951d3ebfb1a05291aab9466b7e9826fc"), libcommon.Hash(root))
|
||||
|
||||
_, err = body.ExecutionPayload.RlpHeader()
|
||||
assert.NoError(t, err)
|
||||
|
@ -16,12 +16,11 @@ import (
|
||||
var beaconState []byte
|
||||
|
||||
func TestHashTreeRoot(t *testing.T) {
|
||||
t.Skip("Need to update due to data_gas_used")
|
||||
bs := state.New(&clparams.MainnetBeaconConfig)
|
||||
require.NoError(t, utils.DecodeSSZSnappy(bs, beaconState, int(clparams.DenebVersion)))
|
||||
root, err := bs.HashSSZ()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, common.Hash(root), common.HexToHash("0x7d085d9f2cce04eefb4c0aafad744fd2ce4ff962b2c3589fda53aab084171406"))
|
||||
require.Equal(t, common.Hash(root), common.HexToHash("0x9f684cf34c4ac8eb9056051f93498c552b59de6b0977c453ee099be68e58d90c"))
|
||||
}
|
||||
|
||||
func TestHashTreeRootTxs(t *testing.T) {
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
)
|
||||
|
||||
func TestGetters(t *testing.T) {
|
||||
t.Skip("Need to update due to data_gas_used")
|
||||
state := GetTestState()
|
||||
require.NotNil(t, state.BeaconConfig())
|
||||
valLength := state.ValidatorLength()
|
||||
@ -21,12 +20,12 @@ func TestGetters(t *testing.T) {
|
||||
|
||||
root, err := state.BlockRoot()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, common.Hash(root), common.HexToHash("0xa33e9a962fe153b2ed0174d30d5c657b9eaca2fba666df40e31ce8cf1a988961"))
|
||||
require.Equal(t, common.Hash(root), common.HexToHash("0x9f1620db18ee06b9cbdf1b7fa9658701063d2bd05d54b09780f6c0a074b4ce5f"))
|
||||
|
||||
copied, err := state.Copy()
|
||||
require.NoError(t, err)
|
||||
|
||||
root, err = copied.BlockRoot()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, common.Hash(root), common.HexToHash("0xa33e9a962fe153b2ed0174d30d5c657b9eaca2fba666df40e31ce8cf1a988961"))
|
||||
require.Equal(t, common.Hash(root), common.HexToHash("0x9f1620db18ee06b9cbdf1b7fa9658701063d2bd05d54b09780f6c0a074b4ce5f"))
|
||||
}
|
||||
|
@ -11,17 +11,16 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
//go:embed test_data/block_processing/deneb_state.ssz_snappy
|
||||
var denebState []byte
|
||||
//go:embed test_data/block_processing/capella_block.ssz_snappy
|
||||
var capellaBlock []byte
|
||||
|
||||
//go:embed test_data/block_processing/deneb_block.ssz_snappy
|
||||
var denebBlock []byte
|
||||
//go:embed test_data/block_processing/capella_state.ssz_snappy
|
||||
var capellaState []byte
|
||||
|
||||
func TestBlockProcessingDeneb(t *testing.T) {
|
||||
t.Skip("Need to update due to data_gas_used")
|
||||
func TestBlockProcessing(t *testing.T) {
|
||||
state := state.New(&clparams.MainnetBeaconConfig)
|
||||
require.NoError(t, utils.DecodeSSZSnappy(state, denebState, int(clparams.DenebVersion)))
|
||||
require.NoError(t, utils.DecodeSSZSnappy(state, capellaState, int(clparams.CapellaVersion)))
|
||||
block := &cltypes.SignedBeaconBlock{}
|
||||
require.NoError(t, utils.DecodeSSZSnappy(block, denebBlock, int(clparams.DenebVersion)))
|
||||
require.NoError(t, utils.DecodeSSZSnappy(block, capellaBlock, int(clparams.CapellaVersion)))
|
||||
require.NoError(t, TransitionState(state, block, true)) // All checks already made in transition state
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -15,12 +15,11 @@ import (
|
||||
var beaconState []byte
|
||||
|
||||
func TestEncodeDecode(t *testing.T) {
|
||||
t.Skip("Need to update due to data_gas_used")
|
||||
bs := state.New(&clparams.MainnetBeaconConfig)
|
||||
require.NoError(t, utils.DecodeSSZSnappy(bs, beaconState, int(clparams.DenebVersion)))
|
||||
require.NoError(t, utils.DecodeSSZSnappy(bs, beaconState, int(clparams.CapellaVersion)))
|
||||
root, err := bs.HashSSZ()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, common.Hash(root), common.HexToHash("0x7d085d9f2cce04eefb4c0aafad744fd2ce4ff962b2c3589fda53aab084171406"))
|
||||
require.Equal(t, common.Hash(root), common.HexToHash("0x36eb1bb5b4616f9d5046b2a719a8c4217f3dc40c1b7dff7abcc55c47f142a78b"))
|
||||
d, err := bs.EncodeSSZ(nil)
|
||||
require.NoError(t, err)
|
||||
dec, _ := utils.DecompressSnappy(beaconState)
|
||||
|
BIN
cl/ssz/testdata/serialized.ssz_snappy
vendored
BIN
cl/ssz/testdata/serialized.ssz_snappy
vendored
Binary file not shown.
Loading…
Reference in New Issue
Block a user