Skip to content

Commit 06b1428

Browse files
committed
Add London opcode tests
Validation of London header gas limit was missing, which caused an infinite loop when trying to fill up a block (it never filled!). So, added validation of London headers: gas_used <= gas_limit
1 parent 80b9de2 commit 06b1428

File tree

3 files changed

+77
-2
lines changed

3 files changed

+77
-2
lines changed

eth/vm/forks/london/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ class LondonVM(BerlinVM):
3636
all_header_sedes: Type[BlockHeaderSedesAPI] = LondonBackwardsHeader
3737

3838
# Methods
39-
# skip header validation: validate everything in the executor as we need state access
40-
validate_transaction_against_header = lambda *_: None # type: ignore
4139
create_header_from_parent = staticmethod(create_london_header_from_parent) # type: ignore
4240
compute_difficulty = staticmethod(compute_london_difficulty) # type: ignore
4341
# configure_header = configure_berlin_header

tests/core/chain-object/test_gas_estimation.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,78 @@
755755
22272,
756756
id='sha3 precompile 32 bytes 1000_tolerance binary pending for BerlinVM',
757757
),
758+
pytest.param(
759+
b'',
760+
None,
761+
ADDR_1010,
762+
True,
763+
LondonVM,
764+
21000,
765+
id='simple default pending for LondonVM',
766+
),
767+
pytest.param(
768+
b'',
769+
None,
770+
ADDR_1010,
771+
False,
772+
LondonVM,
773+
21000,
774+
id='simple default for LondonVM',
775+
),
776+
pytest.param(
777+
b'\xff' * 10,
778+
None,
779+
ADDR_1010,
780+
True,
781+
LondonVM,
782+
21160,
783+
id='10 bytes default pending for LondonVM',
784+
),
785+
pytest.param(
786+
b'\xff' * 10,
787+
None,
788+
ADDR_1010,
789+
False,
790+
LondonVM,
791+
21160,
792+
id='10 bytes default for LondonVM',
793+
),
794+
pytest.param(
795+
b'\xff' * 32,
796+
None,
797+
ADDRESS_2,
798+
True,
799+
LondonVM,
800+
33675,
801+
id='sha3 precompile 32 bytes default pending for LondonVM',
802+
),
803+
pytest.param(
804+
b'\xff' * 32,
805+
None,
806+
ADDRESS_2,
807+
False,
808+
LondonVM,
809+
33687,
810+
id='sha3 precompile 32 bytes default for LondonVM',
811+
),
812+
pytest.param(
813+
b'\xff' * 320,
814+
None,
815+
ADDRESS_2,
816+
True,
817+
LondonVM,
818+
38265,
819+
id='sha3 precompile 320 bytes default pending for LondonVM',
820+
),
821+
pytest.param(
822+
b'\xff' * 32,
823+
binary_gas_search_1000_tolerance,
824+
ADDRESS_2,
825+
True,
826+
LondonVM,
827+
22272,
828+
id='sha3 precompile 32 bytes 1000_tolerance binary pending for LondonVM',
829+
),
758830
),
759831
)
760832
def test_estimate_gas(
@@ -816,6 +888,7 @@ def test_estimate_gas(
816888
(IstanbulVM, 186120),
817889
(MuirGlacierVM, 186120),
818890
(BerlinVM, 186120),
891+
(LondonVM, 186120),
819892
)
820893
)
821894
def test_estimate_gas_on_full_block(

tests/core/helpers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,9 @@ def fill_block(chain, from_, key, gas, data):
3636
break
3737
else:
3838
raise exc
39+
else:
40+
new_header = chain.get_vm().get_block().header
41+
assert new_header.gas_used > 0
42+
assert new_header.gas_used <= new_header.gas_limit
3943

4044
assert chain.get_vm().get_block().header.gas_used > 0

0 commit comments

Comments
 (0)