diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 66c1452..aa688fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -119,7 +119,7 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} huff-tests: - name: Foundry tests + name: Huff tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/src/L2Compressor.huff b/src/L2Compressor.huff index 5d1c419..11a573a 100644 --- a/src/L2Compressor.huff +++ b/src/L2Compressor.huff @@ -174,11 +174,10 @@ codecopy // [flag, windex, rindex + 1] no_load: - dup1 // [flag, flag, windex, rindex + 1] - 0x01 shl // [flag << 0x01, flag, windex, rindex + 1] - mload // [word, flag, windex, rindex + 1] - 0xf0 shr // [word >> 0xf0, flag, windex, rindex + 1] - jump // [flag, windex, rindex + 1] + 0x01 shl // [flag << 0x01, windex, rindex + 1] + mload // [word, windex, rindex + 1] + 0xf0 shr // [word >> 0xf0, windex, rindex + 1] + jump // [windex, rindex + 1] FLAG_READ_BYTES32_0_BYTES: READ_BYTES32_EMPTY() // [windex, rindex] @@ -878,9 +877,7 @@ } #define macro READ_ABI(nrfs, nparams) = takes (3) returns (2) { - // input stack: [flag, windex, rindex] - - pop // [windex, rindex] + // input stack: [windex, rindex] // Reserve 32 bytes to store the size, dynamic values // use the first 32 bytes to store the size of the value @@ -965,9 +962,7 @@ } #define macro READ_BYTES32(shift_bits, read_bytes) = takes (3) returns (2) { - // input stack: [flag, windex, rindex] - - pop // [windex, rindex] + // input stack: [windex, rindex] 0x20 // [0x20, windex, rindex] @@ -991,9 +986,7 @@ } #define macro READ_BYTES32_EMPTY() = takes (3) returns (2) { - // input stack: [flag, windex, rindex] - - pop // [windex, rindex] + // input stack: [windex, rindex] 0x00 // [0x00, windex, rindex] dup2 // [windex, 0x00, windex, rindex] @@ -1002,13 +995,11 @@ 0x20 // [0x20, windex, rindex] add // [(0x20 + windex), rindex] - // input stack: [flag, windex, rindex] + // input stack: [windex, rindex] } #define macro READ_BYTES32_WORD() = takes (3) returns (2) { - // input stack: [flag, windex, rindex] - - pop // [windex, rindex] + // input stack: [windex, rindex] 0x20 // [0x20, windex, rindex] dup1 // [0x20, 0x20, windex, rindex] @@ -1032,7 +1023,6 @@ #define test TEST_FLAG_READ_BYTES32() = { 0x01 // [rindex] [FMS] 0x40 add // [windex, rindex] - 0x00 // [flag, windex, rindex] READ_BYTES32(0xf0, 0x02) // [windex, rindex] @@ -1043,7 +1033,6 @@ 0x00 // [rindex] [FMS] // [windex, rindex] - 0xff // [flag, windex, rindex] READ_BYTES32(0x00, 0x20) // [windex, rindex] @@ -1054,7 +1043,6 @@ 0x00 // [rindex] [FMS] 0x40 add // [windex, rindex] - 0x00 // [flag, windex, rindex] READ_BYTES32_WORD() // [windex, rindex] @@ -1066,7 +1054,6 @@ 0x15 // [rindex] [FMS] 0x10 add // [windex, rindex] - 0xf1 // [flag, windex, rindex] READ_BYTES32_EMPTY() // [windex, rindex] @@ -1077,9 +1064,7 @@ } #define macro SAVE_ADDRESS() = takes (3) returns (2) { - // input stack: [flag, windex, rindex] - - pop // [windex, rindex] + // input stack: [windex, rindex] dup2 // [rindex, windex, rindex] calldataload // [word, windex, rindex] @@ -1110,8 +1095,6 @@ 0x01 // [rindex] [FMS] // [windex, rindex] - 0x02 // [flag, windex, rindex] - SAVE_ADDRESS() // [windex, rindex] [FMS] 0x20 add eq ASSERT() // [rindex] @@ -1133,9 +1116,7 @@ } #define macro SAVE_BYTES32() = takes (3) returns (2) { - // input stack: [flag, windex, rindex] - - pop // [windex, rindex] + // input stack: [windex, rindex] dup2 // [rindex, windex, rindex] calldataload // [word, windex, rindex] @@ -1164,8 +1145,6 @@ 0x01 // [rindex] 0x20 // [windex, rindex] - 0x02 // [flag, windex, rindex] - SAVE_BYTES32() // [windex, rindex] 0x40 eq ASSERT() // [] @@ -1196,9 +1175,8 @@ } #define macro READ_STORAGE(smv, smc, read_bytes, read_bits_shift) = takes (3) returns (2) { - // input stack: [flag, windex, rindex] + // input stack: [windex, rindex] - pop // [windex, rindex] swap1 // [rindex, windex] LOAD_DYNAMIC_SIZE(, ) // [index, nrindex + size, windex] @@ -1230,7 +1208,6 @@ // Read the first bytes32 0x00 // [rindex] 0x00 // [windex, rindex] - [FLAG_READ_BYTES32_2_BYTES] // [flag, windex, rindex] READ_BYTES32_STORAGE(0x02, 0xf0) // [windex, rindex] @@ -1242,7 +1219,6 @@ // Read the second bytes32 0x02 // [rindex] 0x20 // [windex, rindex] - [FLAG_READ_BYTES32_2_BYTES] 0x02 add // [flag, windex, rindex] READ_BYTES32_STORAGE(0x04, 0xe0) // [windex, rindex] @@ -1255,8 +1231,6 @@ 0x06 // [rindex] 0x10 // [windex, rindex] - [FLAG_READ_BYTES32_2_BYTES] 0x03 add // [flag, windex, rindex] - READ_BYTES32_STORAGE(0x05, 0xd8) // [windex, rindex] 0x30 eq ASSERT() // [rindex] @@ -1281,7 +1255,6 @@ // Read the first bytes32 0x00 // [rindex] 0x00 // [windex, rindex] - [FLAG_READ_ADDRESS_2_BYTES] // [flag, windex, rindex] READ_ADDRESS_STORAGE(0x02, 0xf0) // [windex, rindex] @@ -1293,7 +1266,6 @@ // Read the second bytes32 0x02 // [rindex] 0x20 // [windex, rindex] - [FLAG_READ_ADDRESS_2_BYTES] 0x02 add // [flag, windex, rindex] READ_ADDRESS_STORAGE(0x04, 0xe0) // [windex, rindex] @@ -1306,8 +1278,6 @@ 0x06 // [rindex] 0x10 // [windex, rindex] - [FLAG_READ_ADDRESS_2_BYTES] 0x03 add // [flag, windex, rindex] - READ_ADDRESS_STORAGE(0x05, 0xd8) // [windex, rindex] 0x30 eq ASSERT() // [rindex] @@ -1408,9 +1378,7 @@ } #define macro READ_N_BYTES(nrfs) = takes (2) returns (2) { - // input stack: [flag, windex, rindex] - - pop // [windex, rindex] + // input stack: [windex, rindex] PERFORM_NESTED_READ_FLAG() // [windex, rindex] BACKREAD_SINGLE_VALUE() // [size, windex, rindex]