mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 11:57:18 +00:00
fix validator client (#11755)
* fix validator client (cherry picked from commit deb138959a2ffcb89cd2e3eb8304477526f4a168) * Use signed changes in middleware block Co-authored-by: Potuz <potuz@prysmaticlabs.com>
This commit is contained in:
parent
fa01ee5eba
commit
fb981d29e8
@ -498,7 +498,7 @@ type BlindedBeaconBlockBodyCapellaJson struct {
|
||||
VoluntaryExits []*SignedVoluntaryExitJson `json:"voluntary_exits"`
|
||||
SyncAggregate *SyncAggregateJson `json:"sync_aggregate"`
|
||||
ExecutionPayloadHeader *ExecutionPayloadHeaderCapellaJson `json:"execution_payload_header"`
|
||||
BLSToExecutionChanges []*BLSToExecutionChangeJson `json:"bls_to_execution_changes"`
|
||||
BLSToExecutionChanges []*SignedBLSToExecutionChangeJson `json:"bls_to_execution_changes"`
|
||||
}
|
||||
|
||||
type ExecutionPayloadJson struct {
|
||||
@ -623,6 +623,11 @@ type AttestationDataJson struct {
|
||||
Target *CheckpointJson `json:"target"`
|
||||
}
|
||||
|
||||
type SignedBLSToExecutionChangeJson struct {
|
||||
Message *BLSToExecutionChangeJson `json:"message"`
|
||||
Signature string `json:"signature" hex:"true"`
|
||||
}
|
||||
|
||||
type BLSToExecutionChangeJson struct {
|
||||
ValidatorIndex string `json:"validator_index"`
|
||||
FromBLSPubkey string `json:"from_bls_pubkey" hex:"true"`
|
||||
|
@ -15,15 +15,19 @@ func jsonifyTransactions(transactions [][]byte) []string {
|
||||
return jsonTransactions
|
||||
}
|
||||
|
||||
func jsonifyBlsToExecutionChanges(blsToExecutionChanges []*ethpb.SignedBLSToExecutionChange) []*apimiddleware.BLSToExecutionChangeJson {
|
||||
jsonBlsToExecutionChanges := make([]*apimiddleware.BLSToExecutionChangeJson, len(blsToExecutionChanges))
|
||||
func jsonifyBlsToExecutionChanges(blsToExecutionChanges []*ethpb.SignedBLSToExecutionChange) []*apimiddleware.SignedBLSToExecutionChangeJson {
|
||||
jsonBlsToExecutionChanges := make([]*apimiddleware.SignedBLSToExecutionChangeJson, len(blsToExecutionChanges))
|
||||
for index, signedBlsToExecutionChange := range blsToExecutionChanges {
|
||||
blsToExecutionChangeJson := &apimiddleware.BLSToExecutionChangeJson{
|
||||
ValidatorIndex: uint64ToString(signedBlsToExecutionChange.Message.ValidatorIndex),
|
||||
FromBLSPubkey: hexutil.Encode(signedBlsToExecutionChange.Message.FromBlsPubkey),
|
||||
ToExecutionAddress: hexutil.Encode(signedBlsToExecutionChange.Message.ToExecutionAddress),
|
||||
}
|
||||
jsonBlsToExecutionChanges[index] = blsToExecutionChangeJson
|
||||
signedJson := &apimiddleware.SignedBLSToExecutionChangeJson{
|
||||
Message: blsToExecutionChangeJson,
|
||||
Signature: hexutil.Encode(signedBlsToExecutionChange.Signature),
|
||||
}
|
||||
jsonBlsToExecutionChanges[index] = signedJson
|
||||
}
|
||||
return jsonBlsToExecutionChanges
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ func TestBeaconBlockJsonHelpers_JsonifyBlsToExecutionChanges(t *testing.T) {
|
||||
FromBlsPubkey: []byte{2},
|
||||
ToExecutionAddress: []byte{3},
|
||||
},
|
||||
Signature: []byte{7},
|
||||
},
|
||||
{
|
||||
Message: ðpb.BLSToExecutionChange{
|
||||
@ -38,19 +39,26 @@ func TestBeaconBlockJsonHelpers_JsonifyBlsToExecutionChanges(t *testing.T) {
|
||||
FromBlsPubkey: []byte{5},
|
||||
ToExecutionAddress: []byte{6},
|
||||
},
|
||||
Signature: []byte{8},
|
||||
},
|
||||
}
|
||||
|
||||
expectedResult := []*apimiddleware.BLSToExecutionChangeJson{
|
||||
expectedResult := []*apimiddleware.SignedBLSToExecutionChangeJson{
|
||||
{
|
||||
ValidatorIndex: "1",
|
||||
FromBLSPubkey: hexutil.Encode([]byte{2}),
|
||||
ToExecutionAddress: hexutil.Encode([]byte{3}),
|
||||
Message: &apimiddleware.BLSToExecutionChangeJson{
|
||||
ValidatorIndex: "1",
|
||||
FromBLSPubkey: hexutil.Encode([]byte{2}),
|
||||
ToExecutionAddress: hexutil.Encode([]byte{3}),
|
||||
},
|
||||
Signature: hexutil.Encode([]byte{7}),
|
||||
},
|
||||
{
|
||||
ValidatorIndex: "4",
|
||||
FromBLSPubkey: hexutil.Encode([]byte{5}),
|
||||
ToExecutionAddress: hexutil.Encode([]byte{6}),
|
||||
Message: &apimiddleware.BLSToExecutionChangeJson{
|
||||
ValidatorIndex: "4",
|
||||
FromBLSPubkey: hexutil.Encode([]byte{5}),
|
||||
ToExecutionAddress: hexutil.Encode([]byte{6}),
|
||||
},
|
||||
Signature: hexutil.Encode([]byte{8}),
|
||||
},
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user