Skip to content

Commit

Permalink
Merge pull request #167 from pk910/pk910/spec-1.5.0-alpha.7
Browse files Browse the repository at this point in the history
update electra specs to `v1.5.0-alpha.7`
  • Loading branch information
mcdee authored Oct 6, 2024
2 parents 393fff1 + f6f8068 commit 8fa702e
Show file tree
Hide file tree
Showing 21 changed files with 330 additions and 240 deletions.
2 changes: 1 addition & 1 deletion spec/electra/beaconstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type BeaconState struct {
EarliestExitEpoch phase0.Epoch
ConsolidationBalanceToConsume phase0.Gwei
EarliestConsolidationEpoch phase0.Epoch
PendingBalanceDeposits []*PendingBalanceDeposit `ssz-max:"134217728"`
PendingDeposits []*PendingDeposit `ssz-max:"134217728"`
PendingPartialWithdrawals []*PendingPartialWithdrawal `ssz-max:"134217728"`
PendingConsolidations []*PendingConsolidation `ssz-max:"262144"`
}
Expand Down
14 changes: 7 additions & 7 deletions spec/electra/beaconstate_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type beaconStateJSON struct {
EarliestExitEpoch phase0.Epoch `json:"earliest_exit_epoch"`
ConsolidationBalanceToConsume phase0.Gwei `json:"consolidation_balance_to_consume"`
EarliestConsolidationEpoch phase0.Epoch `json:"earliest_consolidation_epoch"`
PendingBalanceDeposits []*PendingBalanceDeposit `json:"pending_balance_deposits"`
PendingDeposits []*PendingDeposit `json:"pending_deposits"`
PendingPartialWithdrawals []*PendingPartialWithdrawal `json:"pending_partial_withdrawals"`
PendingConsolidations []*PendingConsolidation `json:"pending_consolidations"`
}
Expand Down Expand Up @@ -132,7 +132,7 @@ func (b *BeaconState) MarshalJSON() ([]byte, error) {
EarliestExitEpoch: b.EarliestExitEpoch,
ConsolidationBalanceToConsume: b.ConsolidationBalanceToConsume,
EarliestConsolidationEpoch: b.EarliestConsolidationEpoch,
PendingBalanceDeposits: b.PendingBalanceDeposits,
PendingDeposits: b.PendingDeposits,
PendingPartialWithdrawals: b.PendingPartialWithdrawals,
PendingConsolidations: b.PendingConsolidations,
})
Expand Down Expand Up @@ -321,12 +321,12 @@ func (b *BeaconState) UnmarshalJSON(input []byte) error {
return errors.Wrap(err, "earliest_consolidation_epoch")
}

if err := json.Unmarshal(raw["pending_balance_deposits"], &b.PendingBalanceDeposits); err != nil {
return errors.Wrap(err, "pending_balance_deposits")
if err := json.Unmarshal(raw["pending_deposits"], &b.PendingDeposits); err != nil {
return errors.Wrap(err, "pending_deposits")
}
for i := range b.PendingBalanceDeposits {
if b.PendingBalanceDeposits[i] == nil {
return fmt.Errorf("pending balance deposits entry %d missing", i)
for i := range b.PendingDeposits {
if b.PendingDeposits[i] == nil {
return fmt.Errorf("pending deposits entry %d missing", i)
}
}

Expand Down
24 changes: 12 additions & 12 deletions spec/electra/beaconstate_ssz.go

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

4 changes: 2 additions & 2 deletions spec/electra/beaconstate_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type beaconStateYAML struct {
EarliestExitEpoch phase0.Epoch `yaml:"earliest_exit_epoch"`
ConsolidationBalanceToConsume phase0.Gwei `yaml:"consolidation_balance_to_consume"`
EarliestConsolidationEpoch phase0.Epoch `yaml:"earliest_consolidation_epoch"`
PendingBalanceDeposits []*PendingBalanceDeposit `yaml:"pending_balance_deposits"`
PendingDeposits []*PendingDeposit `yaml:"pending_deposits"`
PendingPartialWithdrawals []*PendingPartialWithdrawal `yaml:"pending_partial_withdrawals"`
PendingConsolidations []*PendingConsolidation `yaml:"pending_consolidations"`
}
Expand Down Expand Up @@ -104,7 +104,7 @@ func (b *BeaconState) MarshalYAML() ([]byte, error) {
EarliestExitEpoch: b.EarliestExitEpoch,
ConsolidationBalanceToConsume: b.ConsolidationBalanceToConsume,
EarliestConsolidationEpoch: b.EarliestConsolidationEpoch,
PendingBalanceDeposits: b.PendingBalanceDeposits,
PendingDeposits: b.PendingDeposits,
PendingPartialWithdrawals: b.PendingPartialWithdrawals,
PendingConsolidations: b.PendingConsolidations,
}, yaml.Flow(true))
Expand Down
4 changes: 2 additions & 2 deletions spec/electra/consensusspec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ func TestConsensusSpec(t *testing.T) {
s: &phase0.PendingAttestation{},
},
{
name: "PendingBalanceDeposit",
s: &electra.PendingBalanceDeposit{},
name: "PendingDeposit",
s: &electra.PendingDeposit{},
},
{
name: "PendingConsolidation",
Expand Down
2 changes: 1 addition & 1 deletion spec/electra/consolidationrequest_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (e *ConsolidationRequest) MarshalYAML() ([]byte, error) {
func (e *ConsolidationRequest) UnmarshalYAML(input []byte) error {
// This is very inefficient, but YAML is only used for spec tests so we do this
// rather than maintain a custom YAML unmarshaller.
var unmarshaled consolidationRequestYAML
var unmarshaled consolidationRequestJSON
if err := yaml.Unmarshal(input, &unmarshaled); err != nil {
return errors.Wrap(err, "failed to unmarshal YAML")
}
Expand Down
6 changes: 3 additions & 3 deletions spec/electra/executionrequests.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (

// ExecutionRequests represents an execution layer payload.
type ExecutionRequests struct {
DepositRequests []*DepositRequest `ssz-max:"8192"`
WithdrawalRequests []*WithdrawalRequest `ssz-max:"16"`
ConsolidationRequests []*ConsolidationRequest `ssz-max:"1"`
Deposits []*DepositRequest `ssz-max:"8192"`
Withdrawals []*WithdrawalRequest `ssz-max:"16"`
Consolidations []*ConsolidationRequest `ssz-max:"1"`
}

// String returns a string version of the structure.
Expand Down
40 changes: 20 additions & 20 deletions spec/electra/executionrequests_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ import (

// executionRequestsJSON is the spec representation of the struct.
type executionRequestsJSON struct {
DepositRequests []*DepositRequest `json:"deposit_requests"`
WithdrawalRequests []*WithdrawalRequest `json:"withdrawal_requests"`
ConsolidationRequests []*ConsolidationRequest `json:"consolidation_requests"`
Deposits []*DepositRequest `json:"deposits"`
Withdrawals []*WithdrawalRequest `json:"withdrawals"`
Consolidations []*ConsolidationRequest `json:"consolidations"`
}

// MarshalJSON implements json.Marshaler.
func (e *ExecutionRequests) MarshalJSON() ([]byte, error) {
return json.Marshal(&executionRequestsJSON{
DepositRequests: e.DepositRequests,
WithdrawalRequests: e.WithdrawalRequests,
ConsolidationRequests: e.ConsolidationRequests,
Deposits: e.Deposits,
Withdrawals: e.Withdrawals,
Consolidations: e.Consolidations,
})
}

Expand All @@ -44,29 +44,29 @@ func (e *ExecutionRequests) UnmarshalJSON(input []byte) error {
return err
}

if err := json.Unmarshal(raw["deposit_requests"], &e.DepositRequests); err != nil {
return errors.Wrap(err, "deposit_requests")
if err := json.Unmarshal(raw["deposits"], &e.Deposits); err != nil {
return errors.Wrap(err, "deposits")
}
for i := range e.DepositRequests {
if e.DepositRequests[i] == nil {
return fmt.Errorf("deposit receipts entry %d missing", i)
for i := range e.Deposits {
if e.Deposits[i] == nil {
return fmt.Errorf("deposits entry %d missing", i)
}
}

if err := json.Unmarshal(raw["withdrawal_requests"], &e.WithdrawalRequests); err != nil {
return errors.Wrap(err, "withdrawal_requests")
if err := json.Unmarshal(raw["withdrawals"], &e.Withdrawals); err != nil {
return errors.Wrap(err, "withdrawals")
}
for i := range e.WithdrawalRequests {
if e.WithdrawalRequests[i] == nil {
return fmt.Errorf("withdraw requests entry %d missing", i)
for i := range e.Withdrawals {
if e.Withdrawals[i] == nil {
return fmt.Errorf("withdrawals entry %d missing", i)
}
}

if err := json.Unmarshal(raw["consolidation_requests"], &e.ConsolidationRequests); err != nil {
return errors.Wrap(err, "consolidation_requests")
if err := json.Unmarshal(raw["consolidations"], &e.Consolidations); err != nil {
return errors.Wrap(err, "consolidations")
}
for i := range e.ConsolidationRequests {
if e.ConsolidationRequests[i] == nil {
for i := range e.Consolidations {
if e.Consolidations[i] == nil {
return fmt.Errorf("consolidation requests entry %d missing", i)
}
}
Expand Down
Loading

0 comments on commit 8fa702e

Please sign in to comment.