Skip to content

Commit

Permalink
updating master from shadow master (#414)
Browse files Browse the repository at this point in the history
* disabling the pager in my pretty printing run script

* change the elaboration of `new` and non-local Invocations to match the flat yul object style (#367)

* making a change to double check work flow

* adding a stub for computing the size of a contract; that'll be its own PR entirely one day fairly soon, but for now, we assume that we just need 32 bytes

* using hex values for some boilerplate so that it matches the docs

* reworking constructors to just allocate memory

* adding some helper functions in util. one is a renaming for transactions from child contracts; the other is basically a type-checked comment pointing out uses of some pretty substantian technical debt

* temporarily removing the code to translate child contracts. rewriting the translation of Invocations to remap everything to local invocations instead, into the names that will be created in the flat yul object

* removing an assertion and adding translation of string literals

* whitespace, scala style

* utility function for undoing the transaction renaming

* generate flat yul object from child contracts (#369)

* rename, add boolean for main-ness in translate decl

* changing signature of translateDeclaration to remove a return that doesn't do anything

* whitespace, scala style

* comments

* scraps; adding an assert

* changing how child contracts are processed

* rewrite of translateTransaction

* chainging signature of translateStatement

* more threading through inMain

* whitespace, scala style

* adding some docs

* removing the nicer output for typed names in favor of a bland one, per solc's current limitations. adding a comment about why.

* adding a temporary fix to the top of the dispatch table pending talking with MC"

* removing a stale comment

* comments

* adding missing declarations to invocations

* cleaning up comments and some messy logic around temporary variables

* removing comment

* more hacks for specific tests in advance of type info

* changing hardcoded value in the mustache file for this to be the current contract address

* adding a couple of args to get this to typecheck

* use type annotations in Yul codegen (#377)

* removing a util function to rename functions in the dispatch table; that no longer makes sense with the solution for flattening that we've settled on for now

* adding comments; expanding getcontractname

* ripping out some code, adding comments

* adding a comment that may help to locate a bug later

* moving comment closer to the source and updating it

* comments

* scraps; this change seemed likely but breaks a bunch of tests

* quick function to traverse over an expression and check a given predicate on all the annotations

* fixing some import dependencies

* traversal of a program rather than just an expression; i sure hope i don't have to come back and make this the fully polymorphic map reduce but i bet i will

* adding updates to the expression returned in the checker from just the ReferenceIdentifier cases, after some debugging with @mcoblenz

* adding additional ParserUtil.updateExprType uses as seems right. bunch of tests fail, some of which i expected some i didn't, and i don't know how to fix a lot of them

* updating width calculation to actually inspect the type, now that we know it

* removing an assert that caused a bunch of false negatives.

* small changes per PR comments

* copying a slightly cut down version of linked lists, but this needs to be edited down even more to be the right goal for a demo.

* compute the sizes of contracts for allocation (#378)

* copying a slightly cut down version of linked lists, but this needs to be edited down even more to be the right goal for a demo.

* computing sizes of types recursively

* adding some simple hard coded unit tests

* copying over a helper from type checker tests to test on actual contracts in files

* adding more general tests; it doesn't work but i think i know why

* scraps and printlines from trying to debug sizes

* changing the type of the size computation function so it has enough information, per MC. reworking tests

* renaming size function; fixing the main test

* adding some comments and a variable for pointer sizes

* formatting, reworking base test

* removing the two simpler unit tests. it is hard and somewhat pointless to be the parser and create a contract table by hand, the existing test is informative enough

* fixing type checker errors (#380)

* debugging scraps

* copying a slightly cut down version of linked lists, but this needs to be edited down even more to be the right goal for a demo.

* commenting out spammy prints

* patch from MC

* updating override syntax to not introduce a new field

* updating expr type update to set the location and use the one field rather than build new ones

* removing printlines

* updating logged errors in a few places; this fixes some but not all of #379

* error in resourcesTest was in the test itself; it was incorrectly looking for m to be at int

* formatting, whitespace

* fixed permission passing test; also errors in the definition of the test, not the checker

* fixing all permowned error

* scala style, whitespace

* scraps

* adding a comment, removing a comment, removing an assert

* compute offsets, store fields in memory (#384)

* fixing a bug in computing sizes by translating from set to list; adding an assert; whitespace and style

* adding helper to compute offsets

* typoe and adding a test to demonstrate that the bug computing sizes is gone

* adding a sandbox test case file

* adding a traversal of the declarations sequence in the contract rather than relying on the toList of an unordered collection; using that helper function both in computing sizes and offsets

* refactoring tests for util functions to reuse the code to produce a symbol table; adding tests for computing offests

* style, whitespace

* a couple more tests for offsets

* a couple more tests for offsets

* updating tests, adding comments for myself

* helper to wrap call to field offsets, changing sload and sstore to m*

* updating test to show that fields get overwritten; adding json so it gets run because it passes

* messing with test files

* changing the ganache test script to use the test skipping checking script that i think works across platforms, per #361

* adding sort, per #631

* scala style, fussy fixes to doc strings etc

* scala style, fussy fixes to doc strings etc

* scala style, fussy fixes to doc strings etc

* scala style, fussy fixes to doc strings etc

* some house keeping to clean up a util function, removing a source of bugs related to computing sizes

* refactoring to change the definition of typed name to have an actual type in it, not just its string representation

* adding clause to type name helper for contracts

* whitespace in obsidian files

* housekeeping, adding docs and removing stale todos

* Adding another passing test

* updating travis test script to work with solc 0.8.10

* iterating on travis script

* allocate fields with pointers, rewrite yulobject and mustache interaction to reflect current object layout (#388)

* adding test case for nonprimitive fields in the main contract

* adding an ownership to the test field to make it valid obsidian

* removing some dead code

* removing unused childContracts argument from YulObject

* scraps

* new test

* fixing local util script for new version of solc, adding a little code for #389 but not a complete idea yet

* scraps

* rewriting yulobject to take an optional int to indicate the size of the main contract and if the contract being elaborated is the main one (if it has as size). this is temporary and not going to last

* removing what i am nearly positive is dead code

* first half of a big rewrite of the YulObject class

* back half of the refactor to update code generation

* adding some todos and notes

* scraps, scala style and whitespace

* scraps

* updating the implementation of switch toString to not print out invalid switches with no branches. this fixes the emptycontract dispatch table.

* scraps

* add the this argument uniformly in codegen not printing, and only remove it for the hashed dispatch table entries

* pulling the body of local invocation out into a helper so that it can get called in both places with different  arguments

* documentation, cleaning up todos

* scraps

* adding a little more documentation

* functions with arguments (#394)

* adding test case for nonprimitive fields in the main contract

* adding an ownership to the test field to make it valid obsidian

* removing some dead code

* removing unused childContracts argument from YulObject

* scraps

* new test

* fixing local util script for new version of solc, adding a little code for #389 but not a complete idea yet

* scraps

* rewriting yulobject to take an optional int to indicate the size of the main contract and if the contract being elaborated is the main one (if it has as size). this is temporary and not going to last

* removing what i am nearly positive is dead code

* first half of a big rewrite of the YulObject class

* back half of the refactor to update code generation

* adding some todos and notes

* scraps, scala style and whitespace

* scraps

* updating the implementation of switch toString to not print out invalid switches with no branches. this fixes the emptycontract dispatch table.

* scraps

* add the this argument uniformly in codegen not printing, and only remove it for the hashed dispatch table entries

* pulling the body of local invocation out into a helper so that it can get called in both places with different  arguments

* documentation, cleaning up todos

* scraps

* renaming some files

* removing half baked linked list test

* typo

* adding json so this test gets run in Travis

* translate constrctors to transactions on the flattened object (#396)

* updating test case so that it compiled and hits missing code

* Adding new test cases

* adding code so that constructors get emitted, named with a hash of their arguments so that objecst with multiple consturctors can call whichever one

* fixed constructors with arguments

* updating ganache test suite with a few constructor examples

* adding code to constructor elaboration to not generate a call to a constructor that doesn't exist

* monkeying around with the install script

* monkeying around with the install script

* monkeying around with the install script

* monkeying around with the install script

* monkeying with travis more

* adding version info to output

* Adding debugging output

* debugging output

* monkeying with the host name

* test script

* trying running ganache on localhost directly

* following some shellcheck fixes

* moving npm commands around

* checking for ganache in the processes

* unhiding ganache output

* downgrading node to LTS version 16

* moving some install commands around, trying to get a lower version of node

* adding possible node work around

* env vars

* undoing env vars, since the 16 now got picked up

* removing debug messages

* removing the ganache install script since that's in travis.yml now

* scraps

* support integer arguments to the main function (#400)

* adding a test case to show that an old bug got fixed. closes #334

* adding a new test case to show that arguments are not currently passed to main

* adding a different presentation of the tests info while i'm thinking of it

* fixing a bad change to IDE settings

* adding a yul statement for comments

* adding helpers to compute abi decoder functions and insert them into the dispatch table and emit them in the body of the object

* updating test cases

* removing old test

* removing old test

* code to decode individual ints, using that to decode tuples, emitting it in the output file

* i forget to change the name of the contract every single time i copy a test

* traveseing the params not the returns

* renaming, scraps

* fixing an error in the ABI names we map to

* removing a todo
"

* scraps, scala style

* adding parameters to the json for the two tests that use them; the technical debt here is quickly becoming too much but i want to make sure this works before doing a pass at rewriting the test harness

* removing duplicate decoders from output, only assigning params to locals if there are more than 0 of them. this should make the old tests pass again

* using distinct instead of hard to read translations to and from set

* Adding some documentation and removing some todos

* fixing json for mainargs1, updating test script to read json for the two new tests in a slightly hacky and specific way

* increasing the padding size on arguments

* test.json is kind of part of a rewrite of the test infrastructure and not really part of this PR. so it doesn't belong in this branch anyway AND is breaking the tests

* removing some dead boilerplate

* updating the padding to the right length in the test script; removing a dead call to decode

* scala style and whitespace

* scraps, comments

* adding a case class for yul types (#403)

* working on #401, this is kind of experimental

* adding a case for user defied types

* adding documentation

* updates to the testing harness (#408)

* adding a test case to show that an old bug got fixed. closes #334

* adding a new test case to show that arguments are not currently passed to main

* adding a different presentation of the tests info while i'm thinking of it

* fixing a bad change to IDE settings

* adding a yul statement for comments

* adding helpers to compute abi decoder functions and insert them into the dispatch table and emit them in the body of the object

* updating test cases

* removing old test

* removing old test

* code to decode individual ints, using that to decode tuples, emitting it in the output file

* i forget to change the name of the contract every single time i copy a test

* traveseing the params not the returns

* renaming, scraps

* fixing an error in the ABI names we map to

* removing a todo
"

* scraps, scala style

* adding parameters to the json for the two tests that use them; the technical debt here is quickly becoming too much but i want to make sure this works before doing a pass at rewriting the test harness

* removing duplicate decoders from output, only assigning params to locals if there are more than 0 of them. this should make the old tests pass again

* using distinct instead of hard to read translations to and from set

* Adding some documentation and removing some todos

* fixing json for mainargs1, updating test script to read json for the two new tests in a slightly hacky and specific way

* increasing the padding size on arguments

* test.json is kind of part of a rewrite of the test infrastructure and not really part of this PR. so it doesn't belong in this branch anyway AND is breaking the tests

* removing some dead boilerplate

* updating the padding to the right length in the test script; removing a dead call to decode

* scala style and whitespace

* scraps, comments

* removing old json in favor of one flat file with less redundancy

* python version of travis script

* more testing script rewrite

* yaml farming

* yaml farming

* yaml farming

* test script rewrite progress

* adding a make target to build a jar quickly, without doing all the test suite

* test script rewrite progress

* test script rewrite progress

* yaml farming, test script work

* finally reworked account polling

* yaml farming, transactions

* updating tests format a little, more testing script updates

* yaml farming, more test script updates

* adding transaction names for primops tests, more verbose output

* removing 2s complement script since it's now in the testing script

* Adding decoding from bytearrays and arguments for the two tests that expect args to main

* add a script to kill stray ganache instances, update return2 test so it passes

* removing the deprecated bash travis script for running ganache tests

* making verbose flag toggle output from ganache-cli as well

* fussing with test script

* pulling magic constants for port and host name out, fixing a typo

* whitesapce, pystyle

* documenting, taking out a couple todos

* quick fix

* emit tracers for each contract (#404)

* new test case

* adding field to yul object for tracers

* emitting tracers per contract, but it's per instance of contract so it's not unique. this isn't the right way to do this

* removing duplicates in a hamfisted way

* log calls and leave

* updating tracing test case

* updates from flat alloc into master (#409)

* disabling the pager in my pretty printing run script

* change the elaboration of `new` and non-local Invocations to match the flat yul object style (#367)

* making a change to double check work flow

* adding a stub for computing the size of a contract; that'll be its own PR entirely one day fairly soon, but for now, we assume that we just need 32 bytes

* using hex values for some boilerplate so that it matches the docs

* reworking constructors to just allocate memory

* adding some helper functions in util. one is a renaming for transactions from child contracts; the other is basically a type-checked comment pointing out uses of some pretty substantian technical debt

* temporarily removing the code to translate child contracts. rewriting the translation of Invocations to remap everything to local invocations instead, into the names that will be created in the flat yul object

* removing an assertion and adding translation of string literals

* whitespace, scala style

* utility function for undoing the transaction renaming

* generate flat yul object from child contracts (#369)

* rename, add boolean for main-ness in translate decl

* changing signature of translateDeclaration to remove a return that doesn't do anything

* whitespace, scala style

* comments

* scraps; adding an assert

* changing how child contracts are processed

* rewrite of translateTransaction

* chainging signature of translateStatement

* more threading through inMain

* whitespace, scala style

* adding some docs

* removing the nicer output for typed names in favor of a bland one, per solc's current limitations. adding a comment about why.

* adding a temporary fix to the top of the dispatch table pending talking with MC"

* removing a stale comment

* comments

* adding missing declarations to invocations

* cleaning up comments and some messy logic around temporary variables

* removing comment

* more hacks for specific tests in advance of type info

* changing hardcoded value in the mustache file for this to be the current contract address

* adding a couple of args to get this to typecheck

* use type annotations in Yul codegen (#377)

* removing a util function to rename functions in the dispatch table; that no longer makes sense with the solution for flattening that we've settled on for now

* adding comments; expanding getcontractname

* ripping out some code, adding comments

* adding a comment that may help to locate a bug later

* moving comment closer to the source and updating it

* comments

* scraps; this change seemed likely but breaks a bunch of tests

* quick function to traverse over an expression and check a given predicate on all the annotations

* fixing some import dependencies

* traversal of a program rather than just an expression; i sure hope i don't have to come back and make this the fully polymorphic map reduce but i bet i will

* adding updates to the expression returned in the checker from just the ReferenceIdentifier cases, after some debugging with @mcoblenz

* adding additional ParserUtil.updateExprType uses as seems right. bunch of tests fail, some of which i expected some i didn't, and i don't know how to fix a lot of them

* updating width calculation to actually inspect the type, now that we know it

* removing an assert that caused a bunch of false negatives.

* small changes per PR comments

* copying a slightly cut down version of linked lists, but this needs to be edited down even more to be the right goal for a demo.

* compute the sizes of contracts for allocation (#378)

* copying a slightly cut down version of linked lists, but this needs to be edited down even more to be the right goal for a demo.

* computing sizes of types recursively

* adding some simple hard coded unit tests

* copying over a helper from type checker tests to test on actual contracts in files

* adding more general tests; it doesn't work but i think i know why

* scraps and printlines from trying to debug sizes

* changing the type of the size computation function so it has enough information, per MC. reworking tests

* renaming size function; fixing the main test

* adding some comments and a variable for pointer sizes

* formatting, reworking base test

* removing the two simpler unit tests. it is hard and somewhat pointless to be the parser and create a contract table by hand, the existing test is informative enough

* fixing type checker errors (#380)

* debugging scraps

* copying a slightly cut down version of linked lists, but this needs to be edited down even more to be the right goal for a demo.

* commenting out spammy prints

* patch from MC

* updating override syntax to not introduce a new field

* updating expr type update to set the location and use the one field rather than build new ones

* removing printlines

* updating logged errors in a few places; this fixes some but not all of #379

* error in resourcesTest was in the test itself; it was incorrectly looking for m to be at int

* formatting, whitespace

* fixed permission passing test; also errors in the definition of the test, not the checker

* fixing all permowned error

* scala style, whitespace

* scraps

* adding a comment, removing a comment, removing an assert

* compute offsets, store fields in memory (#384)

* fixing a bug in computing sizes by translating from set to list; adding an assert; whitespace and style

* adding helper to compute offsets

* typoe and adding a test to demonstrate that the bug computing sizes is gone

* adding a sandbox test case file

* adding a traversal of the declarations sequence in the contract rather than relying on the toList of an unordered collection; using that helper function both in computing sizes and offsets

* refactoring tests for util functions to reuse the code to produce a symbol table; adding tests for computing offests

* style, whitespace

* a couple more tests for offsets

* a couple more tests for offsets

* updating tests, adding comments for myself

* helper to wrap call to field offsets, changing sload and sstore to m*

* updating test to show that fields get overwritten; adding json so it gets run because it passes

* messing with test files

* changing the ganache test script to use the test skipping checking script that i think works across platforms, per #361

* adding sort, per #631

* scala style, fussy fixes to doc strings etc

* scala style, fussy fixes to doc strings etc

* scala style, fussy fixes to doc strings etc

* scala style, fussy fixes to doc strings etc

* some house keeping to clean up a util function, removing a source of bugs related to computing sizes

* refactoring to change the definition of typed name to have an actual type in it, not just its string representation

* adding clause to type name helper for contracts

* whitespace in obsidian files

* housekeeping, adding docs and removing stale todos

* Adding another passing test

* updating travis test script to work with solc 0.8.10

* iterating on travis script

* allocate fields with pointers, rewrite yulobject and mustache interaction to reflect current object layout (#388)

* adding test case for nonprimitive fields in the main contract

* adding an ownership to the test field to make it valid obsidian

* removing some dead code

* removing unused childContracts argument from YulObject

* scraps

* new test

* fixing local util script for new version of solc, adding a little code for #389 but not a complete idea yet

* scraps

* rewriting yulobject to take an optional int to indicate the size of the main contract and if the contract being elaborated is the main one (if it has as size). this is temporary and not going to last

* removing what i am nearly positive is dead code

* first half of a big rewrite of the YulObject class

* back half of the refactor to update code generation

* adding some todos and notes

* scraps, scala style and whitespace

* scraps

* updating the implementation of switch toString to not print out invalid switches with no branches. this fixes the emptycontract dispatch table.

* scraps

* add the this argument uniformly in codegen not printing, and only remove it for the hashed dispatch table entries

* pulling the body of local invocation out into a helper so that it can get called in both places with different  arguments

* documentation, cleaning up todos

* scraps

* adding a little more documentation

* functions with arguments (#394)

* adding test case for nonprimitive fields in the main contract

* adding an ownership to the test field to make it valid obsidian

* removing some dead code

* removing unused childContracts argument from YulObject

* scraps

* new test

* fixing local util script for new version of solc, adding a little code for #389 but not a complete idea yet

* scraps

* rewriting yulobject to take an optional int to indicate the size of the main contract and if the contract being elaborated is the main one (if it has as size). this is temporary and not going to last

* removing what i am nearly positive is dead code

* first half of a big rewrite of the YulObject class

* back half of the refactor to update code generation

* adding some todos and notes

* scraps, scala style and whitespace

* scraps

* updating the implementation of switch toString to not print out invalid switches with no branches. this fixes the emptycontract dispatch table.

* scraps

* add the this argument uniformly in codegen not printing, and only remove it for the hashed dispatch table entries

* pulling the body of local invocation out into a helper so that it can get called in both places with different  arguments

* documentation, cleaning up todos

* scraps

* renaming some files

* removing half baked linked list test

* typo

* adding json so this test gets run in Travis

* translate constrctors to transactions on the flattened object (#396)

* updating test case so that it compiled and hits missing code

* Adding new test cases

* adding code so that constructors get emitted, named with a hash of their arguments so that objecst with multiple consturctors can call whichever one

* fixed constructors with arguments

* updating ganache test suite with a few constructor examples

* adding code to constructor elaboration to not generate a call to a constructor that doesn't exist

* monkeying around with the install script

* monkeying around with the install script

* monkeying around with the install script

* monkeying around with the install script

* monkeying with travis more

* adding version info to output

* Adding debugging output

* debugging output

* monkeying with the host name

* test script

* trying running ganache on localhost directly

* following some shellcheck fixes

* moving npm commands around

* checking for ganache in the processes

* unhiding ganache output

* downgrading node to LTS version 16

* moving some install commands around, trying to get a lower version of node

* adding possible node work around

* env vars

* undoing env vars, since the 16 now got picked up

* removing debug messages

* removing the ganache install script since that's in travis.yml now

* scraps

* support integer arguments to the main function (#400)

* adding a test case to show that an old bug got fixed. closes #334

* adding a new test case to show that arguments are not currently passed to main

* adding a different presentation of the tests info while i'm thinking of it

* fixing a bad change to IDE settings

* adding a yul statement for comments

* adding helpers to compute abi decoder functions and insert them into the dispatch table and emit them in the body of the object

* updating test cases

* removing old test

* removing old test

* code to decode individual ints, using that to decode tuples, emitting it in the output file

* i forget to change the name of the contract every single time i copy a test

* traveseing the params not the returns

* renaming, scraps

* fixing an error in the ABI names we map to

* removing a todo
"

* scraps, scala style

* adding parameters to the json for the two tests that use them; the technical debt here is quickly becoming too much but i want to make sure this works before doing a pass at rewriting the test harness

* removing duplicate decoders from output, only assigning params to locals if there are more than 0 of them. this should make the old tests pass again

* using distinct instead of hard to read translations to and from set

* Adding some documentation and removing some todos

* fixing json for mainargs1, updating test script to read json for the two new tests in a slightly hacky and specific way

* increasing the padding size on arguments

* test.json is kind of part of a rewrite of the test infrastructure and not really part of this PR. so it doesn't belong in this branch anyway AND is breaking the tests

* removing some dead boilerplate

* updating the padding to the right length in the test script; removing a dead call to decode

* scala style and whitespace

* scraps, comments

* adding a case class for yul types (#403)

* working on #401, this is kind of experimental

* adding a case for user defied types

* adding documentation

* updates to the testing harness (#408)

* adding a test case to show that an old bug got fixed. closes #334

* adding a new test case to show that arguments are not currently passed to main

* adding a different presentation of the tests info while i'm thinking of it

* fixing a bad change to IDE settings

* adding a yul statement for comments

* adding helpers to compute abi decoder functions and insert them into the dispatch table and emit them in the body of the object

* updating test cases

* removing old test

* removing old test

* code to decode individual ints, using that to decode tuples, emitting it in the output file

* i forget to change the name of the contract every single time i copy a test

* traveseing the params not the returns

* renaming, scraps

* fixing an error in the ABI names we map to

* removing a todo
"

* scraps, scala style

* adding parameters to the json for the two tests that use them; the technical debt here is quickly becoming too much but i want to make sure this works before doing a pass at rewriting the test harness

* removing duplicate decoders from output, only assigning params to locals if there are more than 0 of them. this should make the old tests pass again

* using distinct instead of hard to read translations to and from set

* Adding some documentation and removing some todos

* fixing json for mainargs1, updating test script to read json for the two new tests in a slightly hacky and specific way

* increasing the padding size on arguments

* test.json is kind of part of a rewrite of the test infrastructure and not really part of this PR. so it doesn't belong in this branch anyway AND is breaking the tests

* removing some dead boilerplate

* updating the padding to the right length in the test script; removing a dead call to decode

* scala style and whitespace

* scraps, comments

* removing old json in favor of one flat file with less redundancy

* python version of travis script

* more testing script rewrite

* yaml farming

* yaml farming

* yaml farming

* test script rewrite progress

* adding a make target to build a jar quickly, without doing all the test suite

* test script rewrite progress

* test script rewrite progress

* yaml farming, test script work

* finally reworked account polling

* yaml farming, transactions

* updating tests format a little, more testing script updates

* yaml farming, more test script updates

* adding transaction names for primops tests, more verbose output

* removing 2s complement script since it's now in the testing script

* Adding decoding from bytearrays and arguments for the two tests that expect args to main

* add a script to kill stray ganache instances, update return2 test so it passes

* removing the deprecated bash travis script for running ganache tests

* making verbose flag toggle output from ganache-cli as well

* fussing with test script

* pulling magic constants for port and host name out, fixing a typo

* whitesapce, pystyle

* documenting, taking out a couple todos

* quick fix

* removing deprecated indiviual test json files

* updating tests json

* removing trace this test because it seems to take an unbounded amount of gas

* fix broken nested intcontinater test (#411)

* new tests case & scraps

* adding a docker running check to save me a local annoyance; pushing it to git to make sure it doesn't break travis

* docs

* logging scraps

* partial rewrite to using pyweb3

* yaml farming

* adding exception handling around the web3 calls

* restored functionality with web3, no logs yet, pushing to travis to make sure it works there on all the tests

* cleaning up a little bit, adding log calls

* using Web3's hash implementation

* yaml farming

* using web3 solidity abi encoder which uses a packed representation that may still work

* removing trial with packed abi representation

* scraps

* tracethis seems to take a ton of gas, so i'm going to leave that test failing in this branch but remove it from shadowmaster

* moving test json around

* updating the nested example so that it compiles

* renaming test

* Adding test case

* removing TraceThis test definition because that doesn't work yet

* Flat readlogs (#412)

* adding a docker running check to save me a local annoyance; pushing it to git to make sure it doesn't break travis

* docs

* logging scraps

* partial rewrite to using pyweb3

* yaml farming

* adding exception handling around the web3 calls

* restored functionality with web3, no logs yet, pushing to travis to make sure it works there on all the tests

* cleaning up a little bit, adding log calls

* using Web3's hash implementation

* yaml farming

* using web3 solidity abi encoder which uses a packed representation that may still work

* removing trial with packed abi representation

* scraps

* tracethis seems to take a ton of gas, so i'm going to leave that test failing in this branch but remove it from shadowmaster

* adding a --stash option to the commandline for obsidianc, threading it through to codegen'

* new test case

* adding dispatch table and decode entries to make the stash-getter visible

* removing a warning, [warn] Ignored unknown package option FixedTimestamp(None)

* updating test case

* removing calls to log0 in favor of stashing, updating the implemtation of stash to advance through storage

* typo

* Adding a bit of a hack to get the tracer called

* scraps

* scraps

* updating travis yaml and options for new ganache version

* removing getstash implementation and the junk in the dispatch table generation that opened it up

* invoke and deploy sends

* .idea directory changes because i added some python support and also updated to the most recent version of intellij

* scraps

* writing to 4 adjacent places in storage

* adding proof that logs are also present and i can detect them

* removing stash commandline arg from compiler and everything it percolates down to

* updating test case name and test harness to check the logs instead of a stashing address

* cleaning up for a PR; hacks on hacks

* fixing a test case
  • Loading branch information
ivoysey committed Feb 15, 2022
1 parent 6a107ce commit 4033149
Show file tree
Hide file tree
Showing 19 changed files with 377 additions and 194 deletions.
12 changes: 12 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules/project/build.properties

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions .idea/runConfigurations.xml

This file was deleted.

1 change: 1 addition & 0 deletions .idea/sbt.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ jdk:
- oraclejdk12 # as of 10 june 2021, up to jdk12 works but 13+ fail

before_install:
- nvm install 16 # as of 19 nov 2021, this version of node works with ganache and 17 does not
- nvm install 17 # as of 26 jan 2022, node 17 works with ganache 7 (below)
- npm install -g npm # update npm
- npm install -g ganache-cli # install ganache
- python -m pip install termcolor eth_abi polling httpx pycryptodome
- npm install -g ganache@>=7.0.0 # install ganache
- python -m pip install termcolor eth_abi polling web3

install:
- gradle publish -b Obsidian_Runtime/build.gradle
Expand Down
4 changes: 3 additions & 1 deletion Obsidian_Runtime/src/main/yul_templates/object.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ object "{{contractName}}" {
}

{{transactions}}

{{tracertransactions}}
}
}
}
}
4 changes: 0 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,3 @@ assembly / assemblyMergeStrategy := {
val oldStrategy = ( assembly / assemblyMergeStrategy).value
oldStrategy(x)
}

// adding this to squelch a warning per https://github.com/sbt/sbt/pull/6237

ThisBuild / packageTimestamp := Package.keepTimestamps
8 changes: 0 additions & 8 deletions resources/tests/GanacheTests/Return2.json

This file was deleted.

26 changes: 26 additions & 0 deletions resources/tests/GanacheTests/SetGetLogs.obs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
contract IntContainer{
int x;

transaction set(int value) {
x = value;
}
transaction get() returns int{
return x;
}
}

main contract SetGetLogs{
IntContainer@Owned ic1;
IntContainer@Owned ic2;
IntContainer@Owned ic3;

transaction main_sgl() returns int{
ic1 = new IntContainer();
ic2 = new IntContainer();
ic3 = new IntContainer();
ic1.set(5);
ic2.set(5);
ic3.set(5);
return (ic1.get() + ic2.get() + ic3.get());
}
}
11 changes: 0 additions & 11 deletions resources/tests/GanacheTests/SetGetMainArgs1.json

This file was deleted.

11 changes: 0 additions & 11 deletions resources/tests/GanacheTests/SetGetMainArgs3.json

This file was deleted.

40 changes: 40 additions & 0 deletions resources/tests/GanacheTests/SetGetNestedPointerArg.obs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
contract IntContainer{
int x;

IntContainer@Owned(int init) {
x = init;
}

transaction set(int value) {
x = value;
}

transaction get() returns int{
return x;
}
}

contract IntContainerWrapper{
IntContainer@Unowned ic;

IntContainerWrapper@Owned(IntContainer@Unowned icarg) {
ic = icarg;
}

transaction set(int value) {
ic.set(value);
}

transaction get() returns int{
return (ic.get());
}
}

main contract SetGetNestedPointerArg{
transaction main() returns int{
IntContainer ic = new IntContainer(0);
IntContainerWrapper iw = new IntContainerWrapper(ic);
iw.set(5);
return(iw.get());
}
}
39 changes: 39 additions & 0 deletions resources/tests/GanacheTests/SetGetNestedPointerPassThrough.obs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
contract IntContainer{
int x;

IntContainer@Owned(int init) {
x = init;
}

transaction set(int value) {
x = value;
}

transaction get() returns int{
return x;
}
}

contract IntContainerWrapper{
IntContainer@Owned ic;

IntContainerWrapper@Owned() {
ic = new IntContainer(0);
}

transaction set(int value) {
ic.set(value);
}

transaction get() returns int{
return (ic.get());
}
}

main contract SetGetNestedPointerPassThrough{
transaction main() returns int{
IntContainerWrapper iw = new IntContainerWrapper();
iw.set(5);
return(iw.get());
}
}
55 changes: 55 additions & 0 deletions resources/tests/GanacheTests/TraceThis.obs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
contract IntContainer{
int x;

transaction set(int arg) {
x = arg;
}

transaction get() returns int{
return x;
}
}

contract IntContainerBox{
IntContainer@Owned ic1;
IntContainer@Owned ic2;
IntContainer@Owned ic3;

transaction set3(int arg1, int arg2, int arg3) {
ic1.set(arg1);
ic2.set(arg2);
ic3.set(arg3);
}

transaction getsum() returns int{
return ic1.get() + ic2.get() + ic3.get() + 4;
}
}

contract IntContainerBoxBag{
IntContainerBox@Owned icb1;
IntContainerBox@Owned icb2;

transaction set2(int arg1, int arg2, int arg3) {
icb1.set3(arg1 * arg1, arg2 * arg2, arg3 * arg3);
icb2.set3(arg1 + arg1, arg2 + arg2, arg3 + arg3);
}

transaction get() returns int{
return icb1.getsum() - icb2.getsum();
}
}

main contract TraceThis {
// having two will show that the tracer gets called twice and on two different addresses
IntContainerBoxBag@Owned ic1;
IntContainerBoxBag@Owned ic2;

transaction main() returns int{
ic1 = new IntContainerBoxBag();
ic1.set2(5,20,-19);
ic2 = new IntContainerBoxBag();
ic2.set2(500,0,1219);
return ic1.get() + ic2.get();
}
}
17 changes: 17 additions & 0 deletions resources/tests/GanacheTests/tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,23 @@
"file": "SimpleCall.obs",
"expected": "4",
"shows_that_we_support": "calling a transaction and setting a variable as a result"
},
{
"file": "SetGetNestedPointerPassThrough.obs",
"expected": "5",
"shows_that_we_support": "contracts with fields that refer to other contracts when the wrapper is a simple pass through"
},
{
"file": "SetGetNestedPointerArg.obs",
"expected": "5",
"shows_that_we_support": "contracts with fields that refer to other contracts that they take as arguments"
},
{
"file": "SetGetLogs.obs",
"expected": "15",
"trans" : "main_sgl",
"logged" : [320,320,320,320],
"shows_that_we_support": "simple set-get with tracers that emit logged values"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ object CodeGenJava extends CodeGenerator{

def gen(filename: String, srcDir: Path, outputPath: Path, protoDir: Path,
options: CompilerOptions, checkedTable: SymbolTable, transformedTable: SymbolTable): Boolean = {

val lastSlash = filename.lastIndexOf(File.separator)
val sourceFilename = if (lastSlash < 0) filename else filename.substring(lastSlash + 1)

Expand Down
46 changes: 42 additions & 4 deletions src/main/scala/edu/cmu/cs/obsidian/codegen/CodeGenYul.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package edu.cmu.cs.obsidian.codegen

import edu.cmu.cs.obsidian.CompilerOptions
import edu.cmu.cs.obsidian.typecheck.{NonPrimitiveType, ObsidianType, UnitType}
import edu.cmu.cs.obsidian.typecheck.{ContractReferenceType, NonPrimitiveType, ObsidianType, UnitType}

import java.io.{File, FileWriter}
import java.nio.file.{Files, Path, Paths}
Expand All @@ -13,7 +13,6 @@ import edu.cmu.cs.obsidian.parser._
import edu.cmu.cs.obsidian.typecheck.ContractType

object CodeGenYul extends CodeGenerator {

// we generate new temporary variables with a little bit of global state; i am making the
// implicit assumption that nothing except nextTemp will modify the contents of tempCnt, even
// though that is not enforced statically.
Expand Down Expand Up @@ -97,15 +96,54 @@ object CodeGenYul extends CodeGenerator {
}
}


// nb: we do not process imports
YulObject(contractName = mainContract.name,
data = Seq(), // nb: we currently ignore data so this is empty
data = Seq(),
mainContractTransactions = mainContract.declarations.flatMap(d => translateDeclaration(d, mainContract.name, checkedTable, inMain = true)),
mainContractSize = sizeOfContractST(mainContract.name, checkedTable),
otherTransactions = program.contracts.flatMap(translateNonMains)
otherTransactions = program.contracts.flatMap(translateNonMains),
tracers = writeTracers(checkedTable, mainContract.name)
)
}

def nameTracer(name: String): String = {
s"trace_$name"
}

def writeTracers(ct : SymbolTable, name: String): Seq[FunctionDefinition] = {
val c: Contract = ct.contract(name) match {
case Some(value) => value.contract
case None => throw new RuntimeException()
}

var body: Seq[YulStatement] = Seq()
var others: Seq[FunctionDefinition] = Seq()

for(d <- c.declarations){
d match {
case Field(_, typ, fname, _) => typ match {
case t : NonPrimitiveType => t match {
case ContractReferenceType(contractType, _, _) =>
body = body :+ ExpressionStatement(apply(nameTracer(contractType.contractName), fieldFromThis(ct.contractLookup(name),fname)))
others = others ++ writeTracers(ct, contractType.contractName)
case _ => Seq()
}
case _ => Seq()
}
case _ => Seq()
}
}

FunctionDefinition(name = nameTracer(name),
parameters = Seq(TypedName("this",YATAddress())),
returnVariables = Seq(),
body = Block(Seq(
ExpressionStatement(apply("log0",intlit(64),intlit(32)))
) ++ body :+ Leave())
) +: others.distinctBy(fd => fd.name)
}

/**
* compute the translation of a declaration into yul with respect to its context in the larger
* obsidian program
Expand Down

0 comments on commit 4033149

Please sign in to comment.