Skip to content

Conversation

zguesmi
Copy link
Member

@zguesmi zguesmi commented Jul 26, 2025

This PR is purely for renaming. Fixes are in the next PR to simplify diff.

Migration steps:

  • Migrate src files (minimal changes)
  • Modify receive and fallback behavior in Diamond.sol
  • Rename all 1538 to 2535 in contracts and rename Module to Facet in contracts names
  • Add unit tests for Diamond.sol
  • Remove ENSIntegration modules/functions
  • Update all facets to use namespaces app storage.
  • Rename only ✔️ feat: Use namespaced storage #236
  • Fix compilation and tests (next PR)
  • Update contracts file tree.
  • Merge feature/diamond in develop
  • Merge PR Update deployment CI #228
  • Set admin in deployment script
  • Update docs (soldoc, diagrams, ...)

@zguesmi zguesmi requested a review from Copilot July 26, 2025 10:53
@zguesmi zguesmi self-assigned this Jul 26, 2025
Copilot

This comment was marked as outdated.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR migrates the contract storage from a traditional diamond proxy pattern to use namespaced storage following EIP-7201. The changes replace direct access to storage variables with calls to a getPocoStorage() function that returns a storage struct pointer.

Key changes:

  • Replace direct storage variable access (e.g., m_balances[account]) with namespaced storage access (e.g., $.m_balances[account])
  • Restructure the Store contract to use a PocoStorage struct with namespaced storage location
  • Update all facet contracts to retrieve storage through getPocoStorage() function

Reviewed Changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Store.v8.sol Converts storage from individual variables to namespaced PocoStorage struct
Store.sol Converts storage from individual variables to namespaced PocoStorage struct
IexecAccessorsFacet.sol Updates all storage access to use namespaced storage pattern
IexecERC20Core.sol Updates balance and allowance operations to use namespaced storage
IexecEscrow.v8.sol Updates escrow operations (lock/unlock/seize) to use namespaced storage
IexecPoco1Facet.sol Updates deal matching and order management to use namespaced storage
IexecPoco2Facet.sol Updates consensus and contribution logic to use namespaced storage
IexecPocoBoostFacet.sol Updates boost workflow operations to use namespaced storage
IexecConfigurationFacet.sol Updates configuration management to use namespaced storage
Multiple other facets Updates various operations to use namespaced storage pattern

@gfournieriExec
Copy link
Contributor

Is this different due to solidity version ?
$_slot := POCO_STORAGE_LOCATION |   | $.slot := POCO_STORAGE_LOCATION

@zguesmi
Copy link
Member Author

zguesmi commented Jul 28, 2025

Is this different due to solidity version ? $_slot := POCO_STORAGE_LOCATION |   | $.slot := POCO_STORAGE_LOCATION

Yes. v6 vs v8.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using this type of comment to split the storage and make it more readable ? => https://github.com/iExecBlockchainComputing/rlc-multichain/blob/09761d4bb9c252a6ca9a0020d2ad7979ec9ae75f/src/RLCLiquidityUnifier.sol#L62

Copy link
Member Author

@zguesmi zguesmi Jul 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not fan of these comments personally, we use it in other projects.
We can enhance later.

Comment on lines +78 to +87
mapping(bytes32 => address) m_presigned;
// Each order has a volume (>=1). This tracks how much is consumed from
// the volume of each order. Mapping an order hash to its consumed amount.
mapping(bytes32 => uint256) m_consumed;
// a mapping to store PoCo classic deals.
mapping(bytes32 => IexecLibCore_v5.Deal) m_deals;
mapping(bytes32 => IexecLibCore_v5.Task) m_tasks; // per task
mapping(bytes32 => IexecLibCore_v5.Consensus) m_consensus; // per task
mapping(bytes32 => mapping(address => IexecLibCore_v5.Contribution)) m_contributions; // per task-worker
mapping(address => uint256) m_workerScores; // per worker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes done in this PR Add comments to store mappings

Comment on lines +107 to 110
// Use in registries.
interface IRegistry is IERC721Enumerable {
function isRegistered(address _entry) external view returns (bool);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we move that into a dedicated file instead ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed because it's only used here.

// Seized funds of workerpools that do not honor their deals are sent
// out to this kitty address.
// It is determined with address(uint256(keccak256(bytes('iExecKitty'))) - 1).
address public constant KITTY_ADDRESS = 0x99c2268479b93fDe36232351229815DF80837e23;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not having a variable (uint256) directly into the PocoStorage struct ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using constant reduces gas cost.

@zguesmi zguesmi merged commit 1e89ce3 into feature/diamond Jul 28, 2025
1 check failed
@zguesmi zguesmi deleted the feature/namespaced-storage branch July 28, 2025 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants