Skip to content

Commit

Permalink
chore: revert storage change (#55)
Browse files Browse the repository at this point in the history
## Summary
So it'd make the migration easy. For more details, please refer to
natspec.

## Detail
### Changeset
* reverted one change from the [previous
PR](#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
  • Loading branch information
huaweigu authored Dec 18, 2024
1 parent 194a8e9 commit 9f8c6de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
17 changes: 7 additions & 10 deletions src/msca/6900/v0.7/libs/WalletStorageV1Lib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions test/msca/6900/v0.7/WalletStorageV1Lib.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9f8c6de

Please sign in to comment.