Skip to content
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

CSE: Include symbolic contracts corresponding to contract fields into accounts #600

Merged
merged 45 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
43878bb
Draft implementation and test for `contract` field accounts inclusion
palinatolmach Jun 5, 2024
8010577
Set Version: 0.1.301
Jun 5, 2024
1a929bc
Merge branch 'master' into cse-contract-fields
PetarMax Jun 5, 2024
e3794f8
Set Version: 0.1.301
Jun 5, 2024
0c6a57e
Merge branch 'master' into cse-contract-fields
palinatolmach Jun 6, 2024
a78dbb6
Set Version: 0.1.302
Jun 6, 2024
6092452
Use (simple) `#lookup` constraint for `contract` field in storage
palinatolmach Jun 6, 2024
fcd95fa
Minor formatting
palinatolmach Jun 6, 2024
6ac1afa
Merge branch 'master' into cse-contract-fields
palinatolmach Jun 7, 2024
a336d15
Set Version: 0.1.303
Jun 7, 2024
47f1263
Draft implementation refactoring
palinatolmach Jun 7, 2024
486d848
Merge branch 'master' into cse-contract-fields
PetarMax Jun 8, 2024
8bae8cf
Set Version: 0.1.306
Jun 8, 2024
b8aa43c
renaming contracts to avoid conflicts, removing unneeded constraints
PetarMax Jun 8, 2024
1c5795d
minor streamlining
PetarMax Jun 10, 2024
702d8c0
Merge branch 'master' into cse-contract-fields
palinatolmach Jun 11, 2024
90e9e63
Set Version: 0.1.307
Jun 11, 2024
ca23db9
Merge branch 'master' into cse-contract-fields
palinatolmach Jun 11, 2024
4941ea1
Set Version: 0.1.308
Jun 11, 2024
be0c2a3
removing unused variable
PetarMax Jun 11, 2024
a736864
renaming re-assigned variable
PetarMax Jun 11, 2024
7e71976
Make `_create_cse_accounts` apply recursively on `contract` field acc…
palinatolmach Jun 11, 2024
b1509f7
Code quality improvement
palinatolmach Jun 11, 2024
a085c81
Set Version: 0.1.309
Jun 11, 2024
c5c452c
Avoid adding new accs for constructors, add new CSE test for recursiv…
palinatolmach Jun 11, 2024
3c0b3ce
Enforce same symbolic storage variable name between constructor and f…
palinatolmach Jun 11, 2024
a46b3ec
tests with immutables
PetarMax Jun 11, 2024
69132aa
stabilising tests
PetarMax Jun 11, 2024
b2ae1fa
Merge branch 'master' into cse-contract-fields
PetarMax Jun 11, 2024
df4e23c
Set Version: 0.1.309
Jun 11, 2024
610d6e9
Update expected output, remove `Accounts` test
palinatolmach Jun 12, 2024
112a3fb
Update `contracts.k` expected output to reflect removal of `Accounts`
palinatolmach Jun 12, 2024
177c75e
Merge branch 'master' into cse-contract-fields
palinatolmach Jun 12, 2024
a630375
Set Version: 0.1.310
Jun 12, 2024
b3e9746
Use default symbolic storage var name for constructor storage with CSE
palinatolmach Jun 12, 2024
86d5bf2
Documented `_create_cse_accounts`
palinatolmach Jun 12, 2024
ef0acc3
One other output update
palinatolmach Jun 12, 2024
01c4d7a
Merge branch 'master' into cse-contract-fields
palinatolmach Jun 12, 2024
c8ad934
Set Version: 0.1.311
Jun 12, 2024
78f2894
Apply refactoring from review comments
palinatolmach Jun 12, 2024
16cd4e5
Apply refactoring from review comments, preserve `new_init_cterm`
palinatolmach Jun 12, 2024
78d538d
Add test for recursive storage generation in new accounts
palinatolmach Jun 12, 2024
e82ab0c
Update output to account for TGovernance
palinatolmach Jun 12, 2024
40e0f37
correction
PetarMax Jun 12, 2024
4a89a45
Merge branch 'master' into cse-contract-fields
rv-jenkins Jun 12, 2024
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
2 changes: 1 addition & 1 deletion package/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.310
0.1.311
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "kontrol"
version = "0.1.310"
version = "0.1.311"
description = "Foundry integration for KEVM"
authors = [
"Runtime Verification, Inc. <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion src/kontrol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
if TYPE_CHECKING:
from typing import Final

VERSION: Final = '0.1.310'
VERSION: Final = '0.1.311'
239 changes: 170 additions & 69 deletions src/kontrol/prove.py

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion src/tests/integration/test-data/cse-lemmas.k
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module CSE-LEMMAS
[simplification]

// Function selector does not match
rule { B:Bytes #Equals B1:Bytes +Bytes B2:Bytes } => #Bottom
rule { B:Bytes #Equals B1:Bytes +Bytes _:Bytes } => #Bottom
requires #range(B, 0, 4) =/=K #range (B1, 0, 4)
[simplification(60), concrete(B, B1)]

Expand All @@ -40,6 +40,20 @@ module CSE-LEMMAS
requires 4 <=Int lengthBytes(B) andBool #range(B, 0, 4) ==K B1
[simplification(60), concrete(B, B1)]

// Bitwise inequalities
rule [bitwise-and-maxUInt-lt-l]:
A <Int X &Int Y => false
requires 0 <=Int X andBool 0 <=Int Y
andBool X +Int 1 ==Int 2 ^Int log2Int(X +Int 1)
andBool X +Int 1 <=Int A
[concrete(X), simplification, preserves-definedness]

rule [bitwise-and-maxUInt-le-r]:
X &Int Y <=Int A => true
requires 0 <=Int X andBool 0 <=Int Y
andBool X +Int 1 ==Int 2 ^Int log2Int(X +Int 1)
andBool X +Int 1 <=Int A
[concrete(X), simplification, preserves-definedness]

endmodule

Expand Down
1 change: 1 addition & 0 deletions src/tests/integration/test-data/foundry-dependency-all
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ArithmeticContract.add_sub_external(uint256,uint256,uint256)
CSETest.test_add_const(uint256,uint256)
CSETest.test_identity(uint256,uint256)
ConstructorTest.test_contract_call()
ContractFieldTest.testEscrowToken()
Identity.applyOp(uint256)
Identity.identity(uint256)
ImportedContract.set(uint256)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.8.13;
import {Test} from "forge-std/Test.sol";

contract TToken {
uint128 private totalSupply;

constructor(uint128 _totalSupply) {
totalSupply = _totalSupply;
}

function getTotalSupply() public returns (uint256) {
return 32 + uint256(totalSupply);
}
}

contract TEscrow {
TToken token;

constructor(address _token) {
token = TToken(_token);
}

function getTokenTotalSupply() public returns (uint256) {
return token.getTotalSupply() + 13;
}
}

contract ContractFieldTest is Test {
TToken token;
TEscrow escrow;

function setUp() public {
token = new TToken(12300);
escrow = new TEscrow(address(token));
}

/* Calling `getTokenTotalSupply` will summarize `totalSupply` and
include `TestToken token` into the list of accounts in `getTokenTotalSupply`'s summary
*/
function testEscrowToken() public {
assert(escrow.getTokenTotalSupply() == 12345);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
│ statusCode: STATUSCODE:StatusCode
┃ (branch)
┣━━┓ constraint: VV0_x_114b9705:Int <=Int ( maxUInt256 -Int #lookup ( STORAGE_CONTRACT_ID:Map , 0 ) )
┣━━┓ constraint: VV0_x_114b9705:Int <=Int ( maxUInt256 -Int #lookup ( CONTRACT_STORAGE:Map , 0 ) )
┃ │
┃ ├─ 8
┃ │ k: #execute ~> CONTINUATION:K
Expand All @@ -29,7 +29,7 @@
┃ callDepth: CALLDEPTH_CELL_5d410f2a:Int
┃ statusCode: STATUSCODE_FINAL:StatusCode
┗━━┓ constraint: ( maxUInt256 -Int #lookup ( STORAGE_CONTRACT_ID:Map , 0 ) ) <Int VV0_x_114b9705:Int
┗━━┓ constraint: ( maxUInt256 -Int #lookup ( CONTRACT_STORAGE:Map , 0 ) ) <Int VV0_x_114b9705:Int
├─ 9
│ k: #execute ~> CONTINUATION:K
Expand Down Expand Up @@ -76,7 +76,7 @@ module SUMMARY-SRC%CSE%ADDCONST.APPLYOP(UINT256):0
<ethereum>
<evm>
<output>
( _OUTPUT_CELL => #buf ( 32 , ( VV0_x_114b9705:Int +Int #lookup ( STORAGE_CONTRACT_ID:Map , 0 ) ) ) )
( _OUTPUT_CELL => #buf ( 32 , ( VV0_x_114b9705:Int +Int #lookup ( CONTRACT_STORAGE:Map , 0 ) ) ) )
</output>
<statusCode>
( _STATUSCODE => EVMC_SUCCESS )
Expand All @@ -98,7 +98,7 @@ module SUMMARY-SRC%CSE%ADDCONST.APPLYOP(UINT256):0
( .WordStack => ( selector ( "applyOp(uint256)" ) : .WordStack ) )
</wordStack>
<localMem>
( b"" => b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +Bytes #buf ( 32 , ( VV0_x_114b9705:Int +Int #lookup ( STORAGE_CONTRACT_ID:Map , 0 ) ) ) )
( b"" => b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +Bytes #buf ( 32 , ( VV0_x_114b9705:Int +Int #lookup ( CONTRACT_STORAGE:Map , 0 ) ) ) )
</localMem>
<memoryUsed>
0
Expand Down Expand Up @@ -138,7 +138,7 @@ module SUMMARY-SRC%CSE%ADDCONST.APPLYOP(UINT256):0
CONTRACT_BAL:Int
</balance>
<storage>
STORAGE_CONTRACT_ID:Map
CONTRACT_STORAGE:Map
</storage>
<nonce>
CONTRACT_NONCE:Int
Expand Down Expand Up @@ -247,7 +247,7 @@ module SUMMARY-SRC%CSE%ADDCONST.APPLYOP(UINT256):0
andBool ( ( notBool #range ( 0 < CALLER_ID:Int <= 9 ) )
andBool ( ( notBool #range ( 0 < ORIGIN_ID:Int <= 9 ) )
andBool ( ( notBool #range ( 0 < CONTRACT_ID:Int <= 9 ) )
andBool ( VV0_x_114b9705:Int <=Int ( maxUInt256 -Int #lookup ( STORAGE_CONTRACT_ID:Map , 0 ) )
andBool ( VV0_x_114b9705:Int <=Int ( maxUInt256 -Int #lookup ( CONTRACT_STORAGE:Map , 0 ) )
))))))))))))))))))))))))
[priority(20), label(BASIC-BLOCK-8-TO-6)]

Expand Down Expand Up @@ -288,7 +288,7 @@ module SUMMARY-SRC%CSE%ADDCONST.APPLYOP(UINT256):0
0
</callValue>
<wordStack>
( .WordStack => ( 0 : ( VV0_x_114b9705:Int : ( #lookup ( STORAGE_CONTRACT_ID:Map , 0 ) : ( 118 : ( 0 : ( VV0_x_114b9705:Int : ( 70 : ( selector ( "applyOp(uint256)" ) : .WordStack ) ) ) ) ) ) ) ) )
( .WordStack => ( 0 : ( VV0_x_114b9705:Int : ( #lookup ( CONTRACT_STORAGE:Map , 0 ) : ( 118 : ( 0 : ( VV0_x_114b9705:Int : ( 70 : ( selector ( "applyOp(uint256)" ) : .WordStack ) ) ) ) ) ) ) ) )
</wordStack>
<localMem>
( b"" => b"NH{q\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80" )
Expand Down Expand Up @@ -331,7 +331,7 @@ module SUMMARY-SRC%CSE%ADDCONST.APPLYOP(UINT256):0
CONTRACT_BAL:Int
</balance>
<storage>
STORAGE_CONTRACT_ID:Map
CONTRACT_STORAGE:Map
</storage>
<nonce>
CONTRACT_NONCE:Int
Expand Down Expand Up @@ -440,7 +440,7 @@ module SUMMARY-SRC%CSE%ADDCONST.APPLYOP(UINT256):0
andBool ( ( notBool #range ( 0 < CALLER_ID:Int <= 9 ) )
andBool ( ( notBool #range ( 0 < ORIGIN_ID:Int <= 9 ) )
andBool ( ( notBool #range ( 0 < CONTRACT_ID:Int <= 9 ) )
andBool ( ( maxUInt256 -Int #lookup ( STORAGE_CONTRACT_ID:Map , 0 ) ) <Int VV0_x_114b9705:Int
andBool ( ( maxUInt256 -Int #lookup ( CONTRACT_STORAGE:Map , 0 ) ) <Int VV0_x_114b9705:Int
))))))))))))))))))))))))
[priority(20), label(BASIC-BLOCK-9-TO-7)]

Expand Down
Loading
Loading