Skip to content

Commit

Permalink
Fix caplin API RPC issues (#13530)
Browse files Browse the repository at this point in the history
1. In the query http://localhost:3500/eth/v1/config/spec some integers
were not quoted.

2. When sync committees are returned, the fields have to be called
"pubkeys" and "aggregate_pubkey", not "committee" and
"aggregate_public_key".

3. When validators are returned, the public key field has to be called
"pubkey", not "public_key".

Specs for 2:
https://github.com/ethereum/annotated-spec/blob/master/altair/beacon-chain.md#synccommittee

Specs for 3:
https://github.com/ethereum/annotated-spec/blob/master/phase0/beacon-chain.md#validator

@Giulio2002
  • Loading branch information
errge authored Jan 27, 2025
1 parent 43ec1cf commit f4fc23f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cl/beacon/handler/test_data/light_client_bootstrap_1.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cl/beacon/handler/test_data/light_client_update_1.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions cl/clparams/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,10 +579,10 @@ type BeaconChainConfig struct {
// Constants for the Electra fork.
UnsetDepositRequestsStartIndex uint64 `yaml:"UNSET_DEPOSIT_REQUESTS_START_INDEX" spec:"true" json:"UNSET_DEPOSIT_REQUESTS_START_INDEX,string"` // UnsetDepositRequestsStartIndex defines the start index for unset deposit requests.
FullExitRequestAmount uint64 `yaml:"FULL_EXIT_REQUEST_AMOUNT" spec:"true" json:"FULL_EXIT_REQUEST_AMOUNT,string"` // FullExitRequestAmount defines the amount for a full exit request.
CompoundingWithdrawalPrefix byte `yaml:"COMPOUNDING_WITHDRAWAL_PREFIX" spec:"true" json:"COMPOUNDING_WITHDRAWAL_PREFIX"` // CompoundingWithdrawalPrefix is the prefix for compounding withdrawals.
DepositRequestType byte `yaml:"DEPOSIT_REQUEST_TYPE" spec:"true" json:"DEPOSIT_REQUEST_TYPE"` // DepositRequestType is the type for deposit requests.
WithdrawalRequestType byte `yaml:"WITHDRAWAL_REQUEST_TYPE" spec:"true" json:"WITHDRAWAL_REQUEST_TYPE"` // WithdrawalRequestType is the type for withdrawal requests.
ConsolidationRequestType byte `yaml:"CONSOLIDATION_REQUEST_TYPE" spec:"true" json:"CONSOLIDATION_REQUEST_TYPE"` // ConsolidationRequestType is the type for consolidation requests.
CompoundingWithdrawalPrefix byte `yaml:"COMPOUNDING_WITHDRAWAL_PREFIX" spec:"true" json:"COMPOUNDING_WITHDRAWAL_PREFIX,string"` // CompoundingWithdrawalPrefix is the prefix for compounding withdrawals.
DepositRequestType byte `yaml:"DEPOSIT_REQUEST_TYPE" spec:"true" json:"DEPOSIT_REQUEST_TYPE,string"` // DepositRequestType is the type for deposit requests.
WithdrawalRequestType byte `yaml:"WITHDRAWAL_REQUEST_TYPE" spec:"true" json:"WITHDRAWAL_REQUEST_TYPE,string"` // WithdrawalRequestType is the type for withdrawal requests.
ConsolidationRequestType byte `yaml:"CONSOLIDATION_REQUEST_TYPE" spec:"true" json:"CONSOLIDATION_REQUEST_TYPE,string"` // ConsolidationRequestType is the type for consolidation requests.

}

Expand Down
8 changes: 4 additions & 4 deletions cl/cltypes/solid/sync_committee.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ func (s *SyncCommittee) Static() bool {

func (s *SyncCommittee) MarshalJSON() ([]byte, error) {
return json.Marshal(struct {
Committee []libcommon.Bytes48 `json:"committee"`
AggregatePublicKey libcommon.Bytes48 `json:"aggregate_public_key"`
Committee []libcommon.Bytes48 `json:"pubkeys"`
AggregatePublicKey libcommon.Bytes48 `json:"aggregate_pubkey"`
}{
Committee: s.GetCommittee(),
AggregatePublicKey: s.AggregatePublicKey(),
Expand All @@ -122,8 +122,8 @@ func (s *SyncCommittee) MarshalJSON() ([]byte, error) {
func (s *SyncCommittee) UnmarshalJSON(input []byte) error {
var err error
var tmp struct {
Committee []libcommon.Bytes48 `json:"committee"`
AggregatePublicKey libcommon.Bytes48 `json:"aggregate_public_key"`
Committee []libcommon.Bytes48 `json:"pubkeys"`
AggregatePublicKey libcommon.Bytes48 `json:"aggregate_pubkey"`
}
if err = json.Unmarshal(input, &tmp); err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions cl/cltypes/solid/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func (v Validator) IsSlashable(epoch uint64) bool {

func (v Validator) MarshalJSON() ([]byte, error) {
return json.Marshal(struct {
PublicKey common.Bytes48 `json:"public_key"`
PublicKey common.Bytes48 `json:"pubkey"`
WithdrawalCredentials common.Hash `json:"withdrawal_credentials"`
EffectiveBalance uint64 `json:"effective_balance,string"`
Slashed bool `json:"slashed"`
Expand All @@ -269,7 +269,7 @@ func (v Validator) MarshalJSON() ([]byte, error) {
func (v *Validator) UnmarshalJSON(input []byte) error {
var err error
var tmp struct {
PublicKey common.Bytes48 `json:"public_key"`
PublicKey common.Bytes48 `json:"pubkey"`
WithdrawalCredentials common.Hash `json:"withdrawal_credentials"`
EffectiveBalance uint64 `json:"effective_balance,string"`
Slashed bool `json:"slashed"`
Expand Down

0 comments on commit f4fc23f

Please sign in to comment.