Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Initial assertions in emitted Solidity #162

Merged
merged 11 commits into from Feb 13, 2020
Merged

Initial assertions in emitted Solidity #162

merged 11 commits into from Feb 13, 2020

Conversation

ehildenb
Copy link
Contributor

@ehildenb ehildenb commented Feb 13, 2020

  • Adds snapshotting to K definition.

  • Adds klabel declarations to some important Event in the log, so that we can more easily pull them out in the mcd-pyk.py file.

  • Changes the way contracts/addresses are wrapped in the generated solidity output.

  • Prints out a minimized state delta as a K rewrite.

  • Prints out initial attempt at assertions in the Solidity, now example emitted Solidity looks like:

        // Test Run
    ADMIN.Vat_rely(address(GemJoin_gold));
    ADMIN.Spot_setPrice("gold", 1);
    ADMIN.Flip_gold_rely(address(End));
    ADMIN.Vat_file("Line", 1000000000000);
    ADMIN.Vat_file("spot", "gold", 3000000000);
    ADMIN.Vat_file("line", "gold", 1000000000000);
    ADMIN.Vow_file("bump", 1000000000);
    ADMIN.Vow_file("hump", 0);
    ADMIN.Gem_gold_mint(address(Alice), 20);
    ADMIN.Gem_gold_mint(address(Bobby), 20);
    Alice.Vat_hope(address(Pot));
    Alice.Vat_hope(address(Flip_gold));
    Alice.Vat_hope(address(End));
    Bobby.Vat_hope(address(Pot));
    Bobby.Vat_hope(address(Flip_gold));
    Bobby.Vat_hope(address(End));
    Alice.GemJoin_gold_join(address(Alice), 10);
    Bobby.GemJoin_gold_join(address(Bobby), 10);
    Alice.Vat_frob("gold", address(Alice), address(Alice), address(Alice), 10, 10);
    Bobby.Vat_frob("gold", address(Bobby), address(Bobby), address(Bobby), 10, 10);
    Bobby.Vat_move(address(Bobby), address(Bobby), 135_/Rat_64);
    ADMIN.Pot_file("dsr", 273_/Rat_256);
    hevm.warp(2);
    Bobby.GemJoin_gold_join(address(Bobby), 265_/Rat_64);
    Alice.Vat_hope(address(Alice));
    hevm.warp(2);
    hevm.warp(2);
    
    // Assertions
    assertTrue( Gems.cell() == GemCellMapItem( <gem-id> "gold" </gem-id> , <gem> <gem-id> "gold" </gem-id> <gem-wards> .Set </gem-wards> <gem-balances> GemJoin "gold" |-> 1545 /Rat 64 "Bobby" |-> 375 /Rat 64 "Alice" |-> 10 </gem-balances> </gem> ) );
    assertTrue( Pot.dsr() == 273 /Rat 256 );
    assertTrue( Vat.can() == "Bobby" |-> SetItem( Flip "gold" ) SetItem( End ) SetItem( Pot ) "Alice" |-> SetItem( Flip "gold" ) SetItem( "Alice" ) SetItem( End ) SetItem( Pot ) );
    assertTrue( Vat.gem() == { "gold" , Flip "gold" } |-> 0 { "gold" , "Bobby" } |-> 265 /Rat 64 { "gold" , "Alice" } |-> 0 { "gold" , End } |-> 0 );
    

iamchrissmith
iamchrissmith previously approved these changes Feb 13, 2020
Copy link
Contributor

@iamchrissmith iamchrissmith left a comment

Choose a reason for hiding this comment

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

I would say lets get this merged in and improve from there, but the assertions example seems to be pretty heavy in the state changes and not quite solidity ready. I'll take a look at how that can be improved.

@iamchrissmith iamchrissmith dismissed their stale review February 13, 2020 16:13

looks like there is an issue with this change. the jenkins is failing and i get an error locally

Copy link
Contributor

@kmbarry1 kmbarry1 left a comment

Choose a reason for hiding this comment

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

Agree w/@iamchrissmith that the assertions will need some massaging, but I don't really see that as a reason to block this PR (except that Jenkins is complaining it can't build, of course).

@iamchrissmith iamchrissmith merged commit 03b821e into master Feb 13, 2020
@ehildenb ehildenb deleted the assertions branch February 13, 2020 18:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants