-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
validator REST API: block v2 and Electra support (#14623)
* adding electra to validator client rest for get and post, also migrates to use the v2 endpoints * changelog * fixing test * fixing linting
- Loading branch information
1 parent
c0f9689
commit 5179af1
Showing
19 changed files
with
1,437 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
validator/client/beacon-api/propose_beacon_block_blinded_electra_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package beacon_api | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/prysmaticlabs/prysm/v5/api/server/structs" | ||
rpctesting "github.com/prysmaticlabs/prysm/v5/beacon-chain/rpc/eth/shared/testing" | ||
"github.com/prysmaticlabs/prysm/v5/testing/assert" | ||
"github.com/prysmaticlabs/prysm/v5/testing/require" | ||
"github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" | ||
"go.uber.org/mock/gomock" | ||
) | ||
|
||
func TestProposeBeaconBlock_BlindedElectra(t *testing.T) { | ||
ctrl := gomock.NewController(t) | ||
defer ctrl.Finish() | ||
jsonRestHandler := mock.NewMockJsonRestHandler(ctrl) | ||
|
||
var block structs.SignedBlindedBeaconBlockElectra | ||
err := json.Unmarshal([]byte(rpctesting.BlindedElectraBlock), &block) | ||
require.NoError(t, err) | ||
genericSignedBlock, err := block.ToGeneric() | ||
require.NoError(t, err) | ||
|
||
electraBytes, err := json.Marshal(block) | ||
require.NoError(t, err) | ||
// Make sure that what we send in the POST body is the marshalled version of the protobuf block | ||
headers := map[string]string{"Eth-Consensus-Version": "electra"} | ||
jsonRestHandler.EXPECT().Post( | ||
gomock.Any(), | ||
"/eth/v2/beacon/blinded_blocks", | ||
headers, | ||
bytes.NewBuffer(electraBytes), | ||
nil, | ||
) | ||
|
||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler} | ||
proposeResponse, err := validatorClient.proposeBeaconBlock(context.Background(), genericSignedBlock) | ||
assert.NoError(t, err) | ||
require.NotNil(t, proposeResponse) | ||
|
||
expectedBlockRoot, err := genericSignedBlock.GetBlindedElectra().HashTreeRoot() | ||
require.NoError(t, err) | ||
|
||
// Make sure that the block root is set | ||
assert.DeepEqual(t, expectedBlockRoot[:], proposeResponse.BlockRoot) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.