Revert "finalizing state_transition (#792)"
This reverts commit 91d75bdfdd
.
This commit is contained in:
parent
cf2dd002f6
commit
a327c82820
|
@ -373,6 +373,7 @@ proc add*(
|
|||
# TODO if the block is from the future, we should not be resolving it (yet),
|
||||
# but maybe we should use it as a hint that our clock is wrong?
|
||||
updateStateData(pool, pool.tmpState, BlockSlot(blck: parent, slot: blck.slot - 1))
|
||||
|
||||
if not state_transition(pool.tmpState.data, signedBlock, {}):
|
||||
# TODO find a better way to log all this block data
|
||||
notice "Invalid block",
|
||||
|
@ -381,6 +382,7 @@ proc add*(
|
|||
cat = "filtering"
|
||||
|
||||
return
|
||||
|
||||
# Careful, tmpState.data has been updated but not blck - we need to create
|
||||
# the BlockRef first!
|
||||
pool.tmpState.blck = pool.addResolvedBlock(
|
||||
|
|
|
@ -151,7 +151,7 @@ func compute_signing_root*(ssz_object: auto, domain: Domain): Eth2Digest =
|
|||
# object-domain tree.
|
||||
let domain_wrapped_object = SigningRoot(
|
||||
object_root: hash_tree_root(ssz_object),
|
||||
domain: bytes_to_int(domain)
|
||||
domain: domain
|
||||
)
|
||||
hash_tree_root(domain_wrapped_object)
|
||||
|
||||
|
|
|
@ -31,9 +31,9 @@
|
|||
# now.
|
||||
|
||||
import
|
||||
collections/sets, chronicles, sets, options,
|
||||
collections/sets, chronicles, sets,
|
||||
./extras, ./ssz, metrics,
|
||||
./spec/[datatypes, crypto, digest, helpers, validator],
|
||||
./spec/[datatypes, digest, helpers, validator],
|
||||
./spec/[state_transition_block, state_transition_epoch],
|
||||
../nbench/bench_lab
|
||||
|
||||
|
@ -101,19 +101,6 @@ proc process_slots*(state: var BeaconState, slot: Slot) {.nbench.}=
|
|||
if is_epoch_transition:
|
||||
beacon_current_validators.set(get_epoch_validator_count(state))
|
||||
|
||||
#https://github.com/ethereum/eth2.0-specs/blob/v0.10.1/specs/phase0/beacon-chain.md#verify_block_signature
|
||||
proc verify_block_signature*(state: var BeaconState, signedBlock: SignedBeaconBlock, stateCache: var StateCache): bool {.nbench.} =
|
||||
let proposer = state.validators[get_beacon_proposer_index(state, stateCache).get]
|
||||
let domain = get_domain(state, DOMAIN_BEACON_PROPOSER, compute_epoch_at_slot(signedBlock.message.slot))
|
||||
# TODO This will need to be changed for:
|
||||
# ```
|
||||
# let signing_root = compute_signing_root(signedBlock.message,domain)
|
||||
# return bls_verify(proposer.pubKey, signing_root.data, signedBlock.signature, domain)
|
||||
# ```
|
||||
# when https://github.com/status-im/nim-beacon-chain/pull/780 is merged
|
||||
return bls_verify(proposer.pubKey, hash_tree_root(signedBlock.message).data, signedBlock.signature, domain)
|
||||
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.4/specs/core/0_beacon-chain.md#beacon-chain-state-transition-function
|
||||
proc verifyStateRoot(state: BeaconState, blck: BeaconBlock): bool =
|
||||
# This is inlined in state_transition(...) in spec.
|
||||
|
@ -170,10 +157,6 @@ proc state_transition*(
|
|||
# https://github.com/ethereum/eth2.0-specs/issues/293
|
||||
var per_epoch_cache = get_empty_per_epoch_cache()
|
||||
|
||||
if skipBLSValidation notin flags and not verify_block_signature(state, signedBlock, per_epoch_cache):
|
||||
state = old_state
|
||||
return false
|
||||
|
||||
if processBlock(state, signedBlock.message, flags, per_epoch_cache):
|
||||
# This is a bit awkward - at the end of processing we verify that the
|
||||
# state we arrive at is what the block producer thought it would be -
|
||||
|
@ -241,10 +224,6 @@ proc state_transition*(
|
|||
process_slots(state, signedBlock.message.slot)
|
||||
var per_epoch_cache = get_empty_per_epoch_cache()
|
||||
|
||||
if skipBLSValidation notin flags and not verify_block_signature(state.data, signedBlock, per_epoch_cache):
|
||||
state = old_state
|
||||
return false
|
||||
|
||||
if processBlock(state.data, signedBlock.message, flags, per_epoch_cache):
|
||||
if skipStateRootValidation in flags or verifyStateRoot(state.data, signedBlock.message):
|
||||
# State root is what it should be - we're done!
|
||||
|
|
Loading…
Reference in New Issue