Skip to content

Commit

Permalink
Merge pull request #192 from carver/constant-block-gas
Browse files Browse the repository at this point in the history
Make gas limit constant
  • Loading branch information
carver authored Jun 1, 2020
2 parents e7a3fbf + c140e63 commit 171dce6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
Unreleased
-------------

- Breaking changes

- Make gas limit constant for py-evm backend
https://github.com/ethereum/eth-tester/pull/192

- Features

- Add support for gas estimate block identifiers
https://github.com/ethereum/eth-tester/pull/189
- Add support for custom virtual machine fork schedule in PyEVMBackend
https://github.com/ethereum/eth-tester/pull/191


v0.4.0-beta.2
-------------
Expand Down
10 changes: 9 additions & 1 deletion eth_tester/backends/pyevm/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,15 @@ def setup_tester_chain(
consensus_applier = ConsensusApplier(NoProofConsensus)
no_proof_vms = consensus_applier.amend_vm_configuration(vm_configuration)

MainnetTesterNoProofChain = MiningChain.configure(vm_configuration=no_proof_vms)
class MainnetTesterNoProofChain(MiningChain):
vm_configuration = no_proof_vms

def create_header_from_parent(self, parent_header, **header_params):
# Keep the gas limit constant
return super().create_header_from_parent(
parent_header,
**assoc(header_params, 'gas_limit', parent_header.gas_limit)
)

if genesis_params is None:
genesis_params = get_default_genesis_params()
Expand Down
7 changes: 7 additions & 0 deletions eth_tester/utils/backend_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,13 @@ def test_mine_multiple_blocks(self, eth_tester):
assert is_integer(after_block_number)
assert before_block_number == after_block_number - 10

def test_gas_limit_constant(self, eth_tester):
eth_tester.mine_blocks()
before_gas_limit = eth_tester.get_block_by_number('latest')['gas_limit']
eth_tester.mine_blocks()
after_gas_limit = eth_tester.get_block_by_number('latest')['gas_limit']
assert before_gas_limit == after_gas_limit

#
# Transaction Sending
#
Expand Down
2 changes: 1 addition & 1 deletion tests/backends/test_pyevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def test_override_genesis_parameters(self):

# Establish a custom gas limit
param_overrides = {"gas_limit": 4750000}
block_one_gas_limit = 4745362
block_one_gas_limit = param_overrides['gas_limit']

# Initialize PyEVM backend with custom genesis parameters
genesis_params = PyEVMBackend._generate_genesis_params(
Expand Down

0 comments on commit 171dce6

Please sign in to comment.