Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions hh2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Node modules
/node_modules

# Hardhat build artifacts / cache
/artifacts
/cache

# Typechain output
/typechain-types
26 changes: 26 additions & 0 deletions hh2/contracts/Initializable__Mock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;

/// @dev Minimal mock used to demonstrate the storage-tracing difference
/// between Hardhat 2 (`hardhat-tracer`) and Hardhat 3 (`-v`).
///
/// `_version` (uint8) and `_initialized` (bool) are packed into the
/// same storage slot (slot 0), so `initialize` performs two SSTOREs
/// into that single slot, and `version()` performs one SLOAD.
contract Initializable__Mock {
uint8 private _version;
bool private _initialized;

event Initialized(uint256 version);

function initialize(uint8 _v) public payable {
require(!_initialized, "Contract is already initialized");
_version = _v; // SSTORE
_initialized = true; // SSTORE (packed into the same slot)
emit Initialized(_v);
}

function version() public view returns (uint8) {
return _version; // SLOAD
}
}
12 changes: 12 additions & 0 deletions hh2/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require("@nomicfoundation/hardhat-ethers");
require("@nomicfoundation/hardhat-chai-matchers");
// hardhat-tracer adds the --trace / --fulltrace / --v..--vvvv flags to
// `hardhat test`. It is the plugin that renders [SLOAD]/[SSTORE] lines.
require("hardhat-tracer");

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
// Same compiler as the HH3 project so the bytecode (and therefore the
// storage layout / opcodes) is identical on both sides.
solidity: "0.8.9",
};
Loading
Loading