@@ -155,15 +155,6 @@ function popStackCheck(sp, evmGasLeft, numInputs) {
155
155
}
156
156
}
157
157
158
- function popPushStackCheck (sp, evmGasLeft, numInputs) {
159
- let popCheck := lt (sub (sp, mul (0x20 , sub (numInputs, 1 ))), STACK_OFFSET ())
160
- let pushOffset := sub (sp, mul (0x20 , numInputs))
161
- let pushCheck := or (gt (pushOffset, BYTECODE_OFFSET ()), eq (pushOffset, BYTECODE_OFFSET ()))
162
- if or (popCheck, pushCheck) {
163
- revertWithGas (evmGasLeft)
164
- }
165
- }
166
-
167
158
function getCodeAddress () -> addr {
168
159
addr := verbatim_0i_1o ("code_source " )
169
160
}
@@ -193,11 +184,7 @@ function ptrShrinkIntoActive(_dest) {
193
184
}
194
185
195
186
function _getRawCodeHash (account) -> hash {
196
- // TODO: Unhardcode this selector
197
- mstore8 (0 , 0x4d )
198
- mstore8 (1 , 0xe2 )
199
- mstore8 (2 , 0xe4 )
200
- mstore8 (3 , 0x68 )
187
+ mstore (0 , 0x4DE2E46800000000000000000000000000000000000000000000000000000000 )
201
188
mstore (4 , account)
202
189
203
190
let success := staticcall (gas (), ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT (), 0 , 36 , 0 , 32 )
@@ -212,12 +199,7 @@ function _getRawCodeHash(account) -> hash {
212
199
213
200
function _getCodeHash (account) -> hash {
214
201
// function getCodeHash(uint256 _input) external view override returns (bytes32)
215
- // 0xe03fe177
216
- // TODO: Unhardcode this selector
217
- mstore8 (0 , 0xe0 )
218
- mstore8 (1 , 0x3f )
219
- mstore8 (2 , 0xe1 )
220
- mstore8 (3 , 0x77 )
202
+ mstore (0 , 0xE03FE17700000000000000000000000000000000000000000000000000000000 )
221
203
mstore (4 , account)
222
204
223
205
let success := staticcall (gas (), ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT (), 0 , 36 , 0 , 32 )
@@ -301,11 +283,7 @@ function getDeployedBytecode() {
301
283
302
284
function consumeEvmFrame () -> passGas, isStatic, callerEVM {
303
285
// function consumeEvmFrame() external returns (uint256 passGas, bool isStatic)
304
- // TODO: Unhardcode selector
305
- mstore8 (0 , 0x04 )
306
- mstore8 (1 , 0xc1 )
307
- mstore8 (2 , 0x4e )
308
- mstore8 (3 , 0x9e )
286
+ mstore (0 , 0x04C14E9E00000000000000000000000000000000000000000000000000000000 )
309
287
310
288
let success := call (gas (), EVM_GAS_MANAGER_CONTRACT (), 0 , 0 , 4 , 0 , 64 )
311
289
@@ -550,11 +528,7 @@ function printString(value) {
550
528
}
551
529
552
530
function isSlotWarm (key) -> isWarm {
553
- // TODO: Unhardcode this selector 0x482d2e74
554
- mstore8 (0 , 0x48 )
555
- mstore8 (1 , 0x2d )
556
- mstore8 (2 , 0x2e )
557
- mstore8 (3 , 0x74 )
531
+ mstore (0 , 0x482D2E7400000000000000000000000000000000000000000000000000000000 )
558
532
mstore (4 , key)
559
533
560
534
let success := call (gas (), EVM_GAS_MANAGER_CONTRACT (), 0 , 0 , 36 , 0 , 32 )
@@ -568,11 +542,7 @@ function isSlotWarm(key) -> isWarm {
568
542
}
569
543
570
544
function warmSlot (key,currentValue) -> isWarm, originalValue {
571
- // TODO: Unhardcode this selector 0xbdf78160
572
- mstore8 (0 , 0xbd )
573
- mstore8 (1 , 0xf7 )
574
- mstore8 (2 , 0x81 )
575
- mstore8 (3 , 0x60 )
545
+ mstore (0 , 0xBDF7816000000000000000000000000000000000000000000000000000000000 )
576
546
mstore (4 , key)
577
547
mstore (36 ,currentValue)
578
548
@@ -665,10 +635,7 @@ function getNewAddress(addr) -> newAddr {
665
635
}
666
636
667
637
function incrementNonce (addr) {
668
- mstore8 (0 , 0x30 )
669
- mstore8 (1 , 0x63 )
670
- mstore8 (2 , 0x95 )
671
- mstore8 (3 , 0xc6 )
638
+ mstore (0 , 0x306395C600000000000000000000000000000000000000000000000000000000 )
672
639
mstore (4 , addr)
673
640
674
641
let result := call (gas (), NONCE_HOLDER_SYSTEM_CONTRACT (), 0 , 0 , 36 , 0 , 0 )
@@ -700,11 +667,7 @@ function addGasIfEvmRevert(isCallerEVM,offset,size,evmGasLeft) -> newOffset,newS
700
667
}
701
668
702
669
function $llvm_AlwaysInline_llvm$_warmAddress (addr) -> isWarm {
703
- // TODO: Unhardcode this selector 0x8db2ba78
704
- mstore8 (0 , 0x8d )
705
- mstore8 (1 , 0xb2 )
706
- mstore8 (2 , 0xba )
707
- mstore8 (3 , 0x78 )
670
+ mstore (0 , 0x8DB2BA7800000000000000000000000000000000000000000000000000000000 )
708
671
mstore (4 , addr)
709
672
710
673
let success := call (gas (), EVM_GAS_MANAGER_CONTRACT (), 0 , 0 , 36 , 0 , 32 )
@@ -718,10 +681,7 @@ function $llvm_AlwaysInline_llvm$_warmAddress(addr) -> isWarm {
718
681
}
719
682
720
683
function getNonce (addr) -> nonce {
721
- mstore8 (0 , 0xfb )
722
- mstore8 (1 , 0x1a )
723
- mstore8 (2 , 0x9a )
724
- mstore8 (3 , 0x57 )
684
+ mstore (0 , 0xFB1A9A5700000000000000000000000000000000000000000000000000000000 )
725
685
mstore (4 , addr)
726
686
727
687
let result := staticcall (gas (), NONCE_HOLDER_SYSTEM_CONTRACT (), 0 , 36 , 0 , 32 )
@@ -734,10 +694,7 @@ function getNonce(addr) -> nonce {
734
694
}
735
695
736
696
function getRawNonce (addr) -> nonce {
737
- mstore8 (0 , 0x5a )
738
- mstore8 (1 , 0xa9 )
739
- mstore8 (2 , 0xb6 )
740
- mstore8 (3 , 0xb5 )
697
+ mstore (0 , 0x5AA9B6B500000000000000000000000000000000000000000000000000000000 )
741
698
mstore (4 , addr)
742
699
743
700
let result := staticcall (gas (), NONCE_HOLDER_SYSTEM_CONTRACT (), 0 , 36 , 0 , 32 )
@@ -756,10 +713,7 @@ function _isEVM(_addr) -> isEVM {
756
713
// address(SYSTEM_CONTRACTS_OFFSET + 0x02)
757
714
// );
758
715
759
- mstore8 (0 , 0x8c )
760
- mstore8 (1 , 0x04 )
761
- mstore8 (2 , 0x04 )
762
- mstore8 (3 , 0x77 )
716
+ mstore (0 , 0x8C04047700000000000000000000000000000000000000000000000000000000 )
763
717
mstore (4 , _addr)
764
718
765
719
let success := staticcall (gas (), ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT (), 0 , 36 , 0 , 32 )
@@ -774,12 +728,8 @@ function _isEVM(_addr) -> isEVM {
774
728
775
729
function _pushEVMFrame (_passGas, _isStatic) {
776
730
// function pushEVMFrame(uint256 _passGas, bool _isStatic) external
777
- let selector := 0xead77156
778
731
779
- mstore8 (0 , 0xea )
780
- mstore8 (1 , 0xd7 )
781
- mstore8 (2 , 0x71 )
782
- mstore8 (3 , 0x56 )
732
+ mstore (0 , 0xEAD7715600000000000000000000000000000000000000000000000000000000 )
783
733
mstore (4 , _passGas)
784
734
mstore (36 , _isStatic)
785
735
@@ -792,13 +742,8 @@ function _pushEVMFrame(_passGas, _isStatic) {
792
742
793
743
function _popEVMFrame () {
794
744
// function popEVMFrame() external
795
- // 0xe467d2f0
796
- let selector := 0xe467d2f0
797
745
798
- mstore8 (0 , 0xe4 )
799
- mstore8 (1 , 0x67 )
800
- mstore8 (2 , 0xd2 )
801
- mstore8 (3 , 0xf0 )
746
+ mstore (0 , 0xE467D2F000000000000000000000000000000000000000000000000000000000 )
802
747
803
748
let success := call (gas (), EVM_GAS_MANAGER_CONTRACT (), 0 , 0 , 4 , 0 , 0 )
804
749
if iszero (success) {
@@ -1223,12 +1168,7 @@ function isAddrEmpty(addr) -> isEmpty {
1223
1168
}
1224
1169
1225
1170
function _fetchConstructorReturnGas () -> gasLeft {
1226
- //selector is 0x24e5ab4a
1227
-
1228
- mstore8 (0 , 0x24 )
1229
- mstore8 (1 , 0xe5 )
1230
- mstore8 (2 , 0xab )
1231
- mstore8 (3 , 0x4a )
1171
+ mstore (0 , 0x24E5AB4A00000000000000000000000000000000000000000000000000000000 )
1232
1172
1233
1173
let success := staticcall (gas (), DEPLOYER_SYSTEM_CONTRACT (), 0 , 4 , 0 , 32 )
1234
1174
@@ -1311,6 +1251,45 @@ function $llvm_NoInline_llvm$_genericCreate(addr, offset, size, sp, value, evmGa
1311
1251
mstore (sub (offset, 0x80 ), back)
1312
1252
}
1313
1253
1254
+ function $llvm_AlwaysInline_llvm$_copyRest (dest, val, len) {
1255
+ let rest_bits := shl (3 , len)
1256
+ let upper_bits := sub (256 , rest_bits)
1257
+ let val_mask := shl (upper_bits, MAX_UINT ())
1258
+ let val_masked := and (val, val_mask)
1259
+ let dst_val := mload (dest)
1260
+ let dst_mask := shr (rest_bits, MAX_UINT ())
1261
+ let dst_masked := and (dst_val, dst_mask)
1262
+ mstore (dest, or (val_masked, dst_masked))
1263
+ }
1264
+
1265
+ function $llvm_AlwaysInline_llvm$_memcpy (dest, src, len) {
1266
+ let dest_addr := dest
1267
+ let src_addr := src
1268
+ let dest_end := add (dest, and (len, sub (0 , 32 )))
1269
+ for { } lt (dest_addr, dest_end) {} {
1270
+ mstore (dest_addr, mload (src_addr))
1271
+ dest_addr := add (dest_addr, 32 )
1272
+ src_addr := add (src_addr, 32 )
1273
+ }
1274
+
1275
+ let rest_len := and (len, 31 )
1276
+ if rest_len {
1277
+ $llvm_AlwaysInline_llvm$_copyRest (dest_addr, mload (src_addr), rest_len)
1278
+ }
1279
+ }
1280
+
1281
+ function $llvm_AlwaysInline_llvm$_memsetToZero (dest,len) {
1282
+ let dest_end := add (dest, and (len, sub (0 , 32 )))
1283
+ for {let i := dest} lt (i, dest_end) { i := add (i, 32 ) } {
1284
+ mstore (i, 0 )
1285
+ }
1286
+
1287
+ let rest_len := and (len, 31 )
1288
+ if rest_len {
1289
+ $llvm_AlwaysInline_llvm$_copyRest (dest_end, 0 , rest_len)
1290
+ }
1291
+ }
1292
+
1314
1293
function performExtCodeCopy (evmGas,oldSp, oldStackHead) -> evmGasLeft, sp, stackHead {
1315
1294
evmGasLeft := chargeGas (evmGas, 100 )
1316
1295
@@ -1333,17 +1312,7 @@ function performExtCodeCopy(evmGas,oldSp, oldStackHead) -> evmGasLeft, sp, stack
1333
1312
}
1334
1313
evmGasLeft := chargeGas (evmGasLeft, dynamicGas)
1335
1314
1336
-
1337
- let len_32 := shr (5 , len)
1338
- for {let i := 0 } lt (i, len_32) { i := add (i, 1 ) } {
1339
- mstore (add (dest,shl (5 ,i)),0 )
1340
- }
1341
-
1342
- let size_32 := shl (5 ,len_32)
1343
- let rest_32 := sub (len, size_32)
1344
- for {let i := 0 } lt (i, rest_32) { i := add (i, 1 ) } {
1345
- mstore8 (add (dest,add (size_32,i)),0 )
1346
- }
1315
+ $llvm_AlwaysInline_llvm$_memsetToZero (dest, len)
1347
1316
1348
1317
// Gets the code from the addr
1349
1318
if and (iszero (iszero (_getRawCodeHash (addr))),gt (len,0 )) {
@@ -1435,7 +1404,7 @@ function performCreate2(evmGas, oldSp, isStatic, oldStackHead) -> evmGasLeft, sp
1435
1404
1436
1405
{
1437
1406
let hashedBytecode := keccak256 (add (MEM_OFFSET_INNER (), offset), size)
1438
- mstore8 (0 , 0xFF )
1407
+ mstore (0 , 0xFF00000000000000000000000000000000000000000000000000000000000000 )
1439
1408
mstore (0x01 , shl (0x60 , address ()))
1440
1409
mstore (0x15 , salt)
1441
1410
mstore (0x35 , hashedBytecode)
0 commit comments