Skip to content

Commit c71fc35

Browse files
authored
remove unnecessary fields from GetStateValidatorsResponse (#728)
Unmarshalling this structure takes ~4% of all CPU time, and we actually do not need most of the fields. Remove them from struct so that native json decoder will be faster
1 parent 2e6028d commit c71fc35

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

beaconclient/beacon_client_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,7 @@ func TestFetchValidators(t *testing.T) {
177177
Validator: ValidatorResponseValidatorData{
178178
Pubkey: testPubKey,
179179
},
180-
Index: 0,
181-
Balance: "0",
182-
Status: "",
180+
Index: 0,
183181
}
184182

185183
backend := newTestBackend(t, 3)

beaconclient/prod_beacon_instance.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -135,27 +135,27 @@ func (c *ProdBeaconInstance) SubscribeToPayloadAttributesEvents(payloadAttribute
135135
}
136136

137137
type GetStateValidatorsResponse struct {
138-
ExecutionOptimistic bool `json:"execution_optimistic"`
139-
Finalized bool `json:"finalized"`
140-
Data []ValidatorResponseEntry
138+
// ExecutionOptimistic bool `json:"execution_optimistic"`
139+
// Finalized bool `json:"finalized"`
140+
Data []ValidatorResponseEntry
141141
}
142142

143143
type ValidatorResponseEntry struct {
144-
Index uint64 `json:"index,string"` // Index of validator in validator registry.
145-
Balance string `json:"balance"` // Current validator balance in gwei.
146-
Status string `json:"status"`
144+
Index uint64 `json:"index,string"` // Index of validator in validator registry.
145+
// Balance string `json:"balance"` // Current validator balance in gwei.
146+
// Status string `json:"status"`
147147
Validator ValidatorResponseValidatorData `json:"validator"`
148148
}
149149

150150
type ValidatorResponseValidatorData struct {
151-
Pubkey string `json:"pubkey"`
152-
WithdrawalCredentials string `json:"withdrawal_credentials"`
153-
EffectiveBalance string `json:"effective_balance"`
154-
Slashed bool `json:"slashed"`
155-
ActivationEligibility uint64 `json:"activation_eligibility_epoch,string"`
156-
ActivationEpoch uint64 `json:"activation_epoch,string"`
157-
ExitEpoch uint64 `json:"exit_epoch,string"`
158-
WithdrawableEpoch uint64 `json:"withdrawable_epoch,string"`
151+
Pubkey string `json:"pubkey"`
152+
// WithdrawalCredentials string `json:"withdrawal_credentials"`
153+
// EffectiveBalance string `json:"effective_balance"`
154+
// Slashed bool `json:"slashed"`
155+
// ActivationEligibility uint64 `json:"activation_eligibility_epoch,string"`
156+
// ActivationEpoch uint64 `json:"activation_epoch,string"`
157+
// ExitEpoch uint64 `json:"exit_epoch,string"`
158+
// WithdrawableEpoch uint64 `json:"withdrawable_epoch,string"`
159159
}
160160

161161
// GetStateValidators loads all active and pending validators

0 commit comments

Comments
 (0)