Align to spec v1.0.0 (#7469)

* Update eth1data params to double

* Update spec tests tags and state field for fssz gen

* Update more spec test sha tags

* Update slashing params

* Update slashing precompute to use config instead of hardcoded 3

* Update slashing test values due to config changes

* Update configs for slashedless test

* Go mod tidy

* Add toledo config (#7743)

* Update genesis delay to one week (#7782)

* Add Pyrmont config (#7797)

* Add Pyrmont config

* Fix config

* Update genesis time to the correct value

* Remove TestExecuteStateTransition_FullBlock

* Add back missing comments

* Update spectests to v1.0.0

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
This commit is contained in:
terence tsao
2020-11-12 17:00:05 -08:00
committed by GitHub
parent 18be4a4e3e
commit 5fdb916b4f
17 changed files with 1497 additions and 964 deletions

View File

@@ -222,8 +222,8 @@ filegroup(
visibility = ["//visibility:public"],
)
""",
sha256 = "6b3498001de98c477aa2c256beffc20a85ce1b12b8e0f8e88502a5c3a18c01de",
url = "https://github.com/ethereum/eth2.0-spec-tests/releases/download/v1.0.0-rc.0/general.tar.gz",
sha256 = "ef5396e4b13995da9776eeb5ae346a2de90970c28da3c4f0dcaa4ab9f0ad1f93",
url = "https://github.com/ethereum/eth2.0-spec-tests/releases/download/v1.0.0/general.tar.gz",
)
http_archive(
@@ -238,8 +238,8 @@ filegroup(
visibility = ["//visibility:public"],
)
""",
sha256 = "72c2f561db879ddcdf729fef93d10e0f9162b4cf3a697c513ef8935b93f6165a",
url = "https://github.com/ethereum/eth2.0-spec-tests/releases/download/v0.12.3/minimal.tar.gz",
sha256 = "170551b441e7d54b73248372ad9ce8cb6c148810b5f1364637117a63f4f1c085",
url = "https://github.com/ethereum/eth2.0-spec-tests/releases/download/v1.0.0/minimal.tar.gz",
)
http_archive(
@@ -254,8 +254,8 @@ filegroup(
visibility = ["//visibility:public"],
)
""",
sha256 = "63eca02503692a0b6a2d7b70118e0dd62dff094153a3a542af6dbea721841b0d",
url = "https://github.com/ethereum/eth2.0-spec-tests/releases/download/v0.12.3/mainnet.tar.gz",
sha256 = "b541a9979b4703fa5ee5d2182b0b5313c38efc54ae7eaec2eef793230a52ec83",
url = "https://github.com/ethereum/eth2.0-spec-tests/releases/download/v1.0.0/mainnet.tar.gz",
)
http_archive(

View File

@@ -196,9 +196,9 @@ func TestProcessSlashings_SlashedLess(t *testing.T) {
Balances: []uint64{params.BeaconConfig().MaxEffectiveBalance, params.BeaconConfig().MaxEffectiveBalance},
Slashings: []uint64{0, 1e9},
},
// penalty = validator balance / increment * (3*total_penalties) / total_balance * increment
// 3000000000 = (32 * 1e9) / (1 * 1e9) * (3*1e9) / (32*1e9) * (1 * 1e9)
want: uint64(29000000000), // 32 * 1e9 - 3000000000
// penalty = validator balance / increment * (2*total_penalties) / total_balance * increment
// 1000000000 = (32 * 1e9) / (1 * 1e9) * (1*1e9) / (32*1e9) * (1 * 1e9)
want: uint64(31000000000), // 32 * 1e9 - 1000000000
},
{
state: &pb.BeaconState{
@@ -212,9 +212,9 @@ func TestProcessSlashings_SlashedLess(t *testing.T) {
Balances: []uint64{params.BeaconConfig().MaxEffectiveBalance, params.BeaconConfig().MaxEffectiveBalance},
Slashings: []uint64{0, 1e9},
},
// penalty = validator balance / increment * (3*total_penalties) / total_balance * increment
// 1000000000 = (32 * 1e9) / (1 * 1e9) * (3*1e9) / (64*1e9) * (1 * 1e9)
want: uint64(31000000000), // 32 * 1e9 - 1000000000
// penalty = validator balance / increment * (2*total_penalties) / total_balance * increment
// 500000000 = (32 * 1e9) / (1 * 1e9) * (1*1e9) / (32*1e9) * (1 * 1e9)
want: uint64(32000000000), // 32 * 1e9 - 500000000
},
{
state: &pb.BeaconState{
@@ -229,8 +229,8 @@ func TestProcessSlashings_SlashedLess(t *testing.T) {
Slashings: []uint64{0, 2 * 1e9},
},
// penalty = validator balance / increment * (3*total_penalties) / total_balance * increment
// 3000000000 = (32 * 1e9) / (1 * 1e9) * (3*2e9) / (64*1e9) * (1 * 1e9)
want: uint64(29000000000), // 32 * 1e9 - 3000000000
// 1000000000 = (32 * 1e9) / (1 * 1e9) * (1*2e9) / (64*1e9) * (1 * 1e9)
want: uint64(31000000000), // 32 * 1e9 - 1000000000
},
{
state: &pb.BeaconState{
@@ -243,8 +243,8 @@ func TestProcessSlashings_SlashedLess(t *testing.T) {
Slashings: []uint64{0, 1e9},
},
// penalty = validator balance / increment * (3*total_penalties) / total_balance * increment
// 3000000000 = (32 * 1e9 - 1*1e9) / (1 * 1e9) * (3*1e9) / (31*1e9) * (1 * 1e9)
want: uint64(28000000000), // 31 * 1e9 - 3000000000
// 2000000000 = (32 * 1e9 - 1*1e9) / (1 * 1e9) * (2*1e9) / (31*1e9) * (1 * 1e9)
want: uint64(30000000000), // 32 * 1e9 - 2000000000
},
}

View File

@@ -58,9 +58,9 @@ func TestProcessSlashingsPrecompute_SlashedLess(t *testing.T) {
Balances: []uint64{params.BeaconConfig().MaxEffectiveBalance, params.BeaconConfig().MaxEffectiveBalance},
Slashings: []uint64{0, 1e9},
},
// penalty = validator balance / increment * (3*total_penalties) / total_balance * increment
// 3000000000 = (32 * 1e9) / (1 * 1e9) * (3*1e9) / (32*1e9) * (1 * 1e9)
want: uint64(29000000000), // 32 * 1e9 - 3000000000
// penalty = validator balance / increment * (2*total_penalties) / total_balance * increment
// 1000000000 = (32 * 1e9) / (1 * 1e9) * (1*1e9) / (32*1e9) * (1 * 1e9)
want: uint64(31000000000), // 32 * 1e9 - 1000000000
},
{
state: &pb.BeaconState{
@@ -74,9 +74,9 @@ func TestProcessSlashingsPrecompute_SlashedLess(t *testing.T) {
Balances: []uint64{params.BeaconConfig().MaxEffectiveBalance, params.BeaconConfig().MaxEffectiveBalance, params.BeaconConfig().MaxEffectiveBalance},
Slashings: []uint64{0, 1e9},
},
// penalty = validator balance / increment * (3*total_penalties) / total_balance * increment
// 1000000000 = (32 * 1e9) / (1 * 1e9) * (3*1e9) / (64*1e9) * (1 * 1e9)
want: uint64(31000000000), // 32 * 1e9 - 1000000000
// penalty = validator balance / increment * (2*total_penalties) / total_balance * increment
// 500000000 = (32 * 1e9) / (1 * 1e9) * (1*1e9) / (32*1e9) * (1 * 1e9)
want: uint64(32000000000), // 32 * 1e9 - 500000000
},
{
state: &pb.BeaconState{
@@ -91,8 +91,8 @@ func TestProcessSlashingsPrecompute_SlashedLess(t *testing.T) {
Slashings: []uint64{0, 2 * 1e9},
},
// penalty = validator balance / increment * (3*total_penalties) / total_balance * increment
// 3000000000 = (32 * 1e9) / (1 * 1e9) * (3*2e9) / (64*1e9) * (1 * 1e9)
want: uint64(29000000000), // 32 * 1e9 - 3000000000
// 1000000000 = (32 * 1e9) / (1 * 1e9) * (1*2e9) / (64*1e9) * (1 * 1e9)
want: uint64(31000000000), // 32 * 1e9 - 1000000000
},
{
state: &pb.BeaconState{
@@ -105,8 +105,8 @@ func TestProcessSlashingsPrecompute_SlashedLess(t *testing.T) {
Slashings: []uint64{0, 1e9},
},
// penalty = validator balance / increment * (3*total_penalties) / total_balance * increment
// 3000000000 = (32 * 1e9 - 1*1e9) / (1 * 1e9) * (3*1e9) / (31*1e9) * (1 * 1e9)
want: uint64(28000000000), // 31 * 1e9 - 3000000000
// 2000000000 = (32 * 1e9 - 1*1e9) / (1 * 1e9) * (2*1e9) / (31*1e9) * (1 * 1e9)
want: uint64(30000000000), // 32 * 1e9 - 2000000000
},
}

View File

@@ -16,19 +16,6 @@ import (
var runAmount = 25
func TestExecuteStateTransition_FullBlock(t *testing.T) {
benchutil.SetBenchmarkConfig()
beaconState, err := benchutil.PreGenState1Epoch()
require.NoError(t, err)
block, err := benchutil.PreGenFullBlock()
require.NoError(t, err)
oldSlot := beaconState.Slot()
beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, block)
require.NoError(t, err, "Failed to process block, benchmarks will fail")
require.NotEqual(t, oldSlot, beaconState.Slot(), "Expected slots to be different")
}
func BenchmarkExecuteStateTransition_FullBlock(b *testing.B) {
benchutil.SetBenchmarkConfig()
beaconState, err := benchutil.PreGenState1Epoch()

1
go.mod
View File

@@ -126,6 +126,7 @@ require (
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20201026171402-d4b8fe4fd877
google.golang.org/grpc v1.33.1
google.golang.org/protobuf v1.25.0
gopkg.in/confluentinc/confluent-kafka-go.v1 v1.4.2
gopkg.in/d4l3k/messagediff.v1 v1.2.1
gopkg.in/yaml.v2 v2.3.0

View File

@@ -6,357 +6,6 @@ import (
v1alpha1 "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
)
// MarshalSSZ ssz marshals the Status object
func (s *Status) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(s)
}
// MarshalSSZTo ssz marshals the Status object to a target array
func (s *Status) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
// Field (0) 'ForkDigest'
if len(s.ForkDigest) != 4 {
err = ssz.ErrBytesLength
return
}
dst = append(dst, s.ForkDigest...)
// Field (1) 'FinalizedRoot'
if len(s.FinalizedRoot) != 32 {
err = ssz.ErrBytesLength
return
}
dst = append(dst, s.FinalizedRoot...)
// Field (2) 'FinalizedEpoch'
dst = ssz.MarshalUint64(dst, s.FinalizedEpoch)
// Field (3) 'HeadRoot'
if len(s.HeadRoot) != 32 {
err = ssz.ErrBytesLength
return
}
dst = append(dst, s.HeadRoot...)
// Field (4) 'HeadSlot'
dst = ssz.MarshalUint64(dst, s.HeadSlot)
return
}
// UnmarshalSSZ ssz unmarshals the Status object
func (s *Status) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size != 84 {
return ssz.ErrSize
}
// Field (0) 'ForkDigest'
if cap(s.ForkDigest) == 0 {
s.ForkDigest = make([]byte, 0, len(buf[0:4]))
}
s.ForkDigest = append(s.ForkDigest, buf[0:4]...)
// Field (1) 'FinalizedRoot'
if cap(s.FinalizedRoot) == 0 {
s.FinalizedRoot = make([]byte, 0, len(buf[4:36]))
}
s.FinalizedRoot = append(s.FinalizedRoot, buf[4:36]...)
// Field (2) 'FinalizedEpoch'
s.FinalizedEpoch = ssz.UnmarshallUint64(buf[36:44])
// Field (3) 'HeadRoot'
if cap(s.HeadRoot) == 0 {
s.HeadRoot = make([]byte, 0, len(buf[44:76]))
}
s.HeadRoot = append(s.HeadRoot, buf[44:76]...)
// Field (4) 'HeadSlot'
s.HeadSlot = ssz.UnmarshallUint64(buf[76:84])
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the Status object
func (s *Status) SizeSSZ() (size int) {
size = 84
return
}
// HashTreeRoot ssz hashes the Status object
func (s *Status) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(s)
}
// HashTreeRootWith ssz hashes the Status object with a hasher
func (s *Status) HashTreeRootWith(hh *ssz.Hasher) (err error) {
indx := hh.Index()
// Field (0) 'ForkDigest'
if len(s.ForkDigest) != 4 {
err = ssz.ErrBytesLength
return
}
hh.PutBytes(s.ForkDigest)
// Field (1) 'FinalizedRoot'
if len(s.FinalizedRoot) != 32 {
err = ssz.ErrBytesLength
return
}
hh.PutBytes(s.FinalizedRoot)
// Field (2) 'FinalizedEpoch'
hh.PutUint64(s.FinalizedEpoch)
// Field (3) 'HeadRoot'
if len(s.HeadRoot) != 32 {
err = ssz.ErrBytesLength
return
}
hh.PutBytes(s.HeadRoot)
// Field (4) 'HeadSlot'
hh.PutUint64(s.HeadSlot)
hh.Merkleize(indx)
return
}
// MarshalSSZ ssz marshals the BeaconBlocksByRangeRequest object
func (b *BeaconBlocksByRangeRequest) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(b)
}
// MarshalSSZTo ssz marshals the BeaconBlocksByRangeRequest object to a target array
func (b *BeaconBlocksByRangeRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
// Field (0) 'StartSlot'
dst = ssz.MarshalUint64(dst, b.StartSlot)
// Field (1) 'Count'
dst = ssz.MarshalUint64(dst, b.Count)
// Field (2) 'Step'
dst = ssz.MarshalUint64(dst, b.Step)
return
}
// UnmarshalSSZ ssz unmarshals the BeaconBlocksByRangeRequest object
func (b *BeaconBlocksByRangeRequest) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size != 24 {
return ssz.ErrSize
}
// Field (0) 'StartSlot'
b.StartSlot = ssz.UnmarshallUint64(buf[0:8])
// Field (1) 'Count'
b.Count = ssz.UnmarshallUint64(buf[8:16])
// Field (2) 'Step'
b.Step = ssz.UnmarshallUint64(buf[16:24])
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlocksByRangeRequest object
func (b *BeaconBlocksByRangeRequest) SizeSSZ() (size int) {
size = 24
return
}
// HashTreeRoot ssz hashes the BeaconBlocksByRangeRequest object
func (b *BeaconBlocksByRangeRequest) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(b)
}
// HashTreeRootWith ssz hashes the BeaconBlocksByRangeRequest object with a hasher
func (b *BeaconBlocksByRangeRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) {
indx := hh.Index()
// Field (0) 'StartSlot'
hh.PutUint64(b.StartSlot)
// Field (1) 'Count'
hh.PutUint64(b.Count)
// Field (2) 'Step'
hh.PutUint64(b.Step)
hh.Merkleize(indx)
return
}
// MarshalSSZ ssz marshals the ENRForkID object
func (e *ENRForkID) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(e)
}
// MarshalSSZTo ssz marshals the ENRForkID object to a target array
func (e *ENRForkID) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
// Field (0) 'CurrentForkDigest'
if len(e.CurrentForkDigest) != 4 {
err = ssz.ErrBytesLength
return
}
dst = append(dst, e.CurrentForkDigest...)
// Field (1) 'NextForkVersion'
if len(e.NextForkVersion) != 4 {
err = ssz.ErrBytesLength
return
}
dst = append(dst, e.NextForkVersion...)
// Field (2) 'NextForkEpoch'
dst = ssz.MarshalUint64(dst, e.NextForkEpoch)
return
}
// UnmarshalSSZ ssz unmarshals the ENRForkID object
func (e *ENRForkID) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size != 16 {
return ssz.ErrSize
}
// Field (0) 'CurrentForkDigest'
if cap(e.CurrentForkDigest) == 0 {
e.CurrentForkDigest = make([]byte, 0, len(buf[0:4]))
}
e.CurrentForkDigest = append(e.CurrentForkDigest, buf[0:4]...)
// Field (1) 'NextForkVersion'
if cap(e.NextForkVersion) == 0 {
e.NextForkVersion = make([]byte, 0, len(buf[4:8]))
}
e.NextForkVersion = append(e.NextForkVersion, buf[4:8]...)
// Field (2) 'NextForkEpoch'
e.NextForkEpoch = ssz.UnmarshallUint64(buf[8:16])
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the ENRForkID object
func (e *ENRForkID) SizeSSZ() (size int) {
size = 16
return
}
// HashTreeRoot ssz hashes the ENRForkID object
func (e *ENRForkID) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(e)
}
// HashTreeRootWith ssz hashes the ENRForkID object with a hasher
func (e *ENRForkID) HashTreeRootWith(hh *ssz.Hasher) (err error) {
indx := hh.Index()
// Field (0) 'CurrentForkDigest'
if len(e.CurrentForkDigest) != 4 {
err = ssz.ErrBytesLength
return
}
hh.PutBytes(e.CurrentForkDigest)
// Field (1) 'NextForkVersion'
if len(e.NextForkVersion) != 4 {
err = ssz.ErrBytesLength
return
}
hh.PutBytes(e.NextForkVersion)
// Field (2) 'NextForkEpoch'
hh.PutUint64(e.NextForkEpoch)
hh.Merkleize(indx)
return
}
// MarshalSSZ ssz marshals the MetaData object
func (m *MetaData) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(m)
}
// MarshalSSZTo ssz marshals the MetaData object to a target array
func (m *MetaData) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
// Field (0) 'SeqNumber'
dst = ssz.MarshalUint64(dst, m.SeqNumber)
// Field (1) 'Attnets'
if len(m.Attnets) != 8 {
err = ssz.ErrBytesLength
return
}
dst = append(dst, m.Attnets...)
return
}
// UnmarshalSSZ ssz unmarshals the MetaData object
func (m *MetaData) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size != 16 {
return ssz.ErrSize
}
// Field (0) 'SeqNumber'
m.SeqNumber = ssz.UnmarshallUint64(buf[0:8])
// Field (1) 'Attnets'
if cap(m.Attnets) == 0 {
m.Attnets = make([]byte, 0, len(buf[8:16]))
}
m.Attnets = append(m.Attnets, buf[8:16]...)
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the MetaData object
func (m *MetaData) SizeSSZ() (size int) {
size = 16
return
}
// HashTreeRoot ssz hashes the MetaData object
func (m *MetaData) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(m)
}
// HashTreeRootWith ssz hashes the MetaData object with a hasher
func (m *MetaData) HashTreeRootWith(hh *ssz.Hasher) (err error) {
indx := hh.Index()
// Field (0) 'SeqNumber'
hh.PutUint64(m.SeqNumber)
// Field (1) 'Attnets'
if len(m.Attnets) != 8 {
err = ssz.ErrBytesLength
return
}
hh.PutBytes(m.Attnets)
hh.Merkleize(indx)
return
}
// MarshalSSZ ssz marshals the BeaconState object
func (b *BeaconState) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(b)
@@ -530,7 +179,7 @@ func (b *BeaconState) MarshalSSZTo(buf []byte) (dst []byte, err error) {
}
// Field (9) 'Eth1DataVotes'
if len(b.Eth1DataVotes) > 1024 {
if len(b.Eth1DataVotes) > 2048 {
err = ssz.ErrListTooBig
return
}
@@ -761,7 +410,7 @@ func (b *BeaconState) UnmarshalSSZ(buf []byte) error {
// Field (9) 'Eth1DataVotes'
{
buf = tail[o9:o11]
num, err := ssz.DivideInt2(len(buf), 72, 1024)
num, err := ssz.DivideInt2(len(buf), 72, 2048)
if err != nil {
return err
}
@@ -977,7 +626,7 @@ func (b *BeaconState) HashTreeRootWith(hh *ssz.Hasher) (err error) {
{
subIndx := hh.Index()
num := uint64(len(b.Eth1DataVotes))
if num > 1024 {
if num > 2048 {
err = ssz.ErrIncorrectListSize
return
}
@@ -986,7 +635,7 @@ func (b *BeaconState) HashTreeRootWith(hh *ssz.Hasher) (err error) {
return
}
}
hh.MerkleizeWithMixin(subIndx, num, 1024)
hh.MerkleizeWithMixin(subIndx, num, 2048)
}
// Field (10) 'Eth1DepositIndex'
@@ -1608,3 +1257,354 @@ func (f *ForkData) HashTreeRootWith(hh *ssz.Hasher) (err error) {
hh.Merkleize(indx)
return
}
// MarshalSSZ ssz marshals the Status object
func (s *Status) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(s)
}
// MarshalSSZTo ssz marshals the Status object to a target array
func (s *Status) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
// Field (0) 'ForkDigest'
if len(s.ForkDigest) != 4 {
err = ssz.ErrBytesLength
return
}
dst = append(dst, s.ForkDigest...)
// Field (1) 'FinalizedRoot'
if len(s.FinalizedRoot) != 32 {
err = ssz.ErrBytesLength
return
}
dst = append(dst, s.FinalizedRoot...)
// Field (2) 'FinalizedEpoch'
dst = ssz.MarshalUint64(dst, s.FinalizedEpoch)
// Field (3) 'HeadRoot'
if len(s.HeadRoot) != 32 {
err = ssz.ErrBytesLength
return
}
dst = append(dst, s.HeadRoot...)
// Field (4) 'HeadSlot'
dst = ssz.MarshalUint64(dst, s.HeadSlot)
return
}
// UnmarshalSSZ ssz unmarshals the Status object
func (s *Status) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size != 84 {
return ssz.ErrSize
}
// Field (0) 'ForkDigest'
if cap(s.ForkDigest) == 0 {
s.ForkDigest = make([]byte, 0, len(buf[0:4]))
}
s.ForkDigest = append(s.ForkDigest, buf[0:4]...)
// Field (1) 'FinalizedRoot'
if cap(s.FinalizedRoot) == 0 {
s.FinalizedRoot = make([]byte, 0, len(buf[4:36]))
}
s.FinalizedRoot = append(s.FinalizedRoot, buf[4:36]...)
// Field (2) 'FinalizedEpoch'
s.FinalizedEpoch = ssz.UnmarshallUint64(buf[36:44])
// Field (3) 'HeadRoot'
if cap(s.HeadRoot) == 0 {
s.HeadRoot = make([]byte, 0, len(buf[44:76]))
}
s.HeadRoot = append(s.HeadRoot, buf[44:76]...)
// Field (4) 'HeadSlot'
s.HeadSlot = ssz.UnmarshallUint64(buf[76:84])
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the Status object
func (s *Status) SizeSSZ() (size int) {
size = 84
return
}
// HashTreeRoot ssz hashes the Status object
func (s *Status) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(s)
}
// HashTreeRootWith ssz hashes the Status object with a hasher
func (s *Status) HashTreeRootWith(hh *ssz.Hasher) (err error) {
indx := hh.Index()
// Field (0) 'ForkDigest'
if len(s.ForkDigest) != 4 {
err = ssz.ErrBytesLength
return
}
hh.PutBytes(s.ForkDigest)
// Field (1) 'FinalizedRoot'
if len(s.FinalizedRoot) != 32 {
err = ssz.ErrBytesLength
return
}
hh.PutBytes(s.FinalizedRoot)
// Field (2) 'FinalizedEpoch'
hh.PutUint64(s.FinalizedEpoch)
// Field (3) 'HeadRoot'
if len(s.HeadRoot) != 32 {
err = ssz.ErrBytesLength
return
}
hh.PutBytes(s.HeadRoot)
// Field (4) 'HeadSlot'
hh.PutUint64(s.HeadSlot)
hh.Merkleize(indx)
return
}
// MarshalSSZ ssz marshals the BeaconBlocksByRangeRequest object
func (b *BeaconBlocksByRangeRequest) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(b)
}
// MarshalSSZTo ssz marshals the BeaconBlocksByRangeRequest object to a target array
func (b *BeaconBlocksByRangeRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
// Field (0) 'StartSlot'
dst = ssz.MarshalUint64(dst, b.StartSlot)
// Field (1) 'Count'
dst = ssz.MarshalUint64(dst, b.Count)
// Field (2) 'Step'
dst = ssz.MarshalUint64(dst, b.Step)
return
}
// UnmarshalSSZ ssz unmarshals the BeaconBlocksByRangeRequest object
func (b *BeaconBlocksByRangeRequest) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size != 24 {
return ssz.ErrSize
}
// Field (0) 'StartSlot'
b.StartSlot = ssz.UnmarshallUint64(buf[0:8])
// Field (1) 'Count'
b.Count = ssz.UnmarshallUint64(buf[8:16])
// Field (2) 'Step'
b.Step = ssz.UnmarshallUint64(buf[16:24])
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlocksByRangeRequest object
func (b *BeaconBlocksByRangeRequest) SizeSSZ() (size int) {
size = 24
return
}
// HashTreeRoot ssz hashes the BeaconBlocksByRangeRequest object
func (b *BeaconBlocksByRangeRequest) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(b)
}
// HashTreeRootWith ssz hashes the BeaconBlocksByRangeRequest object with a hasher
func (b *BeaconBlocksByRangeRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) {
indx := hh.Index()
// Field (0) 'StartSlot'
hh.PutUint64(b.StartSlot)
// Field (1) 'Count'
hh.PutUint64(b.Count)
// Field (2) 'Step'
hh.PutUint64(b.Step)
hh.Merkleize(indx)
return
}
// MarshalSSZ ssz marshals the ENRForkID object
func (e *ENRForkID) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(e)
}
// MarshalSSZTo ssz marshals the ENRForkID object to a target array
func (e *ENRForkID) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
// Field (0) 'CurrentForkDigest'
if len(e.CurrentForkDigest) != 4 {
err = ssz.ErrBytesLength
return
}
dst = append(dst, e.CurrentForkDigest...)
// Field (1) 'NextForkVersion'
if len(e.NextForkVersion) != 4 {
err = ssz.ErrBytesLength
return
}
dst = append(dst, e.NextForkVersion...)
// Field (2) 'NextForkEpoch'
dst = ssz.MarshalUint64(dst, e.NextForkEpoch)
return
}
// UnmarshalSSZ ssz unmarshals the ENRForkID object
func (e *ENRForkID) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size != 16 {
return ssz.ErrSize
}
// Field (0) 'CurrentForkDigest'
if cap(e.CurrentForkDigest) == 0 {
e.CurrentForkDigest = make([]byte, 0, len(buf[0:4]))
}
e.CurrentForkDigest = append(e.CurrentForkDigest, buf[0:4]...)
// Field (1) 'NextForkVersion'
if cap(e.NextForkVersion) == 0 {
e.NextForkVersion = make([]byte, 0, len(buf[4:8]))
}
e.NextForkVersion = append(e.NextForkVersion, buf[4:8]...)
// Field (2) 'NextForkEpoch'
e.NextForkEpoch = ssz.UnmarshallUint64(buf[8:16])
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the ENRForkID object
func (e *ENRForkID) SizeSSZ() (size int) {
size = 16
return
}
// HashTreeRoot ssz hashes the ENRForkID object
func (e *ENRForkID) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(e)
}
// HashTreeRootWith ssz hashes the ENRForkID object with a hasher
func (e *ENRForkID) HashTreeRootWith(hh *ssz.Hasher) (err error) {
indx := hh.Index()
// Field (0) 'CurrentForkDigest'
if len(e.CurrentForkDigest) != 4 {
err = ssz.ErrBytesLength
return
}
hh.PutBytes(e.CurrentForkDigest)
// Field (1) 'NextForkVersion'
if len(e.NextForkVersion) != 4 {
err = ssz.ErrBytesLength
return
}
hh.PutBytes(e.NextForkVersion)
// Field (2) 'NextForkEpoch'
hh.PutUint64(e.NextForkEpoch)
hh.Merkleize(indx)
return
}
// MarshalSSZ ssz marshals the MetaData object
func (m *MetaData) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(m)
}
// MarshalSSZTo ssz marshals the MetaData object to a target array
func (m *MetaData) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
// Field (0) 'SeqNumber'
dst = ssz.MarshalUint64(dst, m.SeqNumber)
// Field (1) 'Attnets'
if len(m.Attnets) != 8 {
err = ssz.ErrBytesLength
return
}
dst = append(dst, m.Attnets...)
return
}
// UnmarshalSSZ ssz unmarshals the MetaData object
func (m *MetaData) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size != 16 {
return ssz.ErrSize
}
// Field (0) 'SeqNumber'
m.SeqNumber = ssz.UnmarshallUint64(buf[0:8])
// Field (1) 'Attnets'
if cap(m.Attnets) == 0 {
m.Attnets = make([]byte, 0, len(buf[8:16]))
}
m.Attnets = append(m.Attnets, buf[8:16]...)
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the MetaData object
func (m *MetaData) SizeSSZ() (size int) {
size = 16
return
}
// HashTreeRoot ssz hashes the MetaData object
func (m *MetaData) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(m)
}
// HashTreeRootWith ssz hashes the MetaData object with a hasher
func (m *MetaData) HashTreeRootWith(hh *ssz.Hasher) (err error) {
indx := hh.Index()
// Field (0) 'SeqNumber'
hh.PutUint64(m.SeqNumber)
// Field (1) 'Attnets'
if len(m.Attnets) != 8 {
err = ssz.ErrBytesLength
return
}
hh.PutBytes(m.Attnets)
hh.Merkleize(indx)
return
}

File diff suppressed because it is too large Load Diff

View File

@@ -10,7 +10,7 @@ These rules allow for variable substitution for hardcoded tag values like ssz-si
mainnet = {
"block_roots.size": "8192,32", # SLOTS_PER_HISTORICAL_ROOT, [32]byte
"state_roots.size": "8192,32", # SLOTS_PER_HISTORICAL_ROOT, [32]byte
"eth1_data_votes.size": "1024", # SLOTS_PER_ETH1_VOTING_PERIOD
"eth1_data_votes.size": "2048", # SLOTS_PER_ETH1_VOTING_PERIOD
"randao_mixes.size": "65536,32", # EPOCHS_PER_HISTORICAL_VECTOR, [32]byte
"previous_epoch_attestations.max": "4096", # MAX_ATTESTATIONS * SLOTS_PER_EPOCH
"current_epoch_attestations.max": "4096", # MAX_ATTESTATIONS * SLOTS_PER_EPOCH

View File

@@ -37,6 +37,8 @@ type Flags struct {
MedallaTestnet bool // MedallaTestnet defines the flag through which we can enable the node to run on the Medalla testnet.
SpadinaTestnet bool // SpadinaTestnet defines the flag through which we can enable the node to run on the Spadina testnet.
ZinkenTestnet bool // ZinkenTestnet defines the flag through which we can enable the node to run on the Zinken testnet.
ToledoTestnet bool // ToledoTestnet defines the flag through which we can enable the node to run on the Toledo testnet.
PyrmontTestnet bool // PyrmontTestnet defines the flag through which we can enable the node to run on the Pyrmont testnet.
// Feature related flags.
WriteSSZStateTransitions bool // WriteSSZStateTransitions to tmp directory.
@@ -133,6 +135,16 @@ func configureTestnet(ctx *cli.Context, cfg *Flags) {
params.UseZinkenConfig()
params.UseZinkenNetworkConfig()
cfg.ZinkenTestnet = true
} else if ctx.Bool(ToledoTestnet.Name) {
log.Warn("Running on Toledo Testnet")
params.UseToledoConfig()
params.UseToledoNetworkConfig()
cfg.ToledoTestnet = true
} else if ctx.Bool(PyrmontTestnet.Name) {
log.Warn("Running on Pyrmont Testnet")
params.UsePyrmontConfig()
params.UsePyrmontNetworkConfig()
cfg.PyrmontTestnet = true
} else {
log.Warn("Running on ETH2 Mainnet")
params.UseMainnetConfig()

View File

@@ -20,6 +20,16 @@ var (
Name: "medalla",
Usage: "This defines the flag through which we can run on the Medalla Multiclient Testnet",
}
// ToledoTestnet flag for the multiclient eth2 testnet.
ToledoTestnet = &cli.BoolFlag{
Name: "toledo",
Usage: "This defines the flag through which we can run on the Toledo Multiclient Testnet",
}
// PyrmontTestnet flag for the multiclient eth2 testnet.
PyrmontTestnet = &cli.BoolFlag{
Name: "pyrmont",
Usage: "This defines the flag through which we can run on the Pyrmont Multiclient Testnet",
}
// SpadinaTestnet flag for the multiclient eth2 testnet.
SpadinaTestnet = &cli.BoolFlag{
Name: "spadina",
@@ -113,8 +123,10 @@ var ValidatorFlags = append(deprecatedFlags, []cli.Flag{
AltonaTestnet,
OnyxTestnet,
MedallaTestnet,
ToledoTestnet,
SpadinaTestnet,
ZinkenTestnet,
PyrmontTestnet,
Mainnet,
disableAccountsV2,
enableBlst,
@@ -126,8 +138,10 @@ var SlasherFlags = append(deprecatedFlags, []cli.Flag{
AltonaTestnet,
OnyxTestnet,
MedallaTestnet,
ToledoTestnet,
SpadinaTestnet,
ZinkenTestnet,
PyrmontTestnet,
Mainnet,
}...)
@@ -147,8 +161,10 @@ var BeaconChainFlags = append(deprecatedFlags, []cli.Flag{
AltonaTestnet,
OnyxTestnet,
MedallaTestnet,
ToledoTestnet,
SpadinaTestnet,
ZinkenTestnet,
PyrmontTestnet,
Mainnet,
enableBlst,
disableEth1DataMajorityVote,

View File

@@ -14,7 +14,9 @@ go_library(
"testnet_e2e_config.go",
"testnet_medalla_config.go",
"testnet_onyx_config.go",
"testnet_pyrmont_config.go",
"testnet_spadina_config.go",
"testnet_toledo_config.go",
"testnet_zinken_config.go",
"testutils.go",
],

View File

@@ -43,7 +43,7 @@ var mainnetBeaconConfig = &BeaconChainConfig{
FarFutureEpoch: 1<<64 - 1,
BaseRewardsPerEpoch: 4,
DepositContractTreeDepth: 32,
GenesisDelay: 172800, // 2 days
GenesisDelay: 604800, // 1 week.
// Misc constant.
TargetCommitteeSize: 128,
@@ -75,12 +75,12 @@ var mainnetBeaconConfig = &BeaconChainConfig{
SlotsPerEpoch: 32,
MinSeedLookahead: 1,
MaxSeedLookahead: 4,
EpochsPerEth1VotingPeriod: 32,
EpochsPerEth1VotingPeriod: 64,
SlotsPerHistoricalRoot: 8192,
MinValidatorWithdrawabilityDelay: 256,
ShardCommitteePeriod: 256,
MinEpochsToInactivityPenalty: 4,
Eth1FollowDistance: 1024,
Eth1FollowDistance: 2048,
SafeSlotsToUpdateJustified: 8,
SecondsPerETH1Block: 13,
@@ -94,9 +94,9 @@ var mainnetBeaconConfig = &BeaconChainConfig{
BaseRewardFactor: 64,
WhistleBlowerRewardQuotient: 512,
ProposerRewardQuotient: 8,
InactivityPenaltyQuotient: 1 << 24,
MinSlashingPenaltyQuotient: 32,
ProportionalSlashingMultiplier: 3,
InactivityPenaltyQuotient: 67108864,
MinSlashingPenaltyQuotient: 128,
ProportionalSlashingMultiplier: 1,
// Max operations per block constants.
MaxProposerSlashings: 16,

View File

@@ -56,9 +56,9 @@ func MinimalSpecConfig() *BeaconChainConfig {
minimalConfig.BaseRewardFactor = 64
minimalConfig.WhistleBlowerRewardQuotient = 512
minimalConfig.ProposerRewardQuotient = 8
minimalConfig.InactivityPenaltyQuotient = 1 << 24
minimalConfig.MinSlashingPenaltyQuotient = 32
minimalConfig.ProportionalSlashingMultiplier = 3
minimalConfig.InactivityPenaltyQuotient = 33554432
minimalConfig.MinSlashingPenaltyQuotient = 64
minimalConfig.ProportionalSlashingMultiplier = 2
// Max operations per block
minimalConfig.MaxProposerSlashings = 16

View File

@@ -0,0 +1,32 @@
package params
// UsePyrmontNetworkConfig uses the Pyrmont specific
// network config.
func UsePyrmontNetworkConfig() {
cfg := BeaconNetworkConfig().Copy()
cfg.ContractDeploymentBlock = 3713500
cfg.ChainID = 5
cfg.NetworkID = 5
cfg.DepositContractAddress = "0x2c539a95d2a3f9b10681D9c0dD7cCE37D40c7B79"
cfg.BootstrapNodes = []string{
"enr:-Ku4QDuuQGbUpzWMW1IUZpvt3xUzZuEwm2CvHqWQ-EGGzWXPYNc-PZPIfm05R7W3YwEIGM2_2-Y3JHQuEiizbYlW-HoBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpD1pf1CAAAAAP__________gmlkgnY0gmlwhDQPSjiJc2VjcDI1NmsxoQM6yTQB6XGWYJbI7NZFBjp4Yb9AYKQPBhVrfUclQUobb4N1ZHCCIyg",
"enr:-Ku4QAOnRymufUy7UbyxheWFbV9WAtt7BlvoixBz8-Xstb0oBui0ERAiBcsY5xDbE2YxvT7u6gwZPju9V_ecAAJMddUBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpD1pf1CAAAAAP__________gmlkgnY0gmlwhDaa13aJc2VjcDI1NmsxoQKdNQJvnohpf0VO0ZYCAJxGjT0uwJoAHbAiBMujGjK0SoN1ZHCCIyg",
}
OverrideBeaconNetworkConfig(cfg)
}
// UsePyrmontConfig sets the main beacon chain
// config for Pyrmont.
func UsePyrmontConfig() {
beaconConfig = PyrmontConfig()
}
// PyrmontConfig defines the config for the
// Pyrmont testnet.
func PyrmontConfig() *BeaconChainConfig {
cfg := MainnetConfig().Copy()
cfg.MinGenesisTime = 1605700800
cfg.NetworkName = "pyrmont"
cfg.SecondsPerETH1Block = 14
return cfg
}

View File

@@ -0,0 +1,34 @@
package params
// UseToledoNetworkConfig uses the Toledo specific
// network config.
func UseToledoNetworkConfig() {
cfg := BeaconNetworkConfig().Copy()
cfg.ContractDeploymentBlock = 3702432
cfg.ChainID = 5
cfg.NetworkID = 5
cfg.DepositContractAddress = "0x47709dC7a8c18688a1f051761fc34ac253970bC0"
cfg.BootstrapNodes = []string{
// Prysm Bootnode 1
"enr:-Ku4QL5E378NT4-vqP6v1mZ7kHxiTHJvuBvQixQsuTTCffa0PJNWMBlG3Mduvsvd6T2YP1U3l5tBKO5H-9wyX2SCtPkBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpC4EvfsAHAe0P__________gmlkgnY0gmlwhDaetEeJc2VjcDI1NmsxoQKtGC2CAuba7goLLdle899M3esUmoWRvzi7GBVhq6ViCYN1ZHCCIyg",
}
OverrideBeaconNetworkConfig(cfg)
}
// UseToledoConfig sets the main beacon chain
// config for Toledo testnet.
func UseToledoConfig() {
beaconConfig = ToledoConfig()
}
// ToledoConfig defines the config for the
// Toledo testnet.
func ToledoConfig() *BeaconChainConfig {
cfg := MainnetConfig().Copy()
cfg.MinGenesisTime = 1605009600
cfg.GenesisDelay = 86400
cfg.GenesisForkVersion = []byte{0x00, 0x70, 0x1E, 0xD0}
cfg.NetworkName = "toledo"
cfg.SecondsPerETH1Block = 14
return cfg
}

View File

@@ -30,6 +30,8 @@ this command outputs a deposit data string which is required to become a validat
featureconfig.AltonaTestnet,
featureconfig.OnyxTestnet,
featureconfig.MedallaTestnet,
featureconfig.ToledoTestnet,
featureconfig.PyrmontTestnet,
featureconfig.SpadinaTestnet,
featureconfig.ZinkenTestnet,
cmd.AcceptTosFlag,
@@ -58,6 +60,8 @@ this command outputs a deposit data string which is required to become a validat
featureconfig.AltonaTestnet,
featureconfig.OnyxTestnet,
featureconfig.MedallaTestnet,
featureconfig.ToledoTestnet,
featureconfig.PyrmontTestnet,
featureconfig.SpadinaTestnet,
featureconfig.ZinkenTestnet,
cmd.AcceptTosFlag,
@@ -87,6 +91,8 @@ this command outputs a deposit data string which is required to become a validat
featureconfig.AltonaTestnet,
featureconfig.OnyxTestnet,
featureconfig.MedallaTestnet,
featureconfig.ToledoTestnet,
featureconfig.PyrmontTestnet,
featureconfig.SpadinaTestnet,
featureconfig.ZinkenTestnet,
cmd.AcceptTosFlag,
@@ -120,6 +126,8 @@ this command outputs a deposit data string which is required to become a validat
featureconfig.AltonaTestnet,
featureconfig.OnyxTestnet,
featureconfig.MedallaTestnet,
featureconfig.ToledoTestnet,
featureconfig.PyrmontTestnet,
featureconfig.SpadinaTestnet,
featureconfig.ZinkenTestnet,
cmd.AcceptTosFlag,
@@ -150,6 +158,8 @@ this command outputs a deposit data string which is required to become a validat
featureconfig.AltonaTestnet,
featureconfig.OnyxTestnet,
featureconfig.MedallaTestnet,
featureconfig.ToledoTestnet,
featureconfig.PyrmontTestnet,
featureconfig.SpadinaTestnet,
featureconfig.ZinkenTestnet,
cmd.AcceptTosFlag,
@@ -185,6 +195,8 @@ this command outputs a deposit data string which is required to become a validat
featureconfig.AltonaTestnet,
featureconfig.OnyxTestnet,
featureconfig.MedallaTestnet,
featureconfig.ToledoTestnet,
featureconfig.PyrmontTestnet,
featureconfig.SpadinaTestnet,
featureconfig.ZinkenTestnet,
cmd.AcceptTosFlag,

View File

@@ -31,6 +31,8 @@ var WalletCommands = &cli.Command{
featureconfig.AltonaTestnet,
featureconfig.OnyxTestnet,
featureconfig.MedallaTestnet,
featureconfig.ToledoTestnet,
featureconfig.PyrmontTestnet,
featureconfig.SpadinaTestnet,
featureconfig.ZinkenTestnet,
cmd.AcceptTosFlag,
@@ -61,6 +63,8 @@ var WalletCommands = &cli.Command{
featureconfig.AltonaTestnet,
featureconfig.OnyxTestnet,
featureconfig.MedallaTestnet,
featureconfig.ToledoTestnet,
featureconfig.PyrmontTestnet,
featureconfig.SpadinaTestnet,
featureconfig.ZinkenTestnet,
cmd.AcceptTosFlag,
@@ -92,6 +96,8 @@ var WalletCommands = &cli.Command{
featureconfig.AltonaTestnet,
featureconfig.OnyxTestnet,
featureconfig.MedallaTestnet,
featureconfig.ToledoTestnet,
featureconfig.PyrmontTestnet,
featureconfig.SpadinaTestnet,
featureconfig.ZinkenTestnet,
cmd.AcceptTosFlag,