Skip to content

Commit

Permalink
update types for specs v1.5.0-alpha.7 (eip6110)
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Oct 4, 2024
1 parent 393fff1 commit 4aacd50
Show file tree
Hide file tree
Showing 15 changed files with 265 additions and 175 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
2 changes: 1 addition & 1 deletion spec/electra/consensusspec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func TestConsensusSpec(t *testing.T) {
},
{
name: "PendingBalanceDeposit",
s: &electra.PendingBalanceDeposit{},
s: &electra.PendingDeposit{},
},
{
name: "PendingConsolidation",
Expand Down
6 changes: 3 additions & 3 deletions spec/electra/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ package electra

//nolint:revive
// Need to `go install github.com/ferranbt/fastssz/sszgen@latest` for this to work.
//go:generate rm -f aggregateandproof_ssz.go attestation_ssz.go attesterslashing_ssz.go beaconblockbody_ssz.go beaconblock_ssz.go beaconstate_ssz.go consolidation_ssz.go consolidationrequest_ssz.go depositrequest_ssz.go withdrawalrequest_ssz.go executionrequests_ssz.go pendingbalancedeposit_ssz.go pendingconsolidation_ssz.go pendingpartialwithdrawal_ssz.go signedaggregateandproof_ssz.go signedbeaconblock_ssz.go
//go:generate sszgen --suffix=ssz --path . --include ../phase0,../altair,../bellatrix,../capella,../deneb --objs AggregateAndProof,Attestation,AttesterSlashing,BeaconBlockBody,BeaconBlock,BeaconState,Consolidation,ConsolidationRequest,DepositRequest,WithdrawalRequest,ExecutionRequests,PendingBalanceDeposit,PendingConsolidation,PendingPartialWithdrawal,SignedAggregateAndProof,SignedBeaconBlock
//go:generate goimports -w aggregateandproof_ssz.go attestation_ssz.go attesterslashing_ssz.go beaconblockbody_ssz.go beaconblock_ssz.go beaconstate_ssz.go consolidation_ssz.go consolidationrequest_ssz.go depositrequest_ssz.go withdrawalrequest_ssz.go executionrequests_ssz.go pendingbalancedeposit_ssz.go pendingconsolidation_ssz.go pendingpartialwithdrawal_ssz.go signedaggregateandproof_ssz.go signedbeaconblock_ssz.go
//go:generate rm -f aggregateandproof_ssz.go attestation_ssz.go attesterslashing_ssz.go beaconblockbody_ssz.go beaconblock_ssz.go beaconstate_ssz.go consolidation_ssz.go consolidationrequest_ssz.go depositrequest_ssz.go withdrawalrequest_ssz.go executionrequests_ssz.go pendingconsolidation_ssz.go pendingdeposit_ssz.go pendingpartialwithdrawal_ssz.go signedaggregateandproof_ssz.go signedbeaconblock_ssz.go
//go:generate sszgen --suffix=ssz --path . --include ../phase0,../altair,../bellatrix,../capella,../deneb --objs AggregateAndProof,Attestation,AttesterSlashing,BeaconBlockBody,BeaconBlock,BeaconState,Consolidation,ConsolidationRequest,DepositRequest,WithdrawalRequest,ExecutionRequests,PendingConsolidation,PendingDeposit,PendingPartialWithdrawal,SignedAggregateAndProof,SignedBeaconBlock
//go:generate goimports -w aggregateandproof_ssz.go attestation_ssz.go attesterslashing_ssz.go beaconblockbody_ssz.go beaconblock_ssz.go beaconstate_ssz.go consolidation_ssz.go consolidationrequest_ssz.go depositrequest_ssz.go withdrawalrequest_ssz.go executionrequests_ssz.go pendingconsolidation_ssz.go pendingdeposit_ssz.go pendingpartialwithdrawal_ssz.go signedaggregateandproof_ssz.go signedbeaconblock_ssz.go
53 changes: 0 additions & 53 deletions spec/electra/pendingbalancedeposit_json.go

This file was deleted.

74 changes: 0 additions & 74 deletions spec/electra/pendingbalancedeposit_ssz.go

This file was deleted.

2 changes: 1 addition & 1 deletion spec/electra/pendingconsolidation_ssz.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ import (
"github.com/goccy/go-yaml"
)

// PendingBalanceDeposit represents a pending balance deposit.
type PendingBalanceDeposit struct {
Index phase0.ValidatorIndex
Amount phase0.Gwei
// PendingDeposit represents a pending balance deposit.
type PendingDeposit struct {
Pubkey phase0.BLSPubKey `ssz-size:"48"`
WithdrawalCredentials []byte `ssz-size:"32"`
Amount phase0.Gwei
Signature phase0.BLSSignature `ssz-size:"96"`
Slot phase0.Slot
}

// String returns a string version of the structure.
func (p *PendingBalanceDeposit) String() string {
func (p *PendingDeposit) String() string {
data, err := yaml.Marshal(p)
if err != nil {
return fmt.Sprintf("ERR: %v", err)
Expand Down
Loading

0 comments on commit 4aacd50

Please sign in to comment.