1
1
mod api_secret;
2
2
mod create_validator;
3
3
mod keystores;
4
+ mod remotekeys;
4
5
mod tests;
5
6
6
7
use crate :: ValidatorStore ;
7
- use account_utils:: mnemonic_from_phrase;
8
+ use account_utils:: {
9
+ mnemonic_from_phrase,
10
+ validator_definitions:: { SigningDefinition , ValidatorDefinition } ,
11
+ } ;
8
12
use create_validator:: { create_validators_mnemonic, create_validators_web3signer} ;
9
13
use eth2:: lighthouse_vc:: {
10
14
std_types:: AuthResponse ,
@@ -459,7 +463,25 @@ pub fn serve<T: 'static + SlotClock + Clone, E: EthSpec>(
459
463
runtime : Weak < Runtime > | {
460
464
blocking_signed_json_task ( signer, move || {
461
465
if let Some ( runtime) = runtime. upgrade ( ) {
462
- runtime. block_on ( create_validators_web3signer ( & body, & validator_store) ) ?;
466
+ let web3signers: Vec < ValidatorDefinition > = body
467
+ . into_iter ( )
468
+ . map ( |web3signer| ValidatorDefinition {
469
+ enabled : web3signer. enable ,
470
+ voting_public_key : web3signer. voting_public_key ,
471
+ graffiti : web3signer. graffiti ,
472
+ suggested_fee_recipient : web3signer. suggested_fee_recipient ,
473
+ description : web3signer. description ,
474
+ signing_definition : SigningDefinition :: Web3Signer {
475
+ url : web3signer. url ,
476
+ root_certificate_path : web3signer. root_certificate_path ,
477
+ request_timeout_ms : web3signer. request_timeout_ms ,
478
+ } ,
479
+ } )
480
+ . collect ( ) ;
481
+ runtime. block_on ( create_validators_web3signer (
482
+ web3signers,
483
+ & validator_store,
484
+ ) ) ?;
463
485
Ok ( ( ) )
464
486
} else {
465
487
Err ( warp_utils:: reject:: custom_server_error (
@@ -536,6 +558,7 @@ pub fn serve<T: 'static + SlotClock + Clone, E: EthSpec>(
536
558
// Standard key-manager endpoints.
537
559
let eth_v1 = warp:: path ( "eth" ) . and ( warp:: path ( "v1" ) ) ;
538
560
let std_keystores = eth_v1. and ( warp:: path ( "keystores" ) ) . and ( warp:: path:: end ( ) ) ;
561
+ let std_remotekeys = eth_v1. and ( warp:: path ( "remotekeys" ) ) . and ( warp:: path:: end ( ) ) ;
539
562
540
563
// GET /eth/v1/keystores
541
564
let get_std_keystores = std_keystores
@@ -563,14 +586,48 @@ pub fn serve<T: 'static + SlotClock + Clone, E: EthSpec>(
563
586
564
587
// DELETE /eth/v1/keystores
565
588
let delete_std_keystores = std_keystores
589
+ . and ( warp:: body:: json ( ) )
590
+ . and ( signer. clone ( ) )
591
+ . and ( validator_store_filter. clone ( ) )
592
+ . and ( runtime_filter. clone ( ) )
593
+ . and ( log_filter. clone ( ) )
594
+ . and_then ( |request, signer, validator_store, runtime, log| {
595
+ blocking_signed_json_task ( signer, move || {
596
+ keystores:: delete ( request, validator_store, runtime, log)
597
+ } )
598
+ } ) ;
599
+
600
+ // GET /eth/v1/remotekeys
601
+ let get_std_remotekeys = std_remotekeys
602
+ . and ( signer. clone ( ) )
603
+ . and ( validator_store_filter. clone ( ) )
604
+ . and_then ( |signer, validator_store : Arc < ValidatorStore < T , E > > | {
605
+ blocking_signed_json_task ( signer, move || Ok ( remotekeys:: list ( validator_store) ) )
606
+ } ) ;
607
+
608
+ // POST /eth/v1/remotekeys
609
+ let post_std_remotekeys = std_remotekeys
610
+ . and ( warp:: body:: json ( ) )
611
+ . and ( signer. clone ( ) )
612
+ . and ( validator_store_filter. clone ( ) )
613
+ . and ( runtime_filter. clone ( ) )
614
+ . and ( log_filter. clone ( ) )
615
+ . and_then ( |request, signer, validator_store, runtime, log| {
616
+ blocking_signed_json_task ( signer, move || {
617
+ remotekeys:: import ( request, validator_store, runtime, log)
618
+ } )
619
+ } ) ;
620
+
621
+ // DELETE /eth/v1/remotekeys
622
+ let delete_std_remotekeys = std_remotekeys
566
623
. and ( warp:: body:: json ( ) )
567
624
. and ( signer)
568
625
. and ( validator_store_filter)
569
626
. and ( runtime_filter)
570
- . and ( log_filter)
627
+ . and ( log_filter. clone ( ) )
571
628
. and_then ( |request, signer, validator_store, runtime, log| {
572
629
blocking_signed_json_task ( signer, move || {
573
- keystores :: delete ( request, validator_store, runtime, log)
630
+ remotekeys :: delete ( request, validator_store, runtime, log)
574
631
} )
575
632
} ) ;
576
633
@@ -588,17 +645,19 @@ pub fn serve<T: 'static + SlotClock + Clone, E: EthSpec>(
588
645
. or ( get_lighthouse_spec)
589
646
. or ( get_lighthouse_validators)
590
647
. or ( get_lighthouse_validators_pubkey)
591
- . or ( get_std_keystores) ,
648
+ . or ( get_std_keystores)
649
+ . or ( get_std_remotekeys) ,
592
650
)
593
651
. or ( warp:: post ( ) . and (
594
652
post_validators
595
653
. or ( post_validators_keystore)
596
654
. or ( post_validators_mnemonic)
597
655
. or ( post_validators_web3signer)
598
- . or ( post_std_keystores) ,
656
+ . or ( post_std_keystores)
657
+ . or ( post_std_remotekeys) ,
599
658
) )
600
659
. or ( warp:: patch ( ) . and ( patch_validators) )
601
- . or ( warp:: delete ( ) . and ( delete_std_keystores) ) ,
660
+ . or ( warp:: delete ( ) . and ( delete_std_keystores. or ( delete_std_remotekeys ) ) ) ,
602
661
)
603
662
// The auth route is the only route that is allowed to be accessed without the API token.
604
663
. or ( warp:: get ( ) . and ( get_auth) )
0 commit comments