From 9f8c6dee66d282a45fa6226bdd2630f32df91fde Mon Sep 17 00:00:00 2001 From: Huawei Date: Wed, 18 Dec 2024 13:59:28 -0500 Subject: [PATCH] chore: revert storage change (#55) ## Summary So it'd make the migration easy. For more details, please refer to natspec. ## Detail ### Changeset * reverted one change from the [previous PR](https://github.com/circlefin/buidl-wallet-contracts/pull/54) ### Checklist - [x] Did you add new tests and confirm all tests pass? (`yarn test`) - [x] Did you update relevant docs? (docs are found in the `docs` folder) - [x] Do your commits follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard? - [x] Does your PR title also follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard? - [ ] If you have a breaking change, is it [correctly reflected in your commit message](https://www.conventionalcommits.org/en/v1.0.0/#examples)? (e.g. `feat!: breaking change`) - [x] Did you run lint (`yarn lint`) and fix any issues? - [x] Did you run formatter (`yarn format:check`) and fix any issues (`yarn format:write`)? ## Testing * test has also been reverted ## Documentation * see natspec --- src/msca/6900/v0.7/libs/WalletStorageV1Lib.sol | 17 +++++++---------- test/msca/6900/v0.7/WalletStorageV1Lib.t.sol | 5 ++--- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/msca/6900/v0.7/libs/WalletStorageV1Lib.sol b/src/msca/6900/v0.7/libs/WalletStorageV1Lib.sol index 51a2243..68c7b63 100644 --- a/src/msca/6900/v0.7/libs/WalletStorageV1Lib.sol +++ b/src/msca/6900/v0.7/libs/WalletStorageV1Lib.sol @@ -23,16 +23,13 @@ import {ExecutionDetail, PermittedExternalCall, PluginDetail} from "../common/St /// @dev The same storage will be used for v1.x.y of MSCAs. library WalletStorageV1Lib { - // @notice On 12/16/2024, storage was aligned to 256 as a potential optimization in anticipation of gas schedule - // changes following the Verkle state tree migration. This adjustment accounts for scenarios where groups - // of 256 storage slots may become warm simultaneously and will only apply to newly deployed accounts. - // For more details, please refer to https://eips.ethereum.org/EIPS/eip-7201. - // Old value: 0xc6a0cc20c824c4eecc4b0fbb7fb297d07492a7bd12c83d4fa4d27b4249f9bfc8, which is calculated by - // keccak256(abi.encode(uint256(keccak256(abi.encode("circle.msca.v1.storage"))) - 1)); - // New value: - // 1. id = "circle.msca.v1.storage" - // 2. keccak256(abi.encode(uint256(keccak256(id)) - 1)) & ~bytes32(uint256(0xff)) - bytes32 internal constant WALLET_STORAGE_SLOT = 0x1f5beaddce7d7c52c0db456127db41c33d65f252d3a09b925e817276761a6a00; + // @notice When we initially calculated the storage slot, EIP-7201 was still under active discussion, + // so we didn’t fully adopt the storage alignment proposed by the EIP, which reduces gas costs + // for subsequent operations, as a single cold storage access warms all 256 slots within the group. + // To avoid introducing breaking changes and the complexity of migration, we chose not to make changes midway. + // For v2 accounts, which will feature a different storage layout, we will adopt EIP-7201. + // keccak256(abi.encode(uint256(keccak256(abi.encode("circle.msca.v1.storage"))) - 1)) + bytes32 internal constant WALLET_STORAGE_SLOT = 0xc6a0cc20c824c4eecc4b0fbb7fb297d07492a7bd12c83d4fa4d27b4249f9bfc8; struct Layout { // installed plugin addresses for quick query diff --git a/test/msca/6900/v0.7/WalletStorageV1Lib.t.sol b/test/msca/6900/v0.7/WalletStorageV1Lib.t.sol index 29fa25b..c86954c 100644 --- a/test/msca/6900/v0.7/WalletStorageV1Lib.t.sol +++ b/test/msca/6900/v0.7/WalletStorageV1Lib.t.sol @@ -47,9 +47,8 @@ contract WalletStorageV1LibTest is TestUtils { } function testWalletStorageSlot() public pure { - bytes32 hash = keccak256(abi.encode(uint256(keccak256("circle.msca.v1.storage")) - 1)); - bytes32 alignedHash = hash & ~bytes32(uint256(0xff)); - assertEq(alignedHash, 0x1f5beaddce7d7c52c0db456127db41c33d65f252d3a09b925e817276761a6a00); + bytes32 hash = keccak256(abi.encode(uint256(keccak256(abi.encode("circle.msca.v1.storage"))) - 1)); + assertEq(hash, 0xc6a0cc20c824c4eecc4b0fbb7fb297d07492a7bd12c83d4fa4d27b4249f9bfc8); } // this test is very similar to AddressDLLLibTest, but under the context of plugin and wallet