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 // Clear EIP-2929 account access indicator
recorded_account_accesses.clear(); recorded_account_accesses.clear();
// Clear EIP-2929 storage access indicator
for (auto& [address, account]: accounts) for (auto& [address, account]: accounts)
for (auto& [slot, value]: account.storage) 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 // Process selfdestruct list
for (auto& [address, _]: recorded_selfdestructs) for (auto& [address, _]: recorded_selfdestructs)
accounts.erase(address); accounts.erase(address);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -16,33 +16,38 @@ contract C {
// ---- // ----
// test_indices(uint256): 1 -> // test_indices(uint256): 1 ->
// test_indices(uint256): 129 -> // test_indices(uint256): 129 ->
// gas irOptimized: 3018684 // gas irOptimized: 3021484
// gas legacy: 3068883 // gas legacy: 3071683
// gas legacyOptimized: 3011615 // gas legacyOptimized: 3014415
// test_indices(uint256): 5 -> // test_indices(uint256): 5 ->
// gas irOptimized: 372540 // gas irOptimized: 722540
// gas legacy: 369151 // gas legacy: 719151
// gas legacyOptimized: 366139 // gas legacyOptimized: 716139
// test_indices(uint256): 10 -> // test_indices(uint256): 10 ->
// gas irOptimized: 158407
// gas legacy: 162657
// gas legacyOptimized: 158422
// test_indices(uint256): 15 -> // test_indices(uint256): 15 ->
// gas irOptimized: 72860 // gas irOptimized: 173467
// gas legacy: 179782
// gas legacyOptimized: 173727
// test_indices(uint256): 0xFF -> // test_indices(uint256): 0xFF ->
// gas irOptimized: 3410252 // gas irOptimized: 5681652
// gas legacy: 3509577 // gas legacy: 5780977
// gas legacyOptimized: 3397597 // gas legacyOptimized: 5668997
// test_indices(uint256): 1000 -> // test_indices(uint256): 1000 ->
// gas irOptimized: 18206119 // gas irOptimized: 18208919
// gas legacy: 18599999 // gas legacy: 18602799
// gas legacyOptimized: 18176944 // gas legacyOptimized: 18179744
// test_indices(uint256): 129 -> // test_indices(uint256): 129 ->
// gas irOptimized: 2756952 // gas irOptimized: 5198552
// gas legacy: 2770413 // gas legacy: 5212013
// gas legacyOptimized: 2716289 // gas legacyOptimized: 5157889
// test_indices(uint256): 128 -> // test_indices(uint256): 128 ->
// gas irOptimized: 411900 // gas irOptimized: 417500
// gas legacy: 464968 // gas legacy: 470568
// gas legacyOptimized: 418168 // gas legacyOptimized: 423768
// test_indices(uint256): 1 -> // test_indices(uint256): 1 ->
// gas irOptimized: 368568 // gas irOptimized: 726968
// gas legacy: 363389 // gas legacy: 721789
// gas legacyOptimized: 361809 // 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): 1, 1 -> FAILURE, hex"4e487b71", 0x32
// test_boundary_check(uint256,uint256): 10, 10 -> 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 // test_boundary_check(uint256,uint256): 256, 256 -> FAILURE, hex"4e487b71", 0x32
// gas irOptimized: 137831 // gas irOptimized: 140631
// gas legacy: 131830 // gas legacy: 134630
// gas legacyOptimized: 112054 // gas legacyOptimized: 114854
// test_boundary_check(uint256,uint256): 256, 255 -> 0 // test_boundary_check(uint256,uint256): 256, 255 -> 0
// gas irOptimized: 139963 // gas irOptimized: 142763
// gas legacy: 134149 // gas legacy: 136949
// gas legacyOptimized: 114233 // gas legacyOptimized: 117033
// test_boundary_check(uint256,uint256): 256, 0xFFFF -> FAILURE, hex"4e487b71", 0x32 // test_boundary_check(uint256,uint256): 256, 0xFFFF -> FAILURE, hex"4e487b71", 0x32
// test_boundary_check(uint256,uint256): 256, 2 -> 0 // 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): 1 ->
// test_zeroed_indicies(uint256): 5 -> // test_zeroed_indicies(uint256): 5 ->
// gas irOptimized: 131174 // gas irOptimized: 153874
// gas legacy: 132301 // gas legacy: 155001
// gas legacyOptimized: 129539 // gas legacyOptimized: 152239
// test_zeroed_indicies(uint256): 10 -> // test_zeroed_indicies(uint256): 10 ->
// gas irOptimized: 174777 // gas irOptimized: 277077
// gas legacy: 177188 // gas legacy: 279488
// gas legacyOptimized: 172112 // gas legacyOptimized: 274412
// test_zeroed_indicies(uint256): 15 -> // test_zeroed_indicies(uint256): 15 ->
// gas irOptimized: 198022 // gas irOptimized: 399822
// gas legacy: 201738 // gas legacy: 403538
// gas legacyOptimized: 194427 // gas legacyOptimized: 396227
// test_zeroed_indicies(uint256): 0xFF -> // test_zeroed_indicies(uint256): 0xFF ->
// gas irOptimized: 6097912 // gas irOptimized: 6399212
// gas legacy: 6159333 // gas legacy: 6460633
// gas legacyOptimized: 6026177 // gas legacyOptimized: 6327477

View File

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

View File

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

View File

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

View File

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