remove some debugRaiseAsserts and fill in actual Electra functionality (#6172)
This commit is contained in:
parent
13a70e9d69
commit
0b6f75b88b
|
@ -57,13 +57,9 @@ proc installDebugApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
elif contentType == sszMediaType:
|
elif contentType == sszMediaType:
|
||||||
let headers = [("eth-consensus-version", state.kind.toString())]
|
let headers = [("eth-consensus-version", state.kind.toString())]
|
||||||
withState(state):
|
withState(state):
|
||||||
debugRaiseAssert "debug beacon API"
|
|
||||||
when consensusFork != ConsensusFork.Electra:
|
|
||||||
RestApiResponse.sszResponse(forkyState.data, headers)
|
RestApiResponse.sszResponse(forkyState.data, headers)
|
||||||
else:
|
else:
|
||||||
RestApiResponse.jsonError(Http500, InvalidAcceptError)
|
RestApiResponse.jsonError(Http500, InvalidAcceptError)
|
||||||
else:
|
|
||||||
RestApiResponse.jsonError(Http500, InvalidAcceptError)
|
|
||||||
|
|
||||||
RestApiResponse.jsonError(Http404, StateNotFoundError)
|
RestApiResponse.jsonError(Http404, StateNotFoundError)
|
||||||
|
|
||||||
|
|
|
@ -67,11 +67,13 @@ RestJson.useDefaultSerializationFor(
|
||||||
DenebSignedBlockContents,
|
DenebSignedBlockContents,
|
||||||
Deposit,
|
Deposit,
|
||||||
DepositData,
|
DepositData,
|
||||||
|
DepositReceipt,
|
||||||
DepositTreeSnapshot,
|
DepositTreeSnapshot,
|
||||||
DistributedKeystoreInfo,
|
DistributedKeystoreInfo,
|
||||||
EmptyBody,
|
EmptyBody,
|
||||||
Eth1Data,
|
Eth1Data,
|
||||||
EventBeaconBlockObject,
|
EventBeaconBlockObject,
|
||||||
|
ExecutionLayerExit,
|
||||||
ExecutionPayloadAndBlobsBundle,
|
ExecutionPayloadAndBlobsBundle,
|
||||||
Fork,
|
Fork,
|
||||||
GetBlockAttestationsResponse,
|
GetBlockAttestationsResponse,
|
||||||
|
@ -240,6 +242,12 @@ RestJson.useDefaultSerializationFor(
|
||||||
deneb_mev.BuilderBid,
|
deneb_mev.BuilderBid,
|
||||||
deneb_mev.SignedBlindedBeaconBlock,
|
deneb_mev.SignedBlindedBeaconBlock,
|
||||||
deneb_mev.SignedBuilderBid,
|
deneb_mev.SignedBuilderBid,
|
||||||
|
electra.BeaconBlock,
|
||||||
|
electra.BeaconState,
|
||||||
|
electra.BeaconBlockBody,
|
||||||
|
electra.ExecutionPayload,
|
||||||
|
electra.ExecutionPayloadHeader,
|
||||||
|
electra.SignedBeaconBlock,
|
||||||
phase0.BeaconBlock,
|
phase0.BeaconBlock,
|
||||||
phase0.BeaconBlockBody,
|
phase0.BeaconBlockBody,
|
||||||
phase0.BeaconState,
|
phase0.BeaconState,
|
||||||
|
@ -597,8 +605,6 @@ proc jsonResponseBlock*(t: typedesc[RestApiResponse],
|
||||||
writer.writeField("execution_optimistic", execOpt.get())
|
writer.writeField("execution_optimistic", execOpt.get())
|
||||||
writer.writeField("finalized", finalized)
|
writer.writeField("finalized", finalized)
|
||||||
withBlck(data):
|
withBlck(data):
|
||||||
debugRaiseAssert "foo"
|
|
||||||
when consensusFork != ConsensusFork.Electra:
|
|
||||||
writer.writeField("data", forkyBlck)
|
writer.writeField("data", forkyBlck)
|
||||||
writer.endRecord()
|
writer.endRecord()
|
||||||
stream.getOutput(seq[byte])
|
stream.getOutput(seq[byte])
|
||||||
|
@ -622,8 +628,6 @@ proc jsonResponseState*(t: typedesc[RestApiResponse],
|
||||||
if execOpt.isSome():
|
if execOpt.isSome():
|
||||||
writer.writeField("execution_optimistic", execOpt.get())
|
writer.writeField("execution_optimistic", execOpt.get())
|
||||||
withState(data):
|
withState(data):
|
||||||
debugRaiseAssert "foo"
|
|
||||||
when consensusFork != ConsensusFork.Electra:
|
|
||||||
writer.writeField("data", forkyState.data)
|
writer.writeField("data", forkyState.data)
|
||||||
writer.endRecord()
|
writer.endRecord()
|
||||||
stream.getOutput(seq[byte])
|
stream.getOutput(seq[byte])
|
||||||
|
@ -2007,8 +2011,15 @@ proc readValue*(reader: var JsonReader[RestJson],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
of ConsensusFork.Electra:
|
of ConsensusFork.Electra:
|
||||||
debugRaiseAssert "electra missing"
|
ForkedBeaconBlock.init(
|
||||||
default(ForkedBeaconBlock)
|
electra.BeaconBlock(
|
||||||
|
slot: slot.get(),
|
||||||
|
proposer_index: proposer_index.get(),
|
||||||
|
parent_root: parent_root.get(),
|
||||||
|
state_root: state_root.get(),
|
||||||
|
body: body.electraBody
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
## RestPublishedSignedBeaconBlock
|
## RestPublishedSignedBeaconBlock
|
||||||
|
@ -2253,7 +2264,16 @@ proc readValue*(reader: var JsonReader[RestJson],
|
||||||
|
|
||||||
value = ForkedSignedBeaconBlock.init(res)
|
value = ForkedSignedBeaconBlock.init(res)
|
||||||
of ConsensusFork.Electra:
|
of ConsensusFork.Electra:
|
||||||
debugRaiseAssert "electra support missing"
|
let res =
|
||||||
|
try:
|
||||||
|
RestJson.decode(string(data.get()),
|
||||||
|
electra.SignedBeaconBlock,
|
||||||
|
requireAllFields = true,
|
||||||
|
allowUnknownFields = true)
|
||||||
|
except SerializationError:
|
||||||
|
reader.raiseUnexpectedValue("Incorrect electra block format")
|
||||||
|
|
||||||
|
value = ForkedSignedBeaconBlock.init(res)
|
||||||
withBlck(value):
|
withBlck(value):
|
||||||
forkyBlck.root = hash_tree_root(forkyBlck.message)
|
forkyBlck.root = hash_tree_root(forkyBlck.message)
|
||||||
|
|
||||||
|
@ -2278,6 +2298,7 @@ proc writeValue*(
|
||||||
writer.writeField("version", "deneb")
|
writer.writeField("version", "deneb")
|
||||||
writer.writeField("data", value.denebData)
|
writer.writeField("data", value.denebData)
|
||||||
of ConsensusFork.Electra:
|
of ConsensusFork.Electra:
|
||||||
|
writer.writeField("version", "electra")
|
||||||
debugRaiseAssert "writeValue RestJson Electra ForkedSignedBaconBlock"
|
debugRaiseAssert "writeValue RestJson Electra ForkedSignedBaconBlock"
|
||||||
writer.endRecord()
|
writer.endRecord()
|
||||||
|
|
||||||
|
@ -2303,6 +2324,7 @@ proc readValue*(reader: var JsonReader[RestJson],
|
||||||
of "bellatrix": Opt.some(ConsensusFork.Bellatrix)
|
of "bellatrix": Opt.some(ConsensusFork.Bellatrix)
|
||||||
of "capella": Opt.some(ConsensusFork.Capella)
|
of "capella": Opt.some(ConsensusFork.Capella)
|
||||||
of "deneb": Opt.some(ConsensusFork.Deneb)
|
of "deneb": Opt.some(ConsensusFork.Deneb)
|
||||||
|
of "electra": Opt.some(ConsensusFork.Electra)
|
||||||
else: reader.raiseUnexpectedValue("Incorrect version field value")
|
else: reader.raiseUnexpectedValue("Incorrect version field value")
|
||||||
of "data":
|
of "data":
|
||||||
if data.isSome():
|
if data.isSome():
|
||||||
|
@ -2383,8 +2405,15 @@ proc readValue*(reader: var JsonReader[RestJson],
|
||||||
reader.raiseUnexpectedValue("Incorrect deneb beacon state format")
|
reader.raiseUnexpectedValue("Incorrect deneb beacon state format")
|
||||||
toValue(denebData)
|
toValue(denebData)
|
||||||
of ConsensusFork.Electra:
|
of ConsensusFork.Electra:
|
||||||
debugRaiseAssert "electra missing"
|
try:
|
||||||
reader.raiseUnexpectedValue("electra missing")
|
tmp[].electraData.data = RestJson.decode(
|
||||||
|
string(data.get()),
|
||||||
|
electra.BeaconState,
|
||||||
|
requireAllFields = true,
|
||||||
|
allowUnknownFields = true)
|
||||||
|
except SerializationError:
|
||||||
|
reader.raiseUnexpectedValue("Incorrect electra beacon state format")
|
||||||
|
toValue(electraData)
|
||||||
|
|
||||||
proc writeValue*(
|
proc writeValue*(
|
||||||
writer: var JsonWriter[RestJson], value: ForkedHashedBeaconState
|
writer: var JsonWriter[RestJson], value: ForkedHashedBeaconState
|
||||||
|
@ -2407,7 +2436,8 @@ proc writeValue*(
|
||||||
writer.writeField("version", "deneb")
|
writer.writeField("version", "deneb")
|
||||||
writer.writeField("data", value.denebData.data)
|
writer.writeField("data", value.denebData.data)
|
||||||
of ConsensusFork.Electra:
|
of ConsensusFork.Electra:
|
||||||
debugRaiseAssert "writeValue RestJson ForkedHashedBeaconState Electra missing"
|
writer.writeField("version", "electra")
|
||||||
|
writer.writeField("data", value.electraData.data)
|
||||||
writer.endRecord()
|
writer.endRecord()
|
||||||
|
|
||||||
## SomeForkedLightClientObject
|
## SomeForkedLightClientObject
|
||||||
|
|
|
@ -662,8 +662,7 @@ func init*(T: type ForkedSignedBeaconBlock,
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
ForkedSignedBeaconBlock.init(contents.denebData.signed_block)
|
ForkedSignedBeaconBlock.init(contents.denebData.signed_block)
|
||||||
of ConsensusFork.Electra:
|
of ConsensusFork.Electra:
|
||||||
debugRaiseAssert "electra init ForkedSignedBeaconBlock from RestPublished*"
|
ForkedSignedBeaconBlock.init(contents.electraData.signed_block)
|
||||||
default(ForkedSignedBeaconBlock)
|
|
||||||
|
|
||||||
func init*(t: typedesc[RestPublishedSignedBlockContents],
|
func init*(t: typedesc[RestPublishedSignedBlockContents],
|
||||||
blck: phase0.BeaconBlock, root: Eth2Digest,
|
blck: phase0.BeaconBlock, root: Eth2Digest,
|
||||||
|
|
|
@ -517,10 +517,9 @@ template Forky*(
|
||||||
template withAll*(
|
template withAll*(
|
||||||
x: typedesc[ConsensusFork], body: untyped): untyped =
|
x: typedesc[ConsensusFork], body: untyped): untyped =
|
||||||
static: doAssert ConsensusFork.high == ConsensusFork.Electra
|
static: doAssert ConsensusFork.high == ConsensusFork.Electra
|
||||||
debugRaiseAssert "don't turn on electra here yet"
|
block:
|
||||||
#block:
|
const consensusFork {.inject, used.} = ConsensusFork.Electra
|
||||||
# const consensusFork {.inject, used.} = ConsensusFork.Electra
|
body
|
||||||
# body
|
|
||||||
block:
|
block:
|
||||||
const consensusFork {.inject, used.} = ConsensusFork.Deneb
|
const consensusFork {.inject, used.} = ConsensusFork.Deneb
|
||||||
body
|
body
|
||||||
|
@ -638,6 +637,8 @@ template init*(T: type ForkedBeaconBlock, blck: capella.BeaconBlock): T =
|
||||||
T(kind: ConsensusFork.Capella, capellaData: blck)
|
T(kind: ConsensusFork.Capella, capellaData: blck)
|
||||||
template init*(T: type ForkedBeaconBlock, blck: deneb.BeaconBlock): T =
|
template init*(T: type ForkedBeaconBlock, blck: deneb.BeaconBlock): T =
|
||||||
T(kind: ConsensusFork.Deneb, denebData: blck)
|
T(kind: ConsensusFork.Deneb, denebData: blck)
|
||||||
|
template init*(T: type ForkedBeaconBlock, blck: electra.BeaconBlock): T =
|
||||||
|
T(kind: ConsensusFork.Electra, electraData: blck)
|
||||||
|
|
||||||
template init*(T: type ForkedSignedBeaconBlock, blck: phase0.SignedBeaconBlock): T =
|
template init*(T: type ForkedSignedBeaconBlock, blck: phase0.SignedBeaconBlock): T =
|
||||||
T(kind: ConsensusFork.Phase0, phase0Data: blck)
|
T(kind: ConsensusFork.Phase0, phase0Data: blck)
|
||||||
|
|
|
@ -113,8 +113,14 @@ proc produceBlock(
|
||||||
kzgProofsOpt: Opt.some(kzgProofs),
|
kzgProofsOpt: Opt.some(kzgProofs),
|
||||||
blobsOpt: Opt.some(blobs)))
|
blobsOpt: Opt.some(blobs)))
|
||||||
of ConsensusFork.Electra:
|
of ConsensusFork.Electra:
|
||||||
debugRaiseAssert ""
|
let
|
||||||
return Opt.none(PreparedBeaconBlock)
|
blck = produceBlockResponse.electraData.`block`
|
||||||
|
kzgProofs = produceBlockResponse.electraData.kzg_proofs
|
||||||
|
blobs = produceBlockResponse.electraData.blobs
|
||||||
|
return Opt.some(PreparedBeaconBlock(blockRoot: hash_tree_root(blck),
|
||||||
|
data: ForkedBeaconBlock.init(blck),
|
||||||
|
kzgProofsOpt: Opt.some(kzgProofs),
|
||||||
|
blobsOpt: Opt.some(blobs)))
|
||||||
|
|
||||||
proc produceBlindedBlock(
|
proc produceBlindedBlock(
|
||||||
vc: ValidatorClientRef,
|
vc: ValidatorClientRef,
|
||||||
|
|
|
@ -247,7 +247,8 @@ proc cmdBench(conf: DbConf, cfg: RuntimeConfig) =
|
||||||
seq[altair.TrustedSignedBeaconBlock],
|
seq[altair.TrustedSignedBeaconBlock],
|
||||||
seq[bellatrix.TrustedSignedBeaconBlock],
|
seq[bellatrix.TrustedSignedBeaconBlock],
|
||||||
seq[capella.TrustedSignedBeaconBlock],
|
seq[capella.TrustedSignedBeaconBlock],
|
||||||
seq[deneb.TrustedSignedBeaconBlock])
|
seq[deneb.TrustedSignedBeaconBlock],
|
||||||
|
seq[electra.TrustedSignedBeaconBlock])
|
||||||
|
|
||||||
echo "Loaded head slot ", dag.head.slot,
|
echo "Loaded head slot ", dag.head.slot,
|
||||||
" selected ", blockRefs.len, " blocks"
|
" selected ", blockRefs.len, " blocks"
|
||||||
|
@ -287,7 +288,8 @@ proc cmdBench(conf: DbConf, cfg: RuntimeConfig) =
|
||||||
(ref altair.HashedBeaconState)(),
|
(ref altair.HashedBeaconState)(),
|
||||||
(ref bellatrix.HashedBeaconState)(),
|
(ref bellatrix.HashedBeaconState)(),
|
||||||
(ref capella.HashedBeaconState)(),
|
(ref capella.HashedBeaconState)(),
|
||||||
(ref deneb.HashedBeaconState)())
|
(ref deneb.HashedBeaconState)(),
|
||||||
|
(ref electra.HashedBeaconState)())
|
||||||
|
|
||||||
withTimer(timers[tLoadState]):
|
withTimer(timers[tLoadState]):
|
||||||
doAssert dag.updateState(
|
doAssert dag.updateState(
|
||||||
|
@ -349,8 +351,8 @@ proc cmdBench(conf: DbConf, cfg: RuntimeConfig) =
|
||||||
doAssert dbBenchmark.getState(
|
doAssert dbBenchmark.getState(
|
||||||
forkyState.root, loadedState[4][].data, noRollback)
|
forkyState.root, loadedState[4][].data, noRollback)
|
||||||
of ConsensusFork.Electra:
|
of ConsensusFork.Electra:
|
||||||
debugRaiseAssert ""
|
doAssert dbBenchmark.getState(
|
||||||
let x = 5
|
forkyState.root, loadedState[5][].data, noRollback)
|
||||||
|
|
||||||
if forkyState.data.slot.epoch mod 16 == 0:
|
if forkyState.data.slot.epoch mod 16 == 0:
|
||||||
let loadedRoot = case consensusFork
|
let loadedRoot = case consensusFork
|
||||||
|
@ -359,9 +361,7 @@ proc cmdBench(conf: DbConf, cfg: RuntimeConfig) =
|
||||||
of ConsensusFork.Bellatrix: hash_tree_root(loadedState[2][].data)
|
of ConsensusFork.Bellatrix: hash_tree_root(loadedState[2][].data)
|
||||||
of ConsensusFork.Capella: hash_tree_root(loadedState[3][].data)
|
of ConsensusFork.Capella: hash_tree_root(loadedState[3][].data)
|
||||||
of ConsensusFork.Deneb: hash_tree_root(loadedState[4][].data)
|
of ConsensusFork.Deneb: hash_tree_root(loadedState[4][].data)
|
||||||
of ConsensusFork.Electra:
|
of ConsensusFork.Electra: hash_tree_root(loadedState[5][].data)
|
||||||
debugRaiseAssert ""
|
|
||||||
ZERO_HASH
|
|
||||||
doAssert hash_tree_root(forkyState.data) == loadedRoot
|
doAssert hash_tree_root(forkyState.data) == loadedRoot
|
||||||
|
|
||||||
processBlocks(blocks[0])
|
processBlocks(blocks[0])
|
||||||
|
@ -369,6 +369,7 @@ proc cmdBench(conf: DbConf, cfg: RuntimeConfig) =
|
||||||
processBlocks(blocks[2])
|
processBlocks(blocks[2])
|
||||||
processBlocks(blocks[3])
|
processBlocks(blocks[3])
|
||||||
processBlocks(blocks[4])
|
processBlocks(blocks[4])
|
||||||
|
processBlocks(blocks[5])
|
||||||
|
|
||||||
printTimers(false, timers)
|
printTimers(false, timers)
|
||||||
|
|
||||||
|
|
|
@ -222,8 +222,14 @@ cli do(validatorsDir: string, secretsDir: string,
|
||||||
validators[proposer]).toValidatorSig())
|
validators[proposer]).toValidatorSig())
|
||||||
dump(".", signedBlock)
|
dump(".", signedBlock)
|
||||||
of ConsensusFork.Electra:
|
of ConsensusFork.Electra:
|
||||||
debugRaiseAssert ""
|
blockRoot = hash_tree_root(message.electraData)
|
||||||
let x =5
|
let signedBlock = electra.SignedBeaconBlock(
|
||||||
|
message: message.electraData,
|
||||||
|
root: blockRoot,
|
||||||
|
signature: get_block_signature(
|
||||||
|
fork, genesis_validators_root, slot, blockRoot,
|
||||||
|
validators[proposer]).toValidatorSig())
|
||||||
|
dump(".", signedBlock)
|
||||||
except CatchableError:
|
except CatchableError:
|
||||||
raiseAssert "unreachable"
|
raiseAssert "unreachable"
|
||||||
notice "Block proposed", message, blockRoot
|
notice "Block proposed", message, blockRoot
|
||||||
|
|
|
@ -136,8 +136,9 @@ func init(t: typedesc[Web3SignerForkedBeaconBlock],
|
||||||
kind: ConsensusFork.Deneb,
|
kind: ConsensusFork.Deneb,
|
||||||
data: forked.denebData.toBeaconBlockHeader)
|
data: forked.denebData.toBeaconBlockHeader)
|
||||||
of ConsensusFork.Electra:
|
of ConsensusFork.Electra:
|
||||||
debugRaiseAssert "electra missing"
|
Web3SignerForkedBeaconBlock(
|
||||||
raiseAssert "electra missing"
|
kind: ConsensusFork.Electra,
|
||||||
|
data: forked.electraData.toBeaconBlockHeader)
|
||||||
|
|
||||||
proc createKeystore(dataDir, pubkey,
|
proc createKeystore(dataDir, pubkey,
|
||||||
store, password: string): Result[void, string] =
|
store, password: string): Result[void, string] =
|
||||||
|
|
Loading…
Reference in New Issue