@@ -29,25 +29,25 @@ def test_bloatnet(blockchain_test: BlockchainTestFiller, pre: Alloc, fork: Fork)
29
29
storage = {}
30
30
GasLimit = 30_000_000 # Default gas limit seems to be >90M in this env
31
31
32
- totalgas = gas_costs .G_BASE * 2 # Initial gas for PUSH0 + POP
32
+ totalgas = gas_costs .G_BASE * 2 # Initial gas for PUSH0 + CALLDATALOAD
33
33
gas_increment = gas_costs .G_VERY_LOW * 2 + gas_costs .G_STORAGE_SET + gas_costs .G_COLD_SLOAD
34
- sstore_code = Op .PUSH0
34
+ sstore_code = Op .PUSH0 + Op . CALLDATALOAD + Op . DUP1
35
35
i = 0
36
36
while totalgas + gas_increment < GasLimit :
37
37
totalgas += gas_increment
38
- print (f"increment={ gas_increment } < totalgas={ totalgas } i={ i } " )
39
- sstore_code = sstore_code + Op .PUSH1 ( 1 )
38
+ # print(f"increment={gas_increment} < totalgas={totalgas} i={i}")
39
+ sstore_code = sstore_code + Op .DUP1
40
40
if i < 256 :
41
41
sstore_code = sstore_code + Op .PUSH1 (i )
42
42
else :
43
43
sstore_code = sstore_code + Op .PUSH2 (i )
44
44
45
45
sstore_code = sstore_code + Op .SSTORE (unchecked = True )
46
46
47
- storage [storage_slot ] = 0x1
47
+ storage [storage_slot ] = 0x02 << 248
48
48
storage_slot += 1
49
49
i += 1
50
- sstore_code = sstore_code + Op .POP
50
+ sstore_code = sstore_code + Op .POP # Drop last value on the stack
51
51
52
52
sender = pre .fund_eoa ()
53
53
print (sender )
@@ -59,17 +59,18 @@ def test_bloatnet(blockchain_test: BlockchainTestFiller, pre: Alloc, fork: Fork)
59
59
tx_0_1 = Transaction (
60
60
to = contract_address ,
61
61
gas_limit = GasLimit ,
62
- data = b"" ,
62
+ data = b'\x01 ' , # Single byte 0x01
63
+ value = 0 ,
64
+ sender = sender ,
65
+ )
66
+ tx_1_2 = Transaction (
67
+ to = contract_address ,
68
+ gas_limit = 30000000 ,
69
+ data = b'\x02 ' , # Single byte 0x02, turns into 0x2000000000000000000000000000000000000000000000000000000000000000
63
70
value = 0 ,
64
71
sender = sender ,
65
72
)
66
- # tx_1_2 = Transaction(
67
- # to=contract_address,
68
- # gas_limit=30000000,
69
- # data=b"",
70
- # value=0,
71
- # sender=sender,
72
- # )
73
73
74
74
post = {contract_address : Account (storage = storage )}
75
- blockchain_test (pre = pre , blocks = [Block (txs = [tx_0_1 ])], post = post )
75
+
76
+ blockchain_test (pre = pre , blocks = [Block (txs = [tx_0_1 , tx_1_2 ])], post = post )
0 commit comments