-
Notifications
You must be signed in to change notification settings - Fork 9
Add source-level internal function visibility #1945
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
4 commits
Select commit
Hold shift + click to select a range
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
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,48 @@ | ||
| /- | ||
| Compiler.Modules.Create2SSTORE2: CREATE2 and SSTORE2-style code-as-data helpers. | ||
|
|
||
| These ECMs expose the low-level source surface needed by code-as-data | ||
| contracts without requiring downstream projects to patch generated Yul. | ||
| -/ | ||
|
|
||
| import Compiler.ECM | ||
| import Compiler.CompilationModel | ||
|
|
||
| namespace Compiler.Modules.Create2SSTORE2 | ||
|
|
||
| open Compiler.Yul | ||
| open Compiler.ECM | ||
|
|
||
| /-- Deploy already-prepared initcode with `create2(value, offset, size, salt)` and | ||
| bind the deployed address word. The caller owns initcode layout and salt | ||
| semantics; this module only lowers the EVM mechanic. -/ | ||
| def deployModule (resultVar : String) : ExternalCallModule where | ||
| name := "create2Deploy" | ||
| numArgs := 4 | ||
| resultVars := [resultVar] | ||
| writesState := true | ||
| readsState := false | ||
| axioms := ["create2_initcode_layout", "create2_address_derivation"] | ||
| compile := fun _ctx args => do | ||
| match args with | ||
| | [value, offset, size, salt] => | ||
| pure [YulStmt.let_ resultVar (YulExpr.call "create2" [value, offset, size, salt])] | ||
| | _ => | ||
| throw s!"create2Deploy expects 4 arguments, got {args.length}" | ||
|
|
||
| /-- Copy deployed bytecode into memory with `extcodecopy(pointer, dest, offset, size)`. | ||
| This is the read half of SSTORE2-style code-as-data patterns. -/ | ||
| def readCodeModule : ExternalCallModule where | ||
| name := "sstore2ReadCode" | ||
| numArgs := 4 | ||
| writesState := false | ||
| readsState := true | ||
| axioms := ["sstore2_pointer_code_layout"] | ||
| compile := fun _ctx args => do | ||
| match args with | ||
| | [pointer, destOffset, codeOffset, size] => | ||
| pure [YulStmt.expr (YulExpr.call "extcodecopy" [pointer, destOffset, codeOffset, size])] | ||
| | _ => | ||
| throw s!"sstore2ReadCode expects 4 arguments, got {args.length}" | ||
|
|
||
| end Compiler.Modules.Create2SSTORE2 |
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
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
26 changes: 26 additions & 0 deletions
26
artifacts/macro_property_tests/PropertyCreate2SSTORE2Smoke.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,26 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.33; | ||
|
|
||
| import "./yul/YulTestBase.sol"; | ||
|
|
||
| /** | ||
| * @title PropertyCreate2SSTORE2SmokeTest | ||
| * @notice Auto-generated baseline property stubs from `verity_contract` declarations. | ||
| * @dev Source: Contracts/Smoke.lean | ||
| */ | ||
| contract PropertyCreate2SSTORE2SmokeTest is YulTestBase { | ||
| address target; | ||
| address alice = address(0x1111); | ||
|
|
||
| function setUp() public { | ||
| target = deployYul("Create2SSTORE2Smoke"); | ||
| require(target != address(0), "Deploy failed"); | ||
| } | ||
|
|
||
| // Property 1: readCode has no unexpected revert | ||
| function testAuto_ReadCode_NoUnexpectedRevert() public { | ||
| vm.prank(alice); | ||
| (bool ok,) = target.call(abi.encodeWithSignature("readCode(address,uint256,uint256,uint256)", alice, uint256(1), uint256(1), uint256(1))); | ||
| require(ok, "readCode reverted unexpectedly"); | ||
| } | ||
| } |
50 changes: 50 additions & 0 deletions
50
artifacts/macro_property_tests/PropertyFixedArrayMappingStructSmoke.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,50 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.33; | ||
|
|
||
| import "./yul/YulTestBase.sol"; | ||
|
|
||
| /** | ||
| * @title PropertyFixedArrayMappingStructSmokeTest | ||
| * @notice Auto-generated baseline property stubs from `verity_contract` declarations. | ||
| * @dev Source: Contracts/Smoke.lean | ||
| */ | ||
| contract PropertyFixedArrayMappingStructSmokeTest is YulTestBase { | ||
| address target; | ||
| address alice = address(0x1111); | ||
|
|
||
| function setUp() public { | ||
| target = deployYul("FixedArrayMappingStructSmoke"); | ||
| require(target != address(0), "Deploy failed"); | ||
| } | ||
|
|
||
| // Property 1: writeRoot1 has no unexpected revert | ||
| function testAuto_WriteRoot1_NoUnexpectedRevert() public { | ||
| vm.prank(alice); | ||
| (bool ok,) = target.call(abi.encodeWithSignature("writeRoot1(uint256,bytes32)", uint256(1), bytes32(uint256(0xBEEF)))); | ||
| require(ok, "writeRoot1 reverted unexpectedly"); | ||
| } | ||
| // Property 2: TODO decode and assert `readRoot1` result | ||
| function testTODO_ReadRoot1_DecodeAndAssert() public { | ||
| vm.prank(alice); | ||
| (bool ok, bytes memory ret) = target.call(abi.encodeWithSignature("readRoot1(uint256)", uint256(1))); | ||
| require(ok, "readRoot1 reverted unexpectedly"); | ||
| assertEq(ret.length, 32, "readRoot1 ABI return length mismatch (expected 32 bytes)"); | ||
| // TODO(#1011): decode `ret` and assert the concrete postcondition from Lean theorem. | ||
| ret; | ||
| } | ||
| // Property 3: writeProof11 has no unexpected revert | ||
| function testAuto_WriteProof11_NoUnexpectedRevert() public { | ||
| vm.prank(alice); | ||
| (bool ok,) = target.call(abi.encodeWithSignature("writeProof11(uint256,uint256)", uint256(1), uint256(1))); | ||
| require(ok, "writeProof11 reverted unexpectedly"); | ||
| } | ||
| // Property 4: TODO decode and assert `readProof11` result | ||
| function testTODO_ReadProof11_DecodeAndAssert() public { | ||
| vm.prank(alice); | ||
| (bool ok, bytes memory ret) = target.call(abi.encodeWithSignature("readProof11(uint256)", uint256(1))); | ||
| require(ok, "readProof11 reverted unexpectedly"); | ||
| assertEq(ret.length, 32, "readProof11 ABI return length mismatch (expected 32 bytes)"); | ||
| // TODO(#1011): decode `ret` and assert the concrete postcondition from Lean theorem. | ||
| ret; | ||
| } | ||
| } |
Oops, something went wrong.
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.