Skip to content

Commit

Permalink
- work towards more REST API endpoints being implemented
Browse files Browse the repository at this point in the history
- testnets can now be launched with a separate validator client - make altona SCRIPT_PARAMS="--separateVC"
- reverted the ctrl+C signal handler code reuse - not necessary for the VC anyway (default is good enough)
- added a bit more logging in the VC
- removed unnecessary code in the VC - connect() just parses the address & port...
- fixed a couple more VC issues - when fetching the duties for an epoch fails on the BN side ==> the VC shouldn't be left in a broken state
- documented the currently supported json-rpc endpoints
- added more checks on the BN side for the API - bounds-checking the requests & also checking if the BN itself is synced
- other cleanup

currently a local sim doesn't finalize, but participation in the altona network with a separate VC is painless and works just as well as with in-process validators in a BN
  • Loading branch information
onqtam committed Jul 8, 2020
1 parent fc8502c commit 1482b04
Show file tree
Hide file tree
Showing 10 changed files with 528 additions and 145 deletions.
9 changes: 8 additions & 1 deletion beacon_chain/beacon_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,14 @@ programMain:

var node = waitFor BeaconNode.init(rng, config)

ctrlCHandling: status = BeaconNodeStatus.Stopping
## Ctrl+C handling
proc controlCHandler() {.noconv.} =
when defined(windows):
# workaround for https://github.com/nim-lang/Nim/issues/4057
setupForeignThreadGc()
info "Shutting down after having received SIGINT"
status = BeaconNodeStatus.Stopping
setControlCHook(controlCHandler)

when hasPrompt:
initPrompt(node)
Expand Down
10 changes: 0 additions & 10 deletions beacon_chain/nimbus_binary_common.nim
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@ proc setupMainProc*(logLevel: string) =
stderr.write "Invalid value for --log-level. " & err.msg
quit 1

template ctrlCHandling*(extraCode: untyped) =
## Ctrl+C handling
proc controlCHandler() {.noconv.} =
when defined(windows):
# workaround for https://github.com/nim-lang/Nim/issues/4057
setupForeignThreadGc()
info "Shutting down after having received SIGINT"
extraCode
setControlCHook(controlCHandler)

template makeBannerAndConfig*(clientId: string, ConfType: type): untyped =
let
version = clientId & "\p" & copyrights & "\p\p" &
Expand Down
49 changes: 49 additions & 0 deletions beacon_chain/spec/eth2_apis/beacon_callsigs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,55 @@ proc get_v1_beacon_states_root(stateId: string): Eth2Digest
# TODO stateId is part of the REST path
proc get_v1_beacon_states_fork(stateId: string): Fork

# TODO stateId is part of the REST path
proc get_v1_beacon_states_finality_checkpoints(
stateId: string): BeaconStatesFinalityCheckpointsTuple

# TODO stateId is part of the REST path
proc get_v1_beacon_states_stateId_validators(
stateId: string, validatorIds: seq[string],
status: string): seq[BeaconStatesValidatorsTuple]

# TODO stateId and validatorId are part of the REST path
proc get_v1_beacon_states_stateId_validators_validatorId(
stateId: string, validatorId: string): BeaconStatesValidatorsTuple

# TODO stateId and epoch are part of the REST path
proc get_v1_beacon_states_stateId_committees_epoch(stateId: string,
epoch: uint64, index: uint64, slot: uint64): seq[BeaconStatesCommitteesTuple]

proc get_v1_beacon_headers(slot: uint64, parent_root: Eth2Digest): seq[BeaconHeadersTuple]

# TODO blockId is part of the REST path
proc get_v1_beacon_headers_blockId(blockId: string):
tuple[canonical: bool, header: SignedBeaconBlockHeader]

# TODO blockId is part of the REST path
proc get_v1_beacon_blocks_blockId(blockId: string): SignedBeaconBlock

# TODO blockId is part of the REST path
proc get_v1_beacon_blocks_blockId_root(blockId: string): Eth2Digest

# TODO blockId is part of the REST path
proc get_v1_beacon_blocks_blockId_attestations(blockId: string): seq[Attestation]

# TODO POST /v1/beacon/pool/attester_slashings
# TODO GET /v1/beacon/pool/attester_slashings
# TODO POST /v1/beacon/pool/proposer_slashings
# TODO GET /v1/beacon/pool/proposer_slashings
# TODO POST /v1/beacon/pool/voluntary_exits
# TODO GET /v1/beacon/pool/voluntary_exits
# TODO POST /v1/beacon/pool/attestations
# TODO GET /v1/beacon/pool/attestations



proc post_v1_beacon_pool_attestations(attestation: Attestation): bool

proc get_v1_config_fork_schedule(): seq[tuple[epoch: uint64, version: Version]]

# TODO stateId is part of the REST path
proc get_v1_debug_beacon_states_stateId(stateId: string): BeaconState


# TODO: delete old stuff
Expand Down
20 changes: 20 additions & 0 deletions beacon_chain/spec/eth2_apis/callsigs_types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,23 @@ type
genesis_time: uint64
genesis_validators_root: Eth2Digest
genesis_fork_version: Version

BeaconStatesFinalityCheckpointsTuple* = tuple
previous_justified: Checkpoint
current_justified: Checkpoint
finalized: Checkpoint

BeaconStatesValidatorsTuple* = tuple
validator: Validator
status: string
balance: uint64

BeaconStatesCommitteesTuple* = tuple
index: uint64
slot: uint64
validators: seq[uint64] # each object in the sequence should have an index field...

BeaconHeadersTuple* = tuple
root: Eth2Digest
canonical: bool
header: SignedBeaconBlockHeader
11 changes: 4 additions & 7 deletions beacon_chain/spec/eth2_apis/validator_callsigs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,16 @@ import
# calls that return a bool are actually without a return type in the main REST API
# spec but nim-json-rpc requires that all RPC calls have a return type.

proc post_v1_beacon_pool_attestations(attestation: Attestation): bool
proc get_v1_validator_block(slot: Slot, graffiti: Eth2Digest, randao_reveal: ValidatorSig): BeaconBlock

# TODO slot is part of the REST path
proc get_v1_validator_blocks(slot: Slot, graffiti: Eth2Digest, randao_reveal: ValidatorSig): BeaconBlock
proc post_v1_validator_block(body: SignedBeaconBlock): bool

proc post_v1_beacon_blocks(body: SignedBeaconBlock): bool

proc get_v1_validator_attestation_data(slot: Slot, committee_index: CommitteeIndex): AttestationData
proc get_v1_validator_attestation(slot: Slot, committee_index: CommitteeIndex): AttestationData

# TODO at the time of writing (10.06.2020) the API specifies this call to have a hash of
# the attestation data instead of the object itself but we also need the slot.. see here:
# https://docs.google.com/spreadsheets/d/1kVIx6GvzVLwNYbcd-Fj8YUlPf4qGrWUlS35uaTnIAVg/edit?disco=AAAAGh7r_fQ
proc get_v1_validator_aggregate_attestation(attestation_data: AttestationData): Attestation
proc get_v1_validator_aggregate_and_proof(attestation_data: AttestationData): Attestation

proc post_v1_validator_aggregate_and_proof(payload: SignedAggregateAndProof): bool

Expand Down
Loading

0 comments on commit 1482b04

Please sign in to comment.