Skip to content

Commit

Permalink
Demo issues 1961 and 1962
Browse files Browse the repository at this point in the history
  • Loading branch information
gsalgado committed Nov 6, 2020
1 parent 5b17702 commit 3b79b35
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion eth/vm/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def finalize_block(self, block: BlockAPI) -> BlockAndMetaWitness:

final_block = block.copy(header=block.header.copy(state_root=self.state.state_root))

self.logger.debug(
self.logger.info(
"%s reads %d unique node hashes, %d addresses, %d bytecodes, and %d storage slots",
final_block,
len(meta_witness.hashes),
Expand Down
3 changes: 2 additions & 1 deletion tests/core/chain-object/test_build_block_incrementally.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def test_building_block_incrementally_with_single_transaction(
# test that the *latest* block hasn't changed
assert chain.get_canonical_head().hash == head_hash

mined_block = chain.mine_block()
mined_block, meta_witness = chain.mine_block_extended()
assert len(meta_witness.hashes) == 2
assert len(mined_block.transactions) == 1

actual_tx = mined_block.transactions[0]
Expand Down
25 changes: 25 additions & 0 deletions tests/core/consensus/test_clique_consensus.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,31 @@ def test_validate_chain_works_across_forks(paragon_chain):
paragon_chain.validate_chain_extension((PARAGON_GENESIS_HEADER,) + voting_chain)


def test_building_block_incrementally(paragon_chain):
extra_data_len = VANITY_LENGTH + SIGNATURE_LENGTH
header = paragon_chain.header.copy(extra_data=extra_data_len * b'0')
# XXX: Comment out the two lines below and the test will fail.
# This is a quick hack to demonstrate what needs to be done in order to incrementally build
# clique blocks; what we probably need is an API to set the signer before we start building
paragon_chain.header = sign_block_header(header, ALICE_PK)
assert get_block_signer(paragon_chain.header) == ALICE

tx = new_transaction(paragon_chain.get_vm(), ALICE, BOB, 10, ALICE_PK)
_, _, computation = paragon_chain.apply_transaction(tx)
computation.raise_if_error()
signed_header = sign_block_header(
paragon_chain.header.copy(extra_data=extra_data_len * b'0', difficulty=2, nonce=NONCE_DROP),
ALICE_PK)
mined_block, meta_witness = paragon_chain.mine_block_extended(
extra_data=signed_header.extra_data, difficulty=2, nonce=NONCE_DROP)
state_root = b'\x99\xaa\xf5CF^\x95_\xce~\xe4)\x00\xb1zr\x1dr\xd6\x00N^\xa6\xdc\xc41\x90~\xb7te\x00' # noqa: E501
assert mined_block.header.state_root == state_root

# XXX: This should not be empty, just like it is not when using PoW chains
# (tests/core/chain-object/test_build_block_incrementally.py)
assert len(meta_witness.hashes) == 0


def test_import_block(paragon_chain):

vm = paragon_chain.get_vm()
Expand Down

0 comments on commit 3b79b35

Please sign in to comment.