Skip to content

feat: storage layout for EvmErc20.sol#178

Merged
joshuajbouw merged 2 commits intodevelopfrom
feat-storage-layout
Jul 14, 2021
Merged

feat: storage layout for EvmErc20.sol#178
joshuajbouw merged 2 commits intodevelopfrom
feat-storage-layout

Conversation

@0x3bfc
Copy link
Copy Markdown
Contributor

@0x3bfc 0x3bfc commented Jul 13, 2021

Adding a hardhat plugin that allow developer to generate the storage layout for solidity contract. These storage slots are used for updating the state variables in any adminControlled inheriting contract.

npx hardhat storageLayout
┌─────────────────┬────────────────┬──────────────┬────────┬─────────────────────────────────────────────────────┐
│ contract        │ state_variable │ storage_slot │ offset │ type                                                │
├─────────────────┼────────────────┼──────────────┼────────┼─────────────────────────────────────────────────────┤
│ ERC20           │ _balances      │      0       │   0    │ t_mapping(t_address,t_uint256)                      │
│ ERC20           │ _allowances    │      1       │   0    │ t_mapping(t_address,t_mapping(t_address,t_uint256)) │
│ ERC20           │ _totalSupply   │      2       │   0    │ t_uint256                                           │
│ ERC20           │ _name          │      3       │   0    │ t_string_storage                                    │
│ ERC20           │ _symbol        │      4       │   0    │ t_string_storage                                    │
│ AdminControlled │ admin          │      0       │   0    │ t_address                                           │
│ AdminControlled │ paused         │      1       │   0    │ t_uint256                                           │
│ EvmErc20        │ _balances      │      0       │   0    │ t_mapping(t_address,t_uint256)                      │
│ EvmErc20        │ _allowances    │      1       │   0    │ t_mapping(t_address,t_mapping(t_address,t_uint256)) │
│ EvmErc20        │ _totalSupply   │      2       │   0    │ t_uint256                                           │
│ EvmErc20        │ _name          │      3       │   0    │ t_string_storage                                    │
│ EvmErc20        │ _symbol        │      4       │   0    │ t_string_storage                                    │
│ EvmErc20        │ admin          │      5       │   0    │ t_address                                           │
│ EvmErc20        │ paused         │      6       │   0    │ t_uint256                                           │
│ EvmErc20        │ _name          │      7       │   0    │ t_string_storage                                    │
│ EvmErc20        │ _symbol        │      8       │   0    │ t_string_storage                                    │
│ EvmErc20        │ _decimals      │      9       │   0    │ t_uint8                                             │
│ SelfDestruct    │ counter        │      0       │   0    │ t_uint256                                           │
│ Tester          │ erc20Token     │      0       │   0    │ t_contract(IExit)980                                │
└─────────────────┴────────────────┴──────────────┴────────┴─────────────────────────────────────────────────────┘

@0x3bfc 0x3bfc changed the base branch from master to develop July 13, 2021 16:24
@0x3bfc 0x3bfc requested review from artob and mfornet July 13, 2021 16:25
@0x3bfc 0x3bfc marked this pull request as ready for review July 13, 2021 16:50
Copy link
Copy Markdown
Contributor

@sept-en sept-en left a comment

Choose a reason for hiding this comment

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

Good job!

* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
newStorageLayoutPath: './storageLayout',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Where this variable is used later?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This will be used to export the storage layout in a md file.

@0x3bfc 0x3bfc requested review from birchmd and joshuajbouw July 14, 2021 16:30
@joshuajbouw joshuajbouw merged commit 5e5c8e0 into develop Jul 14, 2021
@joshuajbouw joshuajbouw deleted the feat-storage-layout branch July 14, 2021 16:40
artob added a commit that referenced this pull request Jul 30, 2021
* JSON: fix bugs and add unit tests. (#141)
* Add storage layout debug support for `EvmErc20.sol`. (#178)
* ERC-20: forbid using invalid NEP-141 AccountID for mapping. (#179)
* Add EIP-2930 support. (#181, #182)
* Migrate all workflows to self-hosted runners. (#185)
* Speed up the workflow using build caching. (#189)
* Use the new math API host functions. (#190)
* Fix `clippy::enum_variant_names` warning. (#192)
* Add different networks to the Makefile. (#193)
* Update the network status in the README. (#194)
* Remove the toolchain installation step in workflows. (#195)
* Run all tests for all networks in CI. (#196)
* Optimize for performance instead of code size. (#197)
* Parallelize the test suites. (#198)
* Add build-caching to the testing workflow. (#201)
* Refactor tests to use Signer. (#203)
* Add options to the bench profile. (#204)
* Remove a duplicate test. (#205)
* Add a sanity test for access list handling. (#206)
* Update nearcore to the latest branch.
* Add feature gates to the SDK's new host functions.

Co-authored-by: Ahmed Ali <ahmed@aurora.dev>
Co-authored-by: Dmitry Strokov <dmitry@aurora.dev>
Co-authored-by: Evgeny Ukhanov <evgeny@aurora.dev>
Co-authored-by: Joshua J. Bouw <joshua@aurora.dev>
Co-authored-by: Kirill <kirill@aurora.dev>
Co-authored-by: Michael Birch <michael@aurora.dev>
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.

4 participants