Repository navigation
G29: executable constructor for ordinary verity_contract (verity#2465) #2470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ce21286
fix(edsl): signed Int256 storage reads in executable plane (G28); ERC…
Th0rgal af94be1
chore: auto-refresh derived artifacts
github-actions[bot] 5076d53
test: G2 kernel evaluation of hashed-mapping bodies; fix ERC-20 hop s…
Th0rgal bb3b50b
chore: macro property-test artifacts for ERC-20 hop smoke
Th0rgal 9422010
docs: executable Int256 storage reads are signed (G28)
Th0rgal 7327946
feat(edsl): executable constructor for ordinary verity_contract (veri…
Th0rgal e46bfba
G29: use generated ERC721 constructor; ctor smoke kernel witnesses; p…
Th0rgal 58d5ee8
ci: trigger
Th0rgal 2bbbb95
test: replace #check with example in ctor smoke (hygiene)
Th0rgal a02b60f
fix(macro): suppress unused-param lint on generated executable constr…
Th0rgal 238df8b
Merge main into fix/pareto-g29-ctor
Th0rgal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import Contracts.Common | ||
|
|
||
| /-! | ||
| # Executable constructors for ordinary contracts (verity#2465, Pareto G29) | ||
|
|
||
| An ordinary `verity_contract` constructor now has an executable | ||
| `.constructor` definition (previously only mixins and include hosts did), so a | ||
| deployment boundary can run the generated constructor body. Constructors | ||
| whose body has no executable lowering still elaborate and keep only the | ||
| compilation-model constructor. | ||
| -/ | ||
|
|
||
| namespace Contracts.Smoke.ConstructorExecutable | ||
|
|
||
| open Contracts | ||
| open Verity hiding pure bind | ||
| open Verity.EVM.Uint256 | ||
|
|
||
| verity_contract CtorExec where | ||
| storage | ||
| supply : Uint256 := slot 0 | ||
| minter : Address := slot 5 | ||
|
|
||
| constructor (initial : Uint256) := do | ||
| let sender ← msgSender | ||
| setStorageAddr minter sender | ||
| setStorage supply initial | ||
|
|
||
| function view minterOf () : Address := do | ||
| let m ← getStorageAddr minter | ||
| return m | ||
|
|
||
| example : Uint256 → Contract Unit := CtorExec.constructor | ||
|
|
||
| private def deployer : Address := (0x1234 : Address) | ||
|
|
||
| private def deployed : ContractState := | ||
| ((CtorExec.constructor 77).run { Verity.defaultState with sender := deployer }).getState | ||
|
|
||
| example : deployed.readAddrSlot 5 = deployer ∧ deployed.readSlot 0 = 77 := by | ||
| decide +kernel | ||
|
|
||
| -- Tranche-shaped constructor with metadata `String` parameters (the strings | ||
| -- are accepted as executable parameters; `String` storage stays unsupported). | ||
| verity_contract CtorWithStrings where | ||
| storage | ||
| decimalsSlot : Uint256 := slot 0 | ||
|
|
||
| constructor (_name : String, _symbol : String) := do | ||
| setStorage decimalsSlot 18 | ||
|
|
||
| example : String → String → Contract Unit := CtorWithStrings.constructor | ||
|
|
||
| example : | ||
| (((CtorWithStrings.constructor "AA" "AA_T").run Verity.defaultState).getState).readSlot 0 = 18 := by | ||
| decide +kernel | ||
|
|
||
| end Contracts.Smoke.ConstructorExecutable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.33; | ||
|
|
||
| import "./yul/YulTestBase.sol"; | ||
|
|
||
| /** | ||
| * @title PropertyCtorExecTest | ||
| * @notice Auto-generated baseline property stubs from `verity_contract` declarations. | ||
| * @dev Source: Contracts/Smoke/ConstructorExecutable.lean | ||
| */ | ||
| contract PropertyCtorExecTest is YulTestBase { | ||
| address target; | ||
| address alice = address(0x1111); | ||
|
|
||
| function setUp() public { | ||
| target = deployYulWithArgs("CtorExec", abi.encode(uint256(1))); | ||
| require(target != address(0), "Deploy failed"); | ||
| } | ||
|
|
||
| // Property 1: minterOf reads storage slot 5 and decodes the result | ||
| function testAuto_MinterOf_ReadsConfiguredStorage() public { | ||
| address expected = alice; | ||
| vm.store(target, bytes32(uint256(5)), bytes32(uint256(uint160(expected)))); | ||
| vm.prank(alice); | ||
| (bool ok, bytes memory ret) = target.call(abi.encodeWithSignature("minterOf()")); | ||
| require(ok, "minterOf reverted unexpectedly"); | ||
| assertEq(ret.length, 32, "minterOf ABI return length mismatch (expected 32 bytes)"); | ||
| address actual = abi.decode(ret, (address)); | ||
| assertEq(actual, expected, "minterOf should return storage slot 5"); | ||
| } | ||
| } |
20 changes: 20 additions & 0 deletions
20
artifacts/macro_property_tests/PropertyCtorWithStrings.t.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.33; | ||
|
|
||
| import "./yul/YulTestBase.sol"; | ||
|
|
||
| /** | ||
| * @title PropertyCtorWithStringsTest | ||
| * @notice Auto-generated baseline property stubs from `verity_contract` declarations. | ||
| * @dev Source: Contracts/Smoke/ConstructorExecutable.lean | ||
| */ | ||
| contract PropertyCtorWithStringsTest is YulTestBase { | ||
| address target; | ||
| address alice = address(0x1111); | ||
|
|
||
| function setUp() public { | ||
| target = deployYulWithArgs("CtorWithStrings", abi.encode("verity", "verity")); | ||
| require(target != address(0), "Deploy failed"); | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.