Skip to content

Commit

Permalink
fix: revert Memory.sol incorrect fix
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenctw committed Mar 20, 2024
1 parent d960726 commit c790e92
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions shasum-mock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
c114d9e59014339c29374f0085a266fb820449f123007e7c89f2f9ec680e5de0 src/AccessLogs.sol
b0bb91ae378db1c938e73eccde20c539da01b8556165835839fd1794ca573404 src/Buffer.sol
d5de348b450c7cb5237a836d8e6e22cbfb4649f5892fac30f054efabdd7fc0a5 src/Memory.sol
c2e9abd5557092fb2c7a3b6eb3d55933613c202b8ce54bba2e8cbd2d276278a1 src/Memory.sol
06df1c5a0a6094fdc3f55240a42b1991290eb672fae6833e9f2b4d4bfe2a5b88 src/MetaStep.sol
0cdad8286752fbecf920db8095a764802ed88236efe7d179acdd88e018291b33 src/UArchCompat.sol
d858085617f1e8037e06420d9569e2196b72a8bd0dd217aefbb8bb738b44a8fd src/UArchCompat.sol
60ab17c719b0cb58047bfa5a83e390b30b32f5be00243890f2d321635bc5359a src/UArchConstants.sol
c250ea17a7a471716148a60528b2cd01bd82dffd1c3c57aa0a7e99527fe44527 src/UArchReset.sol
40ab03ff44235b8ee5490314db112120e1ff99b347a5faf6a00f812e2497568d src/UArchStep.sol
4 changes: 2 additions & 2 deletions shasum-prod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
0a8aff4ef47e41118f842437aa29cd9ea74e243fda7b629e40b79878bf17f749 src/AccessLogs.sol
b0bb91ae378db1c938e73eccde20c539da01b8556165835839fd1794ca573404 src/Buffer.sol
d5de348b450c7cb5237a836d8e6e22cbfb4649f5892fac30f054efabdd7fc0a5 src/Memory.sol
c2e9abd5557092fb2c7a3b6eb3d55933613c202b8ce54bba2e8cbd2d276278a1 src/Memory.sol
06df1c5a0a6094fdc3f55240a42b1991290eb672fae6833e9f2b4d4bfe2a5b88 src/MetaStep.sol
0cdad8286752fbecf920db8095a764802ed88236efe7d179acdd88e018291b33 src/UArchCompat.sol
d858085617f1e8037e06420d9569e2196b72a8bd0dd217aefbb8bb738b44a8fd src/UArchCompat.sol
60ab17c719b0cb58047bfa5a83e390b30b32f5be00243890f2d321635bc5359a src/UArchConstants.sol
c250ea17a7a471716148a60528b2cd01bd82dffd1c3c57aa0a7e99527fe44527 src/UArchReset.sol
40ab03ff44235b8ee5490314db112120e1ff99b347a5faf6a00f812e2497568d src/UArchStep.sol
2 changes: 1 addition & 1 deletion src/Memory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ library Memory {
// assert position and size are aligned
// position has to be a multiple of size
// equivalent to: size = 2^a, position = 2^b, position = size * 2^c, where c >= 0
assert(((s - 1) & addr) == 0);
assert(((s - 1) & position) == 0);
uint64 stride = position / s;
return Stride.wrap(stride);
}
Expand Down
4 changes: 3 additions & 1 deletion src/UArchCompat.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ library UArchCompat {
a.writeRegion(
Memory.regionFromPhysicalAddress(
UArchConstants.RESET_POSITION.toPhysicalAddress(),
Memory.alignedSizeFromLog2(UArchConstants.RESET_ALIGNED_SIZE)
Memory.alignedSizeFromLog2(
UArchConstants.RESET_ALIGNED_SIZE - 3
)
),
UArchConstants.PRESTINE_STATE
);
Expand Down
2 changes: 1 addition & 1 deletion test/Memory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ contract MemoryTest is Test {
Memory.alignedSizeFromLog2(l)
);

if ((1 << l) == (paddr)) {
if ((1 << l) == (paddr >> 3)) {
// address has to be aligned with stride size
vm.expectRevert();
uint64(paddr + paddr / 2).toPhysicalAddress()
Expand Down
4 changes: 2 additions & 2 deletions test/UArchReset.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ contract UArchReset_Test is Test {
bytes memory buffer = new bytes(100 * (siblingsLength + 1) * 32);
string memory rj = loadJsonLog(resetLog);
bytes32 initialRootHash = bytes32(
0xb9fbeba37a3a62da4b20fbdcfca24893485643dfb8885b800e08f1cb389e8e5e
0xe6924ad1b17f3e77b62b33d0e43f16066cd4fcd8c5531369fcf71936a93fe271
);
bytes32 finalRootHash = bytes32(
0xda5cc789efd69f0edb94a23753fbd767cf91b203c3055d2339b8db8760f2093e
0xc4a80b24909990e42edabfe9bfb3b90974173e22735a0c191f8809c45e22da66
);

// load json log
Expand Down

0 comments on commit c790e92

Please sign in to comment.