test: Properly clear storage dirty flag

Clear storage dirty flag between transactions in EVMHost. The EIP-2200
dirty flag should be persisted only in a single transaction.
This commit is contained in:
Paweł Bylica 2022-11-08 17:07:36 +01:00 committed by Paweł Bylica
parent d472c94ff6
commit c4b6f5f00b
No known key found for this signature in database
GPG Key ID: 7A0C037434FE77EF
26 changed files with 132 additions and 106 deletions

View File

@ -174,10 +174,13 @@ void EVMHost::newTransactionFrame()
{
// Clear EIP-2929 account access indicator
recorded_account_accesses.clear();
// Clear EIP-2929 storage access indicator
for (auto& [address, account]: accounts)
for (auto& [slot, value]: account.storage)
value.access_status = EVMC_ACCESS_COLD;
{
value.access_status = EVMC_ACCESS_COLD; // Clear EIP-2929 storage access indicator
value.dirty = false; // Clear EIP-2200 dirty slot flag
}
// Process selfdestruct list
for (auto& [address, _]: recorded_selfdestructs)
accounts.erase(address);

View File

@ -39,4 +39,4 @@ contract C is B {
// ----
// test() -> 5, 10
// gas irOptimized: 87337
// gas legacy: 98881
// gas legacy: 104481

View File

@ -46,8 +46,8 @@ contract c {
// storageEmpty -> 0
// test_long() -> 67
// gas irOptimized: 89148
// gas legacy: 103039
// gas legacyOptimized: 100493
// gas legacy: 105839
// gas legacyOptimized: 103293
// storageEmpty -> 0
// test_pop() -> 1780731860627700044960722568376592200742329637303199754547598369979433020
// gas legacy: 61930

View File

@ -40,7 +40,7 @@ contract c {
// gas legacyOptimized: 4548309
// storageEmpty -> 1
// clear() -> 0, 0
// gas irOptimized: 4477223
// gas legacy: 4410748
// gas legacyOptimized: 4382489
// gas irOptimized: 4517023
// gas legacy: 4450548
// gas legacyOptimized: 4422289
// storageEmpty -> 1

View File

@ -44,6 +44,6 @@ contract Test {
// test1() -> 3
// test2() -> 6
// test3() -> 24
// gas irOptimized: 133260
// gas legacy: 134283
// gas legacyOptimized: 133393
// gas irOptimized: 155660
// gas legacy: 156683
// gas legacyOptimized: 155793

View File

@ -21,21 +21,21 @@ contract c {
// gas legacy: 124296
// gas legacyOptimized: 119119
// f(uint256): 32 -> 0x20, 0x20, 1780731860627700044960722568376592200742329637303199754547598369979440671
// gas irOptimized: 118565
// gas legacy: 135251
// gas legacyOptimized: 130091
// gas irOptimized: 124165
// gas legacy: 140851
// gas legacyOptimized: 135691
// f(uint256): 33 -> 0x20, 33, 1780731860627700044960722568376592200742329637303199754547598369979440671, 0x2000000000000000000000000000000000000000000000000000000000000000
// gas irOptimized: 125184
// gas legacy: 142835
// gas legacyOptimized: 137008
// gas irOptimized: 130784
// gas legacy: 148435
// gas legacyOptimized: 142608
// f(uint256): 63 -> 0x20, 0x3f, 1780731860627700044960722568376592200742329637303199754547598369979440671, 14532552714582660066924456880521368950258152170031413196862950297402215316992
// gas irOptimized: 128584
// gas legacy: 160875
// gas legacyOptimized: 150938
// gas irOptimized: 139784
// gas legacy: 172075
// gas legacyOptimized: 162138
// f(uint256): 12 -> 0x20, 0x0c, 0x0102030405060708090a0b0000000000000000000000000000000000000000
// gas legacy: 59345
// gas legacyOptimized: 57279
// f(uint256): 129 -> 0x20, 0x81, 1780731860627700044960722568376592200742329637303199754547598369979440671, 0x202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f, 29063324697304692433803953038474361308315562010425523193971352996434451193439, 0x606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f, -57896044618658097711785492504343953926634992332820282019728792003956564819968
// gas irOptimized: 357699
// gas legacy: 421674
// gas legacyOptimized: 402977
// gas irOptimized: 442899
// gas legacy: 506874
// gas legacyOptimized: 488177

View File

@ -39,8 +39,8 @@ contract C {
// gas legacy: 181047
// gas legacyOptimized: 180029
// g() -> 0x40, 0xc0, 0x49, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738390000000000000000000000000000000000000000000000, 0x11, 0x3132333435363738393233343536373839000000000000000000000000000000
// gas irOptimized: 107097
// gas legacy: 110201
// gas legacyOptimized: 107353
// gas irOptimized: 121097
// gas legacy: 124201
// gas legacyOptimized: 121353
// h() -> 0x40, 0x60, 0x00, 0x00
// storageEmpty -> 1

View File

@ -51,6 +51,6 @@ contract C {
// gas legacyOptimized: 117021
// test2() -> 0x20, 0x14, "[b called][a called]"
// test3() -> 0x20, 0x14, "[b called][a called]"
// gas irOptimized: 103256
// gas legacy: 102814
// gas legacyOptimized: 101706
// gas irOptimized: 106056
// gas legacy: 105614
// gas legacyOptimized: 104506

View File

@ -19,6 +19,9 @@ contract c {
// gas legacyOptimized: 517027
// storageEmpty -> 0
// halfClear() ->
// gas irOptimized: 113961
// gas legacy: 113257
// gas legacyOptimized: 113120
// storageEmpty -> 0
// fullClear() ->
// storageEmpty -> 1

View File

@ -17,4 +17,7 @@ contract c {
// gas legacyOptimized: 467500
// storageEmpty -> 0
// clear() ->
// gas irOptimized: 122148
// gas legacy: 122440
// gas legacyOptimized: 122259
// storageEmpty -> 1

View File

@ -40,6 +40,9 @@ contract C {
// copyFromStorageShort()
// x() -> 0x20, 3, 0x6162630000000000000000000000000000000000000000000000000000000000
// copyFromStorageLong()
// gas irOptimized: 121130
// gas legacy: 121930
// gas legacyOptimized: 121408
// x() -> 0x20, 0x25, 0x3132333435363738393031323334353637383930313233343536373839303132, 0x3334353637000000000000000000000000000000000000000000000000000000
// copyToStorage()
// x() -> 0x20, 0x25, 0x3132333435363738393031323334353637383930313233343536373839303132, 0x3334353637000000000000000000000000000000000000000000000000000000

View File

@ -23,7 +23,7 @@ contract c {
}
// ----
// test() -> 1, 2, 3
// gas irOptimized: 2280147
// gas legacy: 2273434
// gas legacyOptimized: 2261844
// gas irOptimized: 2285747
// gas legacy: 2279034
// gas legacyOptimized: 2267444
// storageEmpty -> 1

View File

@ -34,8 +34,8 @@ contract C {
// ll(uint256): 0 -> 43
// a(uint256,uint256): 0, 42 -> 64
// f(uint256,uint256): 84, 128 ->
// gas irOptimized: 116264
// gas legacy: 107525
// gas irOptimized: 119064
// gas legacy: 110325
// gas legacyOptimized: 96331
// l() -> 2
// ll(uint256): 1 -> 85

View File

@ -22,6 +22,9 @@ contract Test {
// set(bytes): 0x20, 0
// storageEmpty -> 1
// set(bytes): 0x20, 66, "12345678901234567890123456789012", "12345678901234567890123456789012", "12"
// gas irOptimized: 111897
// gas legacy: 112756
// gas legacyOptimized: 112116
// storageEmpty -> 0
// set(bytes): 0x20, 3, "abc"
// storageEmpty -> 0

View File

@ -87,9 +87,9 @@ contract Test {
// EVMVersion: >homestead
// ----
// test1() -> true
// gas irOptimized: 150163
// gas legacy: 150266
// gas legacyOptimized: 149875
// gas irOptimized: 152963
// gas legacy: 153066
// gas legacyOptimized: 152675
// test2() -> true
// test3() -> true
// test4() -> true

View File

@ -31,6 +31,9 @@ contract c {
// copy() -> true
// storageEmpty -> 1
// set(uint256,bytes,uint256): 12, 0x60, 13, 33, "12345678901234567890123456789012", "3" -> true
// gas irOptimized: 133599
// gas legacy: 134654
// gas legacyOptimized: 133882
// storageEmpty -> 0
// del() -> true
// storageEmpty -> 1

View File

@ -46,3 +46,6 @@ contract C {
// gas legacy: 122132
// gas legacyOptimized: 121500
// g() ->
// gas irOptimized: 145472
// gas legacy: 145707
// gas legacyOptimized: 144940

View File

@ -53,9 +53,9 @@ contract C {
// gas legacy: 126150
// gas legacyOptimized: 123163
// test_g() -> true
// gas irOptimized: 95980
// gas legacy: 101281
// gas legacyOptimized: 96566
// gas irOptimized: 106138
// gas legacy: 112481
// gas legacyOptimized: 107706
// addresses(uint256): 0 -> 0x18
// addresses(uint256): 1 -> 0x19
// addresses(uint256): 3 -> 0x1b

View File

@ -34,6 +34,6 @@ contract C {
// ----
// f(bytes): 0x20, 0x5, "abcde" -> 0
// gas irOptimized: 239090
// gas legacy: 240541
// gas legacyOptimized: 239654
// gas irOptimized: 241890
// gas legacy: 243341
// gas legacyOptimized: 242454

View File

@ -16,33 +16,38 @@ contract C {
// ----
// test_indices(uint256): 1 ->
// test_indices(uint256): 129 ->
// gas irOptimized: 3018684
// gas legacy: 3068883
// gas legacyOptimized: 3011615
// gas irOptimized: 3021484
// gas legacy: 3071683
// gas legacyOptimized: 3014415
// test_indices(uint256): 5 ->
// gas irOptimized: 372540
// gas legacy: 369151
// gas legacyOptimized: 366139
// gas irOptimized: 722540
// gas legacy: 719151
// gas legacyOptimized: 716139
// test_indices(uint256): 10 ->
// gas irOptimized: 158407
// gas legacy: 162657
// gas legacyOptimized: 158422
// test_indices(uint256): 15 ->
// gas irOptimized: 72860
// gas irOptimized: 173467
// gas legacy: 179782
// gas legacyOptimized: 173727
// test_indices(uint256): 0xFF ->
// gas irOptimized: 3410252
// gas legacy: 3509577
// gas legacyOptimized: 3397597
// gas irOptimized: 5681652
// gas legacy: 5780977
// gas legacyOptimized: 5668997
// test_indices(uint256): 1000 ->
// gas irOptimized: 18206119
// gas legacy: 18599999
// gas legacyOptimized: 18176944
// gas irOptimized: 18208919
// gas legacy: 18602799
// gas legacyOptimized: 18179744
// test_indices(uint256): 129 ->
// gas irOptimized: 2756952
// gas legacy: 2770413
// gas legacyOptimized: 2716289
// gas irOptimized: 5198552
// gas legacy: 5212013
// gas legacyOptimized: 5157889
// test_indices(uint256): 128 ->
// gas irOptimized: 411900
// gas legacy: 464968
// gas legacyOptimized: 418168
// gas irOptimized: 417500
// gas legacy: 470568
// gas legacyOptimized: 423768
// test_indices(uint256): 1 ->
// gas irOptimized: 368568
// gas legacy: 363389
// gas legacyOptimized: 361809
// gas irOptimized: 726968
// gas legacy: 721789
// gas legacyOptimized: 720209

View File

@ -16,12 +16,12 @@ contract C {
// test_boundary_check(uint256,uint256): 1, 1 -> FAILURE, hex"4e487b71", 0x32
// test_boundary_check(uint256,uint256): 10, 10 -> FAILURE, hex"4e487b71", 0x32
// test_boundary_check(uint256,uint256): 256, 256 -> FAILURE, hex"4e487b71", 0x32
// gas irOptimized: 137831
// gas legacy: 131830
// gas legacyOptimized: 112054
// gas irOptimized: 140631
// gas legacy: 134630
// gas legacyOptimized: 114854
// test_boundary_check(uint256,uint256): 256, 255 -> 0
// gas irOptimized: 139963
// gas legacy: 134149
// gas legacyOptimized: 114233
// gas irOptimized: 142763
// gas legacy: 136949
// gas legacyOptimized: 117033
// test_boundary_check(uint256,uint256): 256, 0xFFFF -> FAILURE, hex"4e487b71", 0x32
// test_boundary_check(uint256,uint256): 256, 2 -> 0

View File

@ -52,18 +52,18 @@ contract C {
// ----
// test_zeroed_indicies(uint256): 1 ->
// test_zeroed_indicies(uint256): 5 ->
// gas irOptimized: 131174
// gas legacy: 132301
// gas legacyOptimized: 129539
// gas irOptimized: 153874
// gas legacy: 155001
// gas legacyOptimized: 152239
// test_zeroed_indicies(uint256): 10 ->
// gas irOptimized: 174777
// gas legacy: 177188
// gas legacyOptimized: 172112
// gas irOptimized: 277077
// gas legacy: 279488
// gas legacyOptimized: 274412
// test_zeroed_indicies(uint256): 15 ->
// gas irOptimized: 198022
// gas legacy: 201738
// gas legacyOptimized: 194427
// gas irOptimized: 399822
// gas legacy: 403538
// gas legacyOptimized: 396227
// test_zeroed_indicies(uint256): 0xFF ->
// gas irOptimized: 6097912
// gas legacy: 6159333
// gas legacyOptimized: 6026177
// gas irOptimized: 6399212
// gas legacy: 6460633
// gas legacyOptimized: 6327477

View File

@ -13,10 +13,10 @@ contract C {
// set_get_length(uint256): 20 -> 20
// set_get_length(uint256): 0xFF -> 0xFF
// gas irOptimized: 96690
// gas legacy: 126722
// gas legacyOptimized: 107818
// gas legacy: 129522
// gas legacyOptimized: 110618
// set_get_length(uint256): 0xFFF -> 0xFFF
// gas irOptimized: 1217848
// gas legacy: 1702119
// gas legacyOptimized: 1398420
// gas irOptimized: 1220648
// gas legacy: 1704919
// gas legacyOptimized: 1401220
// set_get_length(uint256): 0xFFFFF -> FAILURE # Out-of-gas #

View File

@ -16,9 +16,9 @@ contract C {
// gas legacy: 416903
// gas legacyOptimized: 398280
// pushEmpty(uint256): 256
// gas irOptimized: 691026
// gas legacy: 714315
// gas legacyOptimized: 687372
// gas irOptimized: 693826
// gas legacy: 717115
// gas legacyOptimized: 690172
// pushEmpty(uint256): 38869 -> FAILURE # out-of-gas #
// gas irOptimized: 100000000
// gas legacy: 100000000

View File

@ -21,13 +21,13 @@ contract C {
// gas legacy: 77730
// gas legacyOptimized: 77162
// set_get_length(uint256): 0xFF -> 0xFF
// gas irOptimized: 141796
// gas legacy: 678237
// gas legacyOptimized: 115104
// gas irOptimized: 161696
// gas legacy: 698137
// gas legacyOptimized: 135004
// set_get_length(uint256): 0xFFF -> 0xFFF
// gas irOptimized: 1801663
// gas legacy: 9873774
// gas legacyOptimized: 1398546
// gas irOptimized: 1804463
// gas legacy: 9876574
// gas legacyOptimized: 1401346
// set_get_length(uint256): 0xFFFFF -> FAILURE # Out-of-gas #
// gas irOptimized: 100000000
// gas legacyOptimized: 100000000

View File

@ -13,15 +13,15 @@ contract C {
// set_get_length(uint256): 1 -> 0
// set_get_length(uint256): 10 -> 0
// set_get_length(uint256): 20 -> 0
// gas irOptimized: 86331
// gas legacy: 85822
// gas legacyOptimized: 83608
// gas irOptimized: 106222
// gas legacy: 105722
// gas legacyOptimized: 103508
// set_get_length(uint256): 0xFF -> 0
// gas irOptimized: 821872
// gas legacy: 810327
// gas legacyOptimized: 786258
// gas irOptimized: 841772
// gas legacy: 830227
// gas legacyOptimized: 806158
// set_get_length(uint256): 0xFFF -> 0
// gas irOptimized: 12841084
// gas legacy: 12649059
// gas legacyOptimized: 12267870
// gas irOptimized: 12860984
// gas legacy: 12668959
// gas legacyOptimized: 12287770
// set_get_length(uint256): 0xFFFF -> FAILURE # Out-of-gas #