rename most eip4844Data to denebData (#4693)

This commit is contained in:
tersec 2023-03-04 22:23:52 +00:00 committed by GitHub
parent 3b41e6a0e7
commit e3d96ef147
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 54 additions and 54 deletions

View File

@ -781,8 +781,8 @@ proc processNewBlockForLightClient*(
return
when signedBlock is deneb.TrustedSignedBeaconBlock:
dag.cacheLightClientData(state.eip4844Data, signedBlock.toBlockId())
dag.createLightClientUpdates(state.eip4844Data, signedBlock, parentBid)
dag.cacheLightClientData(state.denebData, signedBlock.toBlockId())
dag.createLightClientUpdates(state.denebData, signedBlock, parentBid)
elif signedBlock is capella.TrustedSignedBeaconBlock:
dag.cacheLightClientData(state.capellaData, signedBlock.toBlockId())
dag.createLightClientUpdates(state.capellaData, signedBlock, parentBid)

View File

@ -1162,7 +1162,7 @@ proc writeValue*[
writer.writeField("block_header", value.capellaData)
of ConsensusFork.Deneb:
writer.writeField("version", forkIdentifier "deneb")
writer.writeField("block_header", value.eip4844Data)
writer.writeField("block_header", value.denebData)
writer.endRecord()
proc writeValue*[
@ -1192,7 +1192,7 @@ proc writeValue*[
writer.writeField("data", value.capellaData)
of ConsensusFork.Deneb:
writer.writeField("version", forkIdentifier "deneb")
writer.writeField("data", value.eip4844Data)
writer.writeField("data", value.denebData)
writer.endRecord()
## RestPublishedBeaconBlockBody
@ -1671,7 +1671,7 @@ proc writeValue*(writer: var JsonWriter[RestJson],
writer.writeField("data", value.capellaData)
of ConsensusFork.Deneb:
writer.writeField("version", "deneb")
writer.writeField("data", value.eip4844Data)
writer.writeField("data", value.denebData)
writer.endRecord()
# ForkedHashedBeaconState is used where a `ForkedBeaconState` normally would
@ -1767,14 +1767,14 @@ proc readValue*(reader: var JsonReader[RestJson],
toValue(capellaData)
of ConsensusFork.Deneb:
try:
tmp[].eip4844Data.data = RestJson.decode(
tmp[].denebData.data = RestJson.decode(
string(data.get()),
deneb.BeaconState,
requireAllFields = true,
allowUnknownFields = true)
except SerializationError:
reader.raiseUnexpectedValue("Incorrect EIP4844 beacon state format")
toValue(eip4844Data)
toValue(denebData)
proc writeValue*(writer: var JsonWriter[RestJson], value: ForkedHashedBeaconState)
{.raises: [IOError, Defect].} =
@ -1794,7 +1794,7 @@ proc writeValue*(writer: var JsonWriter[RestJson], value: ForkedHashedBeaconStat
writer.writeField("data", value.capellaData.data)
of ConsensusFork.Deneb:
writer.writeField("version", "deneb")
writer.writeField("data", value.eip4844Data.data)
writer.writeField("data", value.denebData.data)
writer.endRecord()
## Web3SignerRequest

View File

@ -68,7 +68,7 @@ type
of ConsensusFork.Altair: altairData*: altair.HashedBeaconState
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix.HashedBeaconState
of ConsensusFork.Capella: capellaData*: capella.HashedBeaconState
of ConsensusFork.Deneb: eip4844Data*: deneb.HashedBeaconState
of ConsensusFork.Deneb: denebData*: deneb.HashedBeaconState
ForkyExecutionPayload* =
bellatrix.ExecutionPayload |
@ -138,7 +138,7 @@ type
of ConsensusFork.Altair: altairData*: altair.BeaconBlock
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix.BeaconBlock
of ConsensusFork.Capella: capellaData*: capella.BeaconBlock
of ConsensusFork.Deneb: eip4844Data*: deneb.BeaconBlock
of ConsensusFork.Deneb: denebData*: deneb.BeaconBlock
Web3SignerForkedBeaconBlock* = object
case kind*: ConsensusFork
@ -146,7 +146,7 @@ type
of ConsensusFork.Altair: altairData*: altair.BeaconBlock
of ConsensusFork.Bellatrix: bellatrixData*: BeaconBlockHeader
of ConsensusFork.Capella: capellaData*: BeaconBlockHeader
of ConsensusFork.Deneb: eip4844Data*: BeaconBlockHeader
of ConsensusFork.Deneb: denebData*: BeaconBlockHeader
ForkedBlindedBeaconBlock* = object
case kind*: ConsensusFork
@ -154,7 +154,7 @@ type
of ConsensusFork.Altair: altairData*: altair.BeaconBlock
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix_mev.BlindedBeaconBlock
of ConsensusFork.Capella: capellaData*: capella_mev.BlindedBeaconBlock
of ConsensusFork.Deneb: eip4844Data*: capella_mev.BlindedBeaconBlock
of ConsensusFork.Deneb: denebData*: capella_mev.BlindedBeaconBlock
ForkedTrustedBeaconBlock* = object
case kind*: ConsensusFork
@ -162,7 +162,7 @@ type
of ConsensusFork.Altair: altairData*: altair.TrustedBeaconBlock
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix.TrustedBeaconBlock
of ConsensusFork.Capella: capellaData*: capella.TrustedBeaconBlock
of ConsensusFork.Deneb: eip4844Data*: deneb.TrustedBeaconBlock
of ConsensusFork.Deneb: denebData*: deneb.TrustedBeaconBlock
ForkySignedBeaconBlock* =
phase0.SignedBeaconBlock |
@ -177,7 +177,7 @@ type
of ConsensusFork.Altair: altairData*: altair.SignedBeaconBlock
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix.SignedBeaconBlock
of ConsensusFork.Capella: capellaData*: capella.SignedBeaconBlock
of ConsensusFork.Deneb: eip4844Data*: deneb.SignedBeaconBlock
of ConsensusFork.Deneb: denebData*: deneb.SignedBeaconBlock
ForkySignedBlindedBeaconBlock* =
phase0.SignedBeaconBlock |
@ -191,7 +191,7 @@ type
of ConsensusFork.Altair: altairData*: altair.SignedBeaconBlock
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix_mev.SignedBlindedBeaconBlock
of ConsensusFork.Capella: capellaData*: capella_mev.SignedBlindedBeaconBlock
of ConsensusFork.Deneb: eip4844Data*: capella_mev.SignedBlindedBeaconBlock
of ConsensusFork.Deneb: denebData*: capella_mev.SignedBlindedBeaconBlock
ForkySigVerifiedSignedBeaconBlock* =
phase0.SigVerifiedSignedBeaconBlock |
@ -220,7 +220,7 @@ type
of ConsensusFork.Altair: altairData*: altair.MsgTrustedSignedBeaconBlock
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix.MsgTrustedSignedBeaconBlock
of ConsensusFork.Capella: capellaData*: capella.MsgTrustedSignedBeaconBlock
of ConsensusFork.Deneb: eip4844Data*: deneb.MsgTrustedSignedBeaconBlock
of ConsensusFork.Deneb: denebData*: deneb.MsgTrustedSignedBeaconBlock
ForkedTrustedSignedBeaconBlock* = object
case kind*: ConsensusFork
@ -228,7 +228,7 @@ type
of ConsensusFork.Altair: altairData*: altair.TrustedSignedBeaconBlock
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix.TrustedSignedBeaconBlock
of ConsensusFork.Capella: capellaData*: capella.TrustedSignedBeaconBlock
of ConsensusFork.Deneb: eip4844Data*: deneb.TrustedSignedBeaconBlock
of ConsensusFork.Deneb: denebData*: deneb.TrustedSignedBeaconBlock
SomeForkySignedBeaconBlock* =
ForkySignedBeaconBlock |
@ -312,7 +312,7 @@ func new*(T: type ForkedHashedBeaconState, data: capella.BeaconState):
data: data, root: hash_tree_root(data)))
func new*(T: type ForkedHashedBeaconState, data: deneb.BeaconState):
ref ForkedHashedBeaconState =
(ref T)(kind: ConsensusFork.Deneb, eip4844Data: deneb.HashedBeaconState(
(ref T)(kind: ConsensusFork.Deneb, denebData: deneb.HashedBeaconState(
data: data, root: hash_tree_root(data)))
template init*(T: type ForkedBeaconBlock, blck: phase0.BeaconBlock): T =
@ -324,7 +324,7 @@ template init*(T: type ForkedBeaconBlock, blck: bellatrix.BeaconBlock): T =
template init*(T: type ForkedBeaconBlock, blck: capella.BeaconBlock): T =
T(kind: ConsensusFork.Capella, capellaData: blck)
template init*(T: type ForkedBeaconBlock, blck: deneb.BeaconBlock): T =
T(kind: ConsensusFork.Deneb, eip4844Data: blck)
T(kind: ConsensusFork.Deneb, denebData: blck)
template init*(T: type ForkedTrustedBeaconBlock, blck: phase0.TrustedBeaconBlock): T =
T(kind: ConsensusFork.Phase0, phase0Data: blck)
@ -344,7 +344,7 @@ template init*(T: type ForkedSignedBeaconBlock, blck: bellatrix.SignedBeaconBloc
template init*(T: type ForkedSignedBeaconBlock, blck: capella.SignedBeaconBlock): T =
T(kind: ConsensusFork.Capella, capellaData: blck)
template init*(T: type ForkedSignedBeaconBlock, blck: deneb.SignedBeaconBlock): T =
T(kind: ConsensusFork.Deneb, eip4844Data: blck)
T(kind: ConsensusFork.Deneb, denebData: blck)
func init*(T: type ForkedSignedBeaconBlock, forked: ForkedBeaconBlock,
blockRoot: Eth2Digest, signature: ValidatorSig): T =
@ -371,9 +371,9 @@ func init*(T: type ForkedSignedBeaconBlock, forked: ForkedBeaconBlock,
signature: signature))
of ConsensusFork.Deneb:
T(kind: ConsensusFork.Deneb,
eip4844Data: deneb.SignedBeaconBlock(message: forked.eip4844Data,
root: blockRoot,
signature: signature))
denebData: deneb.SignedBeaconBlock(message: forked.denebData,
root: blockRoot,
signature: signature))
func init*(T: type ForkedSignedBlindedBeaconBlock,
forked: ForkedBlindedBeaconBlock, blockRoot: Eth2Digest,
@ -400,8 +400,8 @@ func init*(T: type ForkedSignedBlindedBeaconBlock,
of ConsensusFork.Deneb:
discard $denebImplementationMissing & "forks.nim:init(T: type ForkedSignedBlindedBeaconBlock)"
T(kind: ConsensusFork.Deneb,
eip4844Data: capella_mev.SignedBlindedBeaconBlock(message: forked.eip4844Data,
signature: signature))
denebData: capella_mev.SignedBlindedBeaconBlock(message: forked.denebData,
signature: signature))
template init*(T: type ForkedMsgTrustedSignedBeaconBlock, blck: phase0.MsgTrustedSignedBeaconBlock): T =
T(kind: ConsensusFork.Phase0, phase0Data: blck)
@ -412,7 +412,7 @@ template init*(T: type ForkedMsgTrustedSignedBeaconBlock, blck: bellatrix.MsgTru
template init*(T: type ForkedMsgTrustedSignedBeaconBlock, blck: capella.MsgTrustedSignedBeaconBlock): T =
T(kind: ConsensusFork.Capella, capellaData: blck)
template init*(T: type ForkedMsgTrustedSignedBeaconBlock, blck: deneb.MsgTrustedSignedBeaconBlock): T =
T(kind: ConsensusFork.Deneb, eip4844Data: blck)
T(kind: ConsensusFork.Deneb, eip4844Data: blck)
template init*(T: type ForkedTrustedSignedBeaconBlock, blck: phase0.TrustedSignedBeaconBlock): T =
T(kind: ConsensusFork.Phase0, phase0Data: blck)
@ -423,7 +423,7 @@ template init*(T: type ForkedTrustedSignedBeaconBlock, blck: bellatrix.TrustedSi
template init*(T: type ForkedTrustedSignedBeaconBlock, blck: capella.TrustedSignedBeaconBlock): T =
T(kind: ConsensusFork.Capella, capellaData: blck)
template init*(T: type ForkedTrustedSignedBeaconBlock, blck: deneb.TrustedSignedBeaconBlock): T =
T(kind: ConsensusFork.Deneb, eip4844Data: blck)
T(kind: ConsensusFork.Deneb, denebData: blck)
template toString*(kind: ConsensusFork): string =
case kind
@ -526,7 +526,7 @@ template withState*(x: ForkedHashedBeaconState, body: untyped): untyped =
case x.kind
of ConsensusFork.Deneb:
const stateFork {.inject, used.} = ConsensusFork.Deneb
template forkyState: untyped {.inject, used.} = x.eip4844Data
template forkyState: untyped {.inject, used.} = x.denebData
body
of ConsensusFork.Capella:
const stateFork {.inject, used.} = ConsensusFork.Capella
@ -578,7 +578,7 @@ func assign*(tgt: var ForkedHashedBeaconState, src: ForkedHashedBeaconState) =
if tgt.kind == src.kind:
case tgt.kind
of ConsensusFork.Deneb:
assign(tgt.eip4844Data, src.eip4844Data):
assign(tgt.denebData, src.denebData):
of ConsensusFork.Capella:
assign(tgt.capellaData, src.capellaData):
of ConsensusFork.Bellatrix:
@ -599,7 +599,7 @@ template getStateField*(x: ForkedHashedBeaconState, y: untyped): untyped =
# ```
# Without `unsafeAddr`, the `validators` list would be copied to a temporary variable.
(case x.kind
of ConsensusFork.Deneb: unsafeAddr x.eip4844Data.data.y
of ConsensusFork.Deneb: unsafeAddr x.denebData.data.y
of ConsensusFork.Capella: unsafeAddr x.capellaData.data.y
of ConsensusFork.Bellatrix: unsafeAddr x.bellatrixData.data.y
of ConsensusFork.Altair: unsafeAddr x.altairData.data.y
@ -722,7 +722,7 @@ template withBlck*(
body
of ConsensusFork.Deneb:
const stateFork {.inject, used.} = ConsensusFork.Deneb
template blck: untyped {.inject.} = x.eip4844Data
template blck: untyped {.inject.} = x.denebData
body
func proposer_index*(x: ForkedBeaconBlock): uint64 =
@ -743,7 +743,7 @@ template getForkedBlockField*(
of ConsensusFork.Altair: unsafeAddr x.altairData.message.y
of ConsensusFork.Bellatrix: unsafeAddr x.bellatrixData.message.y
of ConsensusFork.Capella: unsafeAddr x.capellaData.message.y
of ConsensusFork.Deneb: unsafeAddr x.eip4844Data.message.y)[]
of ConsensusFork.Deneb: unsafeAddr x.denebData.message.y)[]
template signature*(x: ForkedSignedBeaconBlock |
ForkedMsgTrustedSignedBeaconBlock |
@ -786,8 +786,8 @@ template withStateAndBlck*(
case s.kind
of ConsensusFork.Deneb:
const stateFork {.inject.} = ConsensusFork.Deneb
template forkyState: untyped {.inject.} = s.eip4844Data
template blck: untyped {.inject.} = b.eip4844Data
template forkyState: untyped {.inject.} = s.denebData
template blck: untyped {.inject.} = b.denebData
body
of ConsensusFork.Capella:
const stateFork {.inject.} = ConsensusFork.Capella

View File

@ -212,7 +212,7 @@ func maybeUpgradeStateToEIP4844(
let newState = upgrade_to_eip4844(cfg, state.capellaData.data)
state = (ref ForkedHashedBeaconState)(
kind: ConsensusFork.Deneb,
eip4844Data: deneb.HashedBeaconState(
denebData: deneb.HashedBeaconState(
root: hash_tree_root(newState[]), data: newState[]))[]
func maybeUpgradeState*(
@ -607,7 +607,7 @@ proc makeBeaconBlock*[T: bellatrix.ExecutionPayload | capella.ExecutionPayload |
of ConsensusFork.Phase0, ConsensusFork.Altair,
ConsensusFork.Bellatrix, ConsensusFork.Capella:
raiseAssert "Attempt to use EIP4844 payload with non-EIP4844 state"
of ConsensusFork.Deneb: makeBeaconBlock(eip4844)
of ConsensusFork.Deneb: makeBeaconBlock(deneb)
# workaround for https://github.com/nim-lang/Nim/issues/20900 rather than have
# these be default arguments

View File

@ -464,7 +464,7 @@ proc getBlockSignature*(v: AttachedValidator, fork: Fork,
of ConsensusFork.Deneb:
Web3SignerForkedBeaconBlock(
kind: ConsensusFork.Deneb,
eip4844Data: blck.eip4844Data.toBeaconBlockHeader)
denebData: blck.denebData.toBeaconBlockHeader)
request = Web3SignerRequest.init(
fork, genesis_validators_root, web3SignerBlock)
@ -506,7 +506,7 @@ proc getBlockSignature*(v: AttachedValidator, fork: Fork,
of ConsensusFork.Deneb:
Web3SignerForkedBeaconBlock(
kind: ConsensusFork.Deneb,
eip4844Data: blck.eip4844Data.toBeaconBlockHeader)
denebData: blck.denebData.toBeaconBlockHeader)
request = Web3SignerRequest.init(
fork, genesis_validators_root, web3SignerBlock)

View File

@ -85,7 +85,7 @@ template saveSSZFile(filename: string, value: ForkedHashedBeaconState) =
of ConsensusFork.Altair: SSZ.saveFile(filename, value.altairData.data)
of ConsensusFork.Bellatrix: SSZ.saveFile(filename, value.bellatrixData.data)
of ConsensusFork.Capella: SSZ.saveFile(filename, value.capellaData.data)
of ConsensusFork.Deneb: SSZ.saveFile(filename, value.eip4844Data.data)
of ConsensusFork.Deneb: SSZ.saveFile(filename, value.denebData.data)
proc loadFile(filename: string, T: type): T =
let

View File

@ -501,7 +501,7 @@ cli do(slots = SLOTS_PER_EPOCH * 6,
elif T is capella.SignedBeaconBlock:
addr state.capellaData
elif T is eip4844.SignedBeaconBlock:
addr state.eip4844Data
addr state.denebData
else:
static: doAssert false
message = makeBeaconBlock(

View File

@ -205,9 +205,9 @@ cli do(validatorsDir: string, secretsDir: string,
validators[proposer]).toValidatorSig())
dump(".", signedBlock)
of ConsensusFork.Deneb:
blockRoot = hash_tree_root(message.eip4844Data)
blockRoot = hash_tree_root(message.denebData)
let signedBlock = eip4844.SignedBeaconBlock(
message: message.eip4844Data,
message: message.denebData,
root: blockRoot,
signature: get_block_signature(
fork, genesis_validators_root, slot, blockRoot,

View File

@ -131,8 +131,8 @@ proc loadForkedState*(
of ConsensusFork.Deneb:
let state = newClone(parseTest(path, SSZ, deneb.BeaconState))
forkedState = (ref ForkedHashedBeaconState)(kind: ConsensusFork.Deneb)
forkedState.eip4844Data.data = state[]
forkedState.eip4844Data.root = hash_tree_root(state[])
forkedState.denebData.data = state[]
forkedState.denebData.root = hash_tree_root(state[])
of ConsensusFork.Capella:
let state = newClone(parseTest(path, SSZ, capella.BeaconState))
forkedState = (ref ForkedHashedBeaconState)(kind: ConsensusFork.Capella)

View File

@ -444,8 +444,8 @@ suite "Beacon chain DB" & preset():
let db = makeTestDB(SLOTS_PER_EPOCH)
for state in testStatesEIP4844:
let root = state[].eip4844Data.root
db.putState(root, state[].eip4844Data.data)
let root = state[].denebData.root
db.putState(root, state[].denebData.data)
check:
db.containsState(root)
@ -543,8 +543,8 @@ suite "Beacon chain DB" & preset():
let stateBuffer = (eip4844.BeaconStateRef)()
for state in testStatesEIP4844:
let root = state[].eip4844Data.root
db.putState(root, state[].eip4844Data.data)
let root = state[].denebData.root
db.putState(root, state[].denebData.data)
check:
db.getState(root, stateBuffer[], noRollback)
@ -666,7 +666,7 @@ suite "Beacon chain DB" & preset():
dag = init(ChainDAGRef, defaultRuntimeConfig, db, validatorMonitor, {})
state = (ref ForkedHashedBeaconState)(
kind: ConsensusFork.Deneb,
eip4844Data: eip4844.HashedBeaconState(data: eip4844.BeaconState(
denebData: eip4844.HashedBeaconState(data: eip4844.BeaconState(
slot: 10.Slot)))
root = Eth2Digest()
@ -678,8 +678,8 @@ suite "Beacon chain DB" & preset():
assign(state[], restoreAddr[])
check:
state[].eip4844Data.data.slot == 10.Slot
not db.getState(root, state[].eip4844Data.data, restore)
state[].denebData.data.slot == 10.Slot
not db.getState(root, state[].denebData.data, restore)
# assign() has switched the case object fork
state[].kind == ConsensusFork.Phase0

View File

@ -213,7 +213,7 @@ suite "Gossip validation - Extra": # Not based on preset config
dag.addHeadBlock(verifier, blck.capellaData, nilCallback)
of ConsensusFork.Deneb:
const nilCallback = OnEIP4844BlockAdded(nil)
dag.addHeadBlock(verifier, blck.eip4844Data, nilCallback)
dag.addHeadBlock(verifier, blck.denebData, nilCallback)
check: added.isOk()
dag.updateHead(added[], quarantine[], [])
dag

View File

@ -78,7 +78,7 @@ suite "Light client" & preset():
dag.addHeadBlock(verifier, blck.capellaData, nilCallback)
of ConsensusFork.Deneb:
const nilCallback = OnEIP4844BlockAdded(nil)
dag.addHeadBlock(verifier, blck.eip4844Data, nilCallback)
dag.addHeadBlock(verifier, blck.denebData, nilCallback)
check: added.isOk()
dag.updateHead(added[], quarantine, [])

View File

@ -65,7 +65,7 @@ suite "Light client processor" & preset():
dag.addHeadBlock(verifier, blck.capellaData, nilCallback)
of ConsensusFork.Deneb:
const nilCallback = OnEIP4844BlockAdded(nil)
dag.addHeadBlock(verifier, blck.eip4844Data, nilCallback)
dag.addHeadBlock(verifier, blck.denebData, nilCallback)
doAssert added.isOk()
dag.updateHead(added[], quarantine[], [])