Clean up debug/heads v2 types (#5859)
This commit is contained in:
parent
b7026a683a
commit
9aabca6a64
|
@ -72,8 +72,11 @@ proc installDebugApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
"/eth/v2/debug/beacon/heads") do () -> RestApiResponse:
|
"/eth/v2/debug/beacon/heads") do () -> RestApiResponse:
|
||||||
RestApiResponse.jsonResponse(
|
RestApiResponse.jsonResponse(
|
||||||
node.dag.heads.mapIt(
|
node.dag.heads.mapIt(
|
||||||
(root: it.root, slot: it.slot,
|
RestChainHeadV2(
|
||||||
execution_optimistic: not it.executionValid)
|
root: it.root,
|
||||||
|
slot: it.slot,
|
||||||
|
execution_optimistic: not it.executionValid
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,7 @@ RestJson.useDefaultSerializationFor(
|
||||||
RestBeaconStatesFinalityCheckpoints,
|
RestBeaconStatesFinalityCheckpoints,
|
||||||
RestBlockHeader,
|
RestBlockHeader,
|
||||||
RestBlockHeaderInfo,
|
RestBlockHeaderInfo,
|
||||||
|
RestChainHeadV2,
|
||||||
RestCommitteeSubscription,
|
RestCommitteeSubscription,
|
||||||
RestContributionAndProof,
|
RestContributionAndProof,
|
||||||
RestDepositContract,
|
RestDepositContract,
|
||||||
|
|
|
@ -13,6 +13,12 @@ import
|
||||||
|
|
||||||
export chronos, client, rest_types, eth2_rest_serialization
|
export chronos, client, rest_types, eth2_rest_serialization
|
||||||
|
|
||||||
|
proc getDebugChainHeadsV2*(): RestResponse[GetDebugChainHeadsV2Response] {.
|
||||||
|
rest, endpoint: "/eth/v2/debug/beacon/heads",
|
||||||
|
meth: MethodGet.}
|
||||||
|
## https://ethereum.github.io/beacon-APIs/#/Beacon/getDebugChainHeadsV2
|
||||||
|
|
||||||
|
|
||||||
proc getStateV2Plain*(state_id: StateIdent): RestPlainResponse {.
|
proc getStateV2Plain*(state_id: StateIdent): RestPlainResponse {.
|
||||||
rest, endpoint: "/eth/v2/debug/beacon/states/{state_id}",
|
rest, endpoint: "/eth/v2/debug/beacon/states/{state_id}",
|
||||||
accept: preferSSZ,
|
accept: preferSSZ,
|
||||||
|
|
|
@ -263,9 +263,10 @@ type
|
||||||
connected*: uint64
|
connected*: uint64
|
||||||
disconnecting*: uint64
|
disconnecting*: uint64
|
||||||
|
|
||||||
RestChainHead* = object
|
RestChainHeadV2* = object
|
||||||
root*: Eth2Digest
|
root*: Eth2Digest
|
||||||
slot*: Slot
|
slot*: Slot
|
||||||
|
execution_optimistic*: bool
|
||||||
|
|
||||||
RestMetadata* = object
|
RestMetadata* = object
|
||||||
seq_number*: string
|
seq_number*: string
|
||||||
|
@ -541,7 +542,7 @@ type
|
||||||
GetBlockHeaderResponse* = DataOptimisticAndFinalizedObject[RestBlockHeaderInfo]
|
GetBlockHeaderResponse* = DataOptimisticAndFinalizedObject[RestBlockHeaderInfo]
|
||||||
GetBlockHeadersResponse* = DataEnclosedObject[seq[RestBlockHeaderInfo]]
|
GetBlockHeadersResponse* = DataEnclosedObject[seq[RestBlockHeaderInfo]]
|
||||||
GetBlockRootResponse* = DataOptimisticObject[RestRoot]
|
GetBlockRootResponse* = DataOptimisticObject[RestRoot]
|
||||||
GetDebugChainHeadsResponse* = DataEnclosedObject[seq[RestChainHead]]
|
GetDebugChainHeadsV2Response* = DataEnclosedObject[seq[RestChainHeadV2]]
|
||||||
GetDepositContractResponse* = DataEnclosedObject[RestDepositContract]
|
GetDepositContractResponse* = DataEnclosedObject[RestDepositContract]
|
||||||
GetDepositSnapshotResponse* = DataEnclosedObject[RestDepositSnapshot]
|
GetDepositSnapshotResponse* = DataEnclosedObject[RestDepositSnapshot]
|
||||||
GetEpochCommitteesResponse* = DataEnclosedObject[seq[RestBeaconStatesCommittees]]
|
GetEpochCommitteesResponse* = DataEnclosedObject[seq[RestBeaconStatesCommittees]]
|
||||||
|
|
|
@ -449,7 +449,7 @@ proc validateMnemonic*(inputWords: string,
|
||||||
|
|
||||||
# TODO consider using a SecretString type for inputWords
|
# TODO consider using a SecretString type for inputWords
|
||||||
|
|
||||||
let words = strutils.strip(inputWords.string.toNFKD).split(Whitespace)
|
let words = strutils.strip(inputWords.toNFKD).split(Whitespace)
|
||||||
if words.len < 12 or words.len > 24 or words.len mod 3 != 0:
|
if words.len < 12 or words.len > 24 or words.len mod 3 != 0:
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue