Skip to content

Commit

Permalink
update electra specs to v1.5.0-alpha.6
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Sep 21, 2024
1 parent 07eba3e commit ae1d6ab
Show file tree
Hide file tree
Showing 25 changed files with 578 additions and 1,825 deletions.
6 changes: 3 additions & 3 deletions spec/electra/beaconblockbody.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ package electra
import (
"fmt"

"github.com/attestantio/go-eth2-client/spec/deneb"

"github.com/attestantio/go-eth2-client/spec/altair"
"github.com/attestantio/go-eth2-client/spec/capella"
"github.com/attestantio/go-eth2-client/spec/deneb"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/goccy/go-yaml"
)
Expand All @@ -35,9 +34,10 @@ type BeaconBlockBody struct {
Deposits []*phase0.Deposit `ssz-max:"16"`
VoluntaryExits []*phase0.SignedVoluntaryExit `ssz-max:"16"`
SyncAggregate *altair.SyncAggregate
ExecutionPayload *ExecutionPayload
ExecutionPayload *deneb.ExecutionPayload
BLSToExecutionChanges []*capella.SignedBLSToExecutionChange `ssz-max:"16"`
BlobKZGCommitments []deneb.KZGCommitment `ssz-max:"4096" ssz-size:"?,48"`
ExecutionRequests *ExecutionRequests
}

// String returns a string version of the structure.
Expand Down
9 changes: 8 additions & 1 deletion spec/electra/beaconblockbody_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/attestantio/go-eth2-client/codecs"
"github.com/attestantio/go-eth2-client/spec/altair"
"github.com/attestantio/go-eth2-client/spec/capella"
"github.com/attestantio/go-eth2-client/spec/deneb"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
)
Expand All @@ -37,9 +38,10 @@ type beaconBlockBodyJSON struct {
Deposits []*phase0.Deposit `json:"deposits"`
VoluntaryExits []*phase0.SignedVoluntaryExit `json:"voluntary_exits"`
SyncAggregate *altair.SyncAggregate `json:"sync_aggregate"`
ExecutionPayload *ExecutionPayload `json:"execution_payload"`
ExecutionPayload *deneb.ExecutionPayload `json:"execution_payload"`
BLSToExecutionChanges []*capella.SignedBLSToExecutionChange `json:"bls_to_execution_changes"`
BlobKZGCommitments []string `json:"blob_kzg_commitments"`
ExecutionRequests *ExecutionRequests `json:"execution_requests"`
}

// MarshalJSON implements json.Marshaler.
Expand All @@ -62,6 +64,7 @@ func (b *BeaconBlockBody) MarshalJSON() ([]byte, error) {
ExecutionPayload: b.ExecutionPayload,
BLSToExecutionChanges: b.BLSToExecutionChanges,
BlobKZGCommitments: blobKZGCommitments,
ExecutionRequests: b.ExecutionRequests,
})
}

Expand Down Expand Up @@ -164,5 +167,9 @@ func (b *BeaconBlockBody) UnmarshalJSON(input []byte) error {
return errors.Wrap(err, "blob_kzg_commitments")
}

if err := json.Unmarshal(raw["execution_requests"], &b.ExecutionRequests); err != nil {
return errors.Wrap(err, "execution_requests")
}

return nil
}
45 changes: 36 additions & 9 deletions spec/electra/beaconblockbody_ssz.go

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

5 changes: 4 additions & 1 deletion spec/electra/beaconblockbody_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

"github.com/attestantio/go-eth2-client/spec/altair"
"github.com/attestantio/go-eth2-client/spec/capella"
"github.com/attestantio/go-eth2-client/spec/deneb"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/goccy/go-yaml"
"github.com/pkg/errors"
Expand All @@ -36,9 +37,10 @@ type beaconBlockBodyYAML struct {
Deposits []*phase0.Deposit `yaml:"deposits"`
VoluntaryExits []*phase0.SignedVoluntaryExit `yaml:"voluntary_exits"`
SyncAggregate *altair.SyncAggregate `yaml:"sync_aggregate"`
ExecutionPayload *ExecutionPayload `yaml:"execution_payload"`
ExecutionPayload *deneb.ExecutionPayload `yaml:"execution_payload"`
BLSToExecutionChanges []*capella.SignedBLSToExecutionChange `yaml:"bls_to_execution_changes"`
BlobKZGCommitments []string `yaml:"blob_kzg_commitments"`
ExecutionRequests *ExecutionRequests `yaml:"execution_requests"`
}

// MarshalYAML implements yaml.Marshaler.
Expand All @@ -61,6 +63,7 @@ func (b *BeaconBlockBody) MarshalYAML() ([]byte, error) {
ExecutionPayload: b.ExecutionPayload,
BLSToExecutionChanges: b.BLSToExecutionChanges,
BlobKZGCommitments: blobKZGCommitments,
ExecutionRequests: b.ExecutionRequests,
}, yaml.Flow(true))
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion spec/electra/beaconstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

"github.com/attestantio/go-eth2-client/spec/altair"
"github.com/attestantio/go-eth2-client/spec/capella"
"github.com/attestantio/go-eth2-client/spec/deneb"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/goccy/go-yaml"
bitfield "github.com/prysmaticlabs/go-bitfield"
Expand Down Expand Up @@ -49,7 +50,7 @@ type BeaconState struct {
InactivityScores []uint64 `ssz-max:"1099511627776"`
CurrentSyncCommittee *altair.SyncCommittee
NextSyncCommittee *altair.SyncCommittee
LatestExecutionPayloadHeader *ExecutionPayloadHeader
LatestExecutionPayloadHeader *deneb.ExecutionPayloadHeader
NextWithdrawalIndex capella.WithdrawalIndex
NextWithdrawalValidatorIndex phase0.ValidatorIndex
HistoricalSummaries []*capella.HistoricalSummary `ssz-max:"16777216"`
Expand Down
59 changes: 30 additions & 29 deletions spec/electra/beaconstate_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/attestantio/go-eth2-client/codecs"
"github.com/attestantio/go-eth2-client/spec/altair"
"github.com/attestantio/go-eth2-client/spec/capella"
"github.com/attestantio/go-eth2-client/spec/deneb"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
)
Expand All @@ -39,34 +40,34 @@ type beaconStateJSON struct {
HistoricalRoots []phase0.Root `json:"historical_roots"`
ETH1Data *phase0.ETH1Data `json:"eth1_data"`
//nolint:staticcheck
ETH1DataVotes []*phase0.ETH1Data `json:"eth1_data_votes,allowempty"`
ETH1DepositIndex string `json:"eth1_deposit_index"`
Validators []*phase0.Validator `json:"validators"`
Balances []string `json:"balances"`
RANDAOMixes []string `json:"randao_mixes"`
Slashings []string `json:"slashings"`
PreviousEpochParticipation []string `json:"previous_epoch_participation"`
CurrentEpochParticipation []string `json:"current_epoch_participation"`
JustificationBits string `json:"justification_bits"`
PreviousJustifiedCheckpoint *phase0.Checkpoint `json:"previous_justified_checkpoint"`
CurrentJustifiedCheckpoint *phase0.Checkpoint `json:"current_justified_checkpoint"`
FinalizedCheckpoint *phase0.Checkpoint `json:"finalized_checkpoint"`
InactivityScores []string `json:"inactivity_scores"`
CurrentSyncCommittee *altair.SyncCommittee `json:"current_sync_committee"`
NextSyncCommittee *altair.SyncCommittee `json:"next_sync_committee"`
LatestExecutionPayloadHeader *ExecutionPayloadHeader `json:"latest_execution_payload_header"`
NextWithdrawalIndex string `json:"next_withdrawal_index"`
NextWithdrawalValidatorIndex string `json:"next_withdrawal_validator_index"`
HistoricalSummaries []*capella.HistoricalSummary `json:"historical_summaries"`
DepositRequestsStartIndex string `json:"deposit_requests_start_index"`
DepositBalanceToConsume phase0.Gwei `json:"deposit_balance_to_consume"`
ExitBalanceToConsume phase0.Gwei `json:"exit_balance_to_consume"`
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"`
PendingPartialWithdrawals []*PendingPartialWithdrawal `json:"pending_partial_withdrawals"`
PendingConsolidations []*PendingConsolidation `json:"pending_consolidations"`
ETH1DataVotes []*phase0.ETH1Data `json:"eth1_data_votes,allowempty"`
ETH1DepositIndex string `json:"eth1_deposit_index"`
Validators []*phase0.Validator `json:"validators"`
Balances []string `json:"balances"`
RANDAOMixes []string `json:"randao_mixes"`
Slashings []string `json:"slashings"`
PreviousEpochParticipation []string `json:"previous_epoch_participation"`
CurrentEpochParticipation []string `json:"current_epoch_participation"`
JustificationBits string `json:"justification_bits"`
PreviousJustifiedCheckpoint *phase0.Checkpoint `json:"previous_justified_checkpoint"`
CurrentJustifiedCheckpoint *phase0.Checkpoint `json:"current_justified_checkpoint"`
FinalizedCheckpoint *phase0.Checkpoint `json:"finalized_checkpoint"`
InactivityScores []string `json:"inactivity_scores"`
CurrentSyncCommittee *altair.SyncCommittee `json:"current_sync_committee"`
NextSyncCommittee *altair.SyncCommittee `json:"next_sync_committee"`
LatestExecutionPayloadHeader *deneb.ExecutionPayloadHeader `json:"latest_execution_payload_header"`
NextWithdrawalIndex string `json:"next_withdrawal_index"`
NextWithdrawalValidatorIndex string `json:"next_withdrawal_validator_index"`
HistoricalSummaries []*capella.HistoricalSummary `json:"historical_summaries"`
DepositRequestsStartIndex string `json:"deposit_requests_start_index"`
DepositBalanceToConsume phase0.Gwei `json:"deposit_balance_to_consume"`
ExitBalanceToConsume phase0.Gwei `json:"exit_balance_to_consume"`
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"`
PendingPartialWithdrawals []*PendingPartialWithdrawal `json:"pending_partial_withdrawals"`
PendingConsolidations []*PendingConsolidation `json:"pending_consolidations"`
}

// MarshalJSON implements json.Marshaler.
Expand Down Expand Up @@ -273,7 +274,7 @@ func (b *BeaconState) UnmarshalJSON(input []byte) error {
return errors.Wrap(err, "next_sync_committee")
}

b.LatestExecutionPayloadHeader = &ExecutionPayloadHeader{}
b.LatestExecutionPayloadHeader = &deneb.ExecutionPayloadHeader{}
if err := b.LatestExecutionPayloadHeader.UnmarshalJSON(raw["latest_execution_payload_header"]); err != nil {
return errors.Wrap(err, "latest_execution_payload_header")
}
Expand Down
7 changes: 4 additions & 3 deletions spec/electra/beaconstate_ssz.go

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

Loading

0 comments on commit ae1d6ab

Please sign in to comment.