├── docs ├── .gitignore ├── CNAME ├── _config.yml ├── Gemfile ├── repository │ └── edu │ │ └── cmu │ │ └── cs │ │ └── obsidian │ │ └── runtime │ │ ├── maven-metadata.xml.md5 │ │ ├── 0.1 │ │ ├── runtime-0.1.jar.md5 │ │ ├── runtime-0.1.pom.md5 │ │ ├── runtime-0.1.jar.sha1 │ │ ├── runtime-0.1.pom.sha1 │ │ └── runtime-0.1.jar │ │ ├── maven-metadata.xml.sha1 │ │ └── maven-metadata.xml ├── working-draft.pdf ├── stable-formalism.pdf ├── images │ └── blacktocat.png ├── contracts-WETSEB2019.pdf ├── obsidian-case-study.pdf ├── tutorial │ └── ownership-diagram.png └── stylesheet.css ├── project ├── build.properties └── assembly.sbt ├── formalization ├── .gitignore ├── sources.cfg ├── all.agda ├── heapProperties.agda ├── README.txt └── false.elf ├── resources ├── tests │ ├── simple.obs │ ├── compilerTests │ │ ├── Simple.obs │ │ ├── StubExceptions.obs │ │ ├── TestFFI.obs │ │ ├── StubExceptionsLib.obs │ │ ├── SimpleVerification.obs │ │ ├── ReentrantClient.obs │ │ ├── MultipleConstructorGroup.obs │ │ ├── NegativeNumber.obs │ │ ├── Simple3.obs │ │ ├── Reentrant.obs │ │ ├── ConstructorWithArgs2.obs │ │ ├── IntContainerClient.obs │ │ ├── ConstructorWithArgs.obs │ │ ├── IntContainer.obs │ │ ├── StringContainerContainerClient.obs │ │ ├── TransactionInConstructor.obs │ │ ├── StateTransactions.obs │ │ ├── PrimitiveTypes.obs │ │ ├── BasicGenerics.obs │ │ └── StringContainerContainer.obs │ ├── parser_tests │ │ ├── UnclosedContract.obs │ │ ├── EmptyBody.obs │ │ ├── BadTransactionOptions.obs │ │ ├── ConstructorPermissionRequired.obs │ │ ├── ConstructorPermissionRequiredMissing.obs │ │ ├── ValidTransactions.obs │ │ ├── TransactionOptions.obs │ │ ├── FSMs.obs │ │ ├── BadTransactionOrdering.obs │ │ ├── AvailableInRepeats.obs │ │ ├── StateInitialization.obs │ │ └── InvokableSpec.obs │ ├── type_checker_tests │ │ ├── NoMainContract.obs │ │ ├── BadInitialization.obs │ │ ├── InterfaceWithReturn.obs │ │ ├── DuplicateContractDecl.obs │ │ ├── ForbiddenShadowing.obs │ │ ├── FieldOwnershipDiscrepancy.obs │ │ ├── DuplicateArgs.obs │ │ ├── UndefinedContract.obs │ │ ├── TransactionParamShadow.obs │ │ ├── Revert.obs │ │ ├── AssetStateTracking.obs │ │ ├── EndsInState.obs │ │ ├── AssetStateTrackingOkay.obs │ │ ├── VariableDeclarations.obs │ │ ├── UndefinedVariable.obs │ │ ├── MultipleConstructors.obs │ │ ├── NoSideEffects.obs │ │ ├── InStateOwnershipChange.obs │ │ ├── SameNameFields.obs │ │ ├── MaybeDroppedAsset.obs │ │ ├── GenericsIntStringMismatch.obs │ │ ├── CheckFields.obs │ │ ├── Uninitialized.obs │ │ ├── SimplePDT.obs │ │ ├── MultiConstrDistinguishable.obs │ │ ├── GenericsOwnership.obs │ │ ├── StringConcat.obs │ │ ├── MultiConstrAmbiguous.obs │ │ ├── ArgumentShadowing.obs │ │ ├── BasicGenerics.obs │ │ ├── SimpleComparisons.obs │ │ ├── Equality.obs │ │ ├── Prescription.obs │ │ ├── SimpleOperations.obs │ │ ├── States.obs │ │ ├── ParentPDT.obs │ │ ├── ExampleTypeFailure.obs │ │ ├── MultistateFields.obs │ │ ├── StaticAsserts.obs │ │ ├── Ownership.obs │ │ ├── Dereference.obs │ │ ├── StartState.obs │ │ ├── ConstructorFieldTypes.obs │ │ ├── ThisTypePDT.obs │ │ ├── BottomTypeNoError.obs │ │ └── MultistateTransactions.obs │ ├── tests_to_run.txt │ ├── GanacheTests │ │ ├── EmptyContract.obs │ │ ├── PrimOpsAdd.obs │ │ ├── PrimOpsDiv.obs │ │ ├── PrimOpsEq.obs │ │ ├── PrimOpsMul.obs │ │ ├── PrimOpsNeg.obs │ │ ├── PrimOpsLess.obs │ │ ├── PrimOpsMod.obs │ │ ├── PrimOpsNEq.obs │ │ ├── PrimOpsAnd.obs │ │ ├── PrimOpsOr.obs │ │ ├── PrimOpsSubNeg.obs │ │ ├── PrimOpsSubPos.obs │ │ ├── PrimOpsGreater.obs │ │ ├── PrimOpsLessEq.obs │ │ ├── PrimOpsNotTrue.obs │ │ ├── PrimOpsNotFalse.obs │ │ ├── PrimOpsGreaterEq.obs │ │ ├── Return2.obs │ │ ├── ReturnAdd.obs │ │ ├── IntConst.obs │ │ ├── BoolLiteral.obs │ │ ├── SimpleCall.obs │ │ ├── Return.obs │ │ ├── AssignLocalAdd.obs │ │ ├── If.obs │ │ ├── SetGetWithArgs.obs │ │ ├── SetGetNoArgsNoConstructNoInit.obs │ │ ├── IfThenElse.obs │ │ ├── SetGetRefCountDecrNoRelease.obs │ │ ├── SetGetConstructorNoArgsNoSet.obs │ │ ├── ICGeneratedCons.obs │ │ ├── MultiLineIfRet.obs │ │ ├── SetGetConstructorNoArgs.obs │ │ ├── SetGetMainArgs1.obs │ │ ├── SetGetConstructorArgs.obs │ │ ├── SetGetMainArgs3.obs │ │ ├── SetGetNoArgsNoConstruct.obs │ │ ├── SetGetRefCountDecr.obs │ │ ├── SG.obs │ │ ├── CombinedBasicsRet.obs │ │ ├── SetGetTwoConstructors.obs │ │ ├── CombinedBasics.obs │ │ ├── SGTwoContainers.obs │ │ ├── SetGetLogs.obs │ │ ├── SetGetRefCountNested.obs │ │ ├── SetGetConstructorField.obs │ │ ├── SetGetRefCountIncr.obs │ │ ├── MultiLineIfRetSm.obs │ │ ├── SetGetPointer.obs │ │ └── SetGetNestedPointerPassThrough.obs │ ├── TestIntContainer.obstest │ ├── simpleVerification.obs │ ├── StateClient.obs │ ├── SolidityBenchmarks │ │ ├── PrimOpsEq.sol │ │ ├── AssignLocalAdd.sol │ │ ├── Return.sol │ │ └── SetGetPointer_Struct.sol │ ├── endToEndTests │ │ ├── InterfaceUseTest.sh │ │ ├── GenericInterfaceParamsTest.sh │ │ ├── BasicGenericsTests.sh │ │ └── GenericsStateVariablesTest.sh │ ├── simple3.obs │ ├── LinkedListAppendClient.obs │ ├── IntContainer.obs │ ├── PrimitiveTypesClient.obs │ ├── IntContainerClient.obs │ ├── StringContainer.obs │ ├── simple2.obs │ ├── owned.obs │ ├── PrimitiveTypes.obs │ ├── FabricTests │ │ ├── TransactionInConstructorTest.sh │ │ ├── MultipleConstructorsTest.sh │ │ └── IntContainerTest.sh │ ├── State.obs │ └── ManualSolidityBenchmarks │ │ └── SetGetPointer_Contract.sol ├── demos │ ├── ERC20 │ │ ├── Comparator.obs │ │ └── Integer.obs │ └── TinyVendingMachine │ │ └── TinyVendingMachineClient.obs ├── case_studies │ └── Insurance │ │ ├── case-study-outline.odg │ │ ├── solidity │ │ ├── insurancebid.sol │ │ └── bank.sol │ │ ├── Bank.obs │ │ ├── Signature.obs │ │ └── TimeService.obs └── protos │ └── InterfaceImplementerWrapper.proto ├── user_guide ├── requirements.txt ├── source │ ├── vscode-commands.png │ ├── tutorial │ │ ├── syntax-diagram.png │ │ ├── ownership-diagram.png │ │ ├── aliasing-before-after.png │ │ ├── aliasing_counterexample.png │ │ ├── tutorial.rst │ │ └── states-assets.rst │ └── reference │ │ └── reference.rst └── Makefile ├── .idea ├── modules │ └── project │ │ └── build.properties ├── codeStyles │ └── codeStyleConfig.xml ├── hydra.xml ├── vcs.xml ├── misc.xml ├── scala_compiler.xml ├── inspectionProfiles │ └── Project_Default.xml └── sbt.xml ├── fabric └── java │ ├── src │ └── main │ │ └── java │ │ └── org │ │ └── hyperledger │ │ └── fabric │ │ └── example │ │ └── .keep │ └── settings.gradle ├── solidity_user_guide ├── requirements.txt ├── source │ ├── getting_started.rst │ ├── tutorial │ │ ├── ownership-diagram.png │ │ └── tutorial.rst │ └── index.rst └── Makefile ├── obs-vscode-extension ├── .gitignore ├── .vscodeignore ├── CHANGELOG.md ├── server │ ├── package.json │ └── tsconfig.json ├── tsconfig.json └── .vscode │ └── tasks.json ├── papers ├── yul_evm_writeup │ ├── relatedwork.tex │ ├── ACM-Reference-Format.cbx │ ├── sizes.csv │ ├── small_bench.csv │ ├── medium_bench.csv │ ├── ll_bench.csv │ ├── macros.tex │ ├── conclusion.tex │ └── ACM-Reference-Format.dbx ├── obsidian-user-studies.pdf └── PLATEAU_2017 │ ├── VoterRegistrationDiagram.png │ └── VoterRegistrationDiagramv2.png ├── evaluation ├── solidity_participant_template │ ├── auction-exercises │ │ ├── build │ │ │ └── Auction │ │ │ │ ├── src │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── org │ │ │ │ │ └── hyperledger │ │ │ │ │ └── fabric │ │ │ │ │ └── example │ │ │ │ │ ├── .keep │ │ │ │ │ └── Contract.java │ │ │ │ └── settings.gradle │ │ ├── .vscode │ │ │ └── settings.json │ │ └── project.json │ └── tutorial-exercises │ │ ├── code1.sol │ │ ├── code5.sol │ │ ├── code2.sol │ │ ├── code8.sol │ │ └── code3.sol ├── P41 │ ├── auction-exercises │ │ ├── .vscode │ │ │ └── settings.json │ │ └── project.json │ ├── tutorial-exercises │ │ ├── code1.sol │ │ ├── code8.sol │ │ ├── code2.sol │ │ └── code5.sol │ └── betting-exercises │ │ └── betting.sol ├── pilot7 │ ├── auction-exercises │ │ ├── project.json │ │ └── .vscode │ │ │ └── settings.json │ ├── tutorial-exercises │ │ ├── code1.obs │ │ ├── code2.obs │ │ ├── code8.obs │ │ ├── code5.obs │ │ ├── code3.obs │ │ └── code6.obs │ └── betting-exercises │ │ └── betting.obs ├── pilot8 │ ├── auction-exercises │ │ └── project.json │ └── tutorial-exercises │ │ ├── code1.obs │ │ ├── code2.obs │ │ ├── code8.obs │ │ ├── code5.obs │ │ ├── code3.obs │ │ └── code6.obs ├── pilot10 │ └── auction-exercises │ │ └── project.json ├── pilot11 │ └── auction-exercises │ │ └── project.json ├── pilot6 │ ├── auction-exercises │ │ └── project.json │ └── tutorial-exercises │ │ ├── code1.obs │ │ ├── code2.obs │ │ ├── code3.obs │ │ ├── code6.obs │ │ └── code5.obs ├── casino-exercises │ ├── CasinoSequence.png │ └── structuralDiagram.png ├── obsidian_participant_template │ ├── auction-exercises │ │ └── project.json │ └── tutorial-exercises │ │ ├── code1.obs │ │ ├── code2.obs │ │ ├── code5.obs │ │ ├── code8.obs │ │ ├── code3.obs │ │ └── code6.obs ├── Tutorials │ ├── obsidian │ │ ├── ownership-diagram.png │ │ └── Q14.4.html │ ├── stylesheet.css │ ├── fused-type-inference │ │ ├── Q16.2.html │ │ └── Q14.4.html │ ├── license-exercises │ │ ├── Money.obs │ │ └── Licensor.obs │ ├── fused-traditional-declarations │ │ └── Q14.4.html │ ├── split-traditional-declarations │ │ └── Q14.4.html │ └── split-type-inference │ │ └── Q14.4.html ├── pilot3 │ ├── tutorial-exercises │ │ ├── code1.obs │ │ ├── code1_R3.obs │ │ ├── code2.obs │ │ ├── code2_R3.obs │ │ ├── code5.obs │ │ ├── code8.obs │ │ ├── code3.obs │ │ ├── code6.obs │ │ └── code3_R3.obs │ └── betting-exercises │ │ ├── betting_pilot.obs │ │ ├── Betting_help_R3.obs │ │ └── betting_help.obs ├── pilot4 │ ├── tutorial-exercises │ │ ├── code1.obs │ │ └── code2.obs │ └── betting-exercises │ │ ├── Betting_R4.obs │ │ └── betting_pilot.obs ├── pilot5 │ ├── tutorial-exercises │ │ ├── code1.obs │ │ ├── code2.obs │ │ └── code6.obs │ └── betting-exercises │ │ └── betting_pilot.obs └── pilot2 │ ├── Betting_R2.obs │ ├── betting_pilot.obs │ ├── betting_help.obs │ └── Betting_help_R2.obs ├── pygments_lexer_obsidian ├── pygments_lexer_obsidian │ └── __init__.py └── README.rst ├── network-framework ├── .gitignore ├── .env ├── scripts │ └── capabilities.json ├── channel-artifacts │ └── README.md ├── crypto-config │ ├── peerOrganizations │ │ ├── org2.example.com │ │ │ ├── msp │ │ │ │ └── config.yaml │ │ │ ├── peers │ │ │ │ ├── peer0.org2.example.com │ │ │ │ │ ├── tls │ │ │ │ │ │ └── server.key │ │ │ │ │ └── msp │ │ │ │ │ │ ├── config.yaml │ │ │ │ │ │ └── keystore │ │ │ │ │ │ └── 6af06030e89043e0a2ed077e39a82f19aa5665a83f74261b995570dfec44b62a_sk │ │ │ │ └── peer1.org2.example.com │ │ │ │ │ ├── tls │ │ │ │ │ └── server.key │ │ │ │ │ └── msp │ │ │ │ │ ├── config.yaml │ │ │ │ │ └── keystore │ │ │ │ │ └── 81feddf769d2bf55b65cdc9b70ddf16be819c27bf1a90491d11285518a180659_sk │ │ │ ├── users │ │ │ │ ├── Admin@org2.example.com │ │ │ │ │ ├── tls │ │ │ │ │ │ └── client.key │ │ │ │ │ └── msp │ │ │ │ │ │ └── keystore │ │ │ │ │ │ └── a9998f4a439f51c97191286c7965509f7a989e56da9d84a129fef279237da5a7_sk │ │ │ │ └── User1@org2.example.com │ │ │ │ │ ├── tls │ │ │ │ │ └── client.key │ │ │ │ │ └── msp │ │ │ │ │ └── keystore │ │ │ │ │ └── 7ac50fa632e9f3bdc3fed1c1d8f06c9ece77c24425ce9fecdb656e12c4e040cd_sk │ │ │ ├── ca │ │ │ │ └── 1124c4985d7363fa48511a22900843c0b121228df9ad270687e8fcfe03a435d7_sk │ │ │ └── tlsca │ │ │ │ └── 090420edbb352674a18308ce5352ca80f7e88206490453a91b07ec8e18bda502_sk │ │ └── org1.example.com │ │ │ ├── msp │ │ │ └── config.yaml │ │ │ ├── peers │ │ │ ├── peer0.org1.example.com │ │ │ │ ├── tls │ │ │ │ │ └── server.key │ │ │ │ └── msp │ │ │ │ │ ├── config.yaml │ │ │ │ │ └── keystore │ │ │ │ │ └── d9eb52653e83ebd36793367da6eb2858abc470bd2ccfc0f71c2dc6197d9b74e7_sk │ │ │ └── peer1.org1.example.com │ │ │ │ ├── tls │ │ │ │ └── server.key │ │ │ │ └── msp │ │ │ │ ├── config.yaml │ │ │ │ └── keystore │ │ │ │ └── c7718967d22ef526fbcca7b455b2f06f667b40fe9c2c2edaed259286642e1faa_sk │ │ │ ├── users │ │ │ ├── Admin@org1.example.com │ │ │ │ ├── tls │ │ │ │ │ └── client.key │ │ │ │ └── msp │ │ │ │ │ └── keystore │ │ │ │ │ └── 1143cbd6e5746190bb865d20dc6668236217c2fb76e2a666ff5615f2713947e9_sk │ │ │ └── User1@org1.example.com │ │ │ │ ├── tls │ │ │ │ └── client.key │ │ │ │ └── msp │ │ │ │ └── keystore │ │ │ │ └── 5d0c74202ab8720c0c36615291dc436d40052a914617af1eba01965e008e7462_sk │ │ │ ├── ca │ │ │ └── 537d87b1a79409452b77983258b32a31d7ff20c6760defcdb1c7460576040989_sk │ │ │ └── tlsca │ │ │ └── 8968b62998908f7a3ac997d3eac4c66b951b13bf50819cac539052bfbf10d5b8_sk │ └── ordererOrganizations │ │ └── example.com │ │ ├── users │ │ └── Admin@example.com │ │ │ ├── tls │ │ │ └── client.key │ │ │ └── msp │ │ │ └── keystore │ │ │ └── 652029aab9649a19fe92c8baa893fae96cebcfec06eb63037bc71149eec43b5f_sk │ │ ├── orderers │ │ └── orderer.example.com │ │ │ ├── tls │ │ │ └── server.key │ │ │ └── msp │ │ │ └── keystore │ │ │ └── 05640e8a4054bac9e9396b90f73ae49127bc28433e96bd55b1b771cac46d530b_sk │ │ ├── ca │ │ └── dd6afe68adf9c80e6afc4da59262928556f3e3b7c21140088a4b78580feae756_sk │ │ ├── tlsca │ │ └── 952b1e43ab3ec5859693d8e8f510489e3dff1504e75a7a484a55bd579e80de01_sk │ │ └── msp │ │ └── admincerts │ │ └── Admin@example.com-cert.pem ├── README.md └── org3-artifacts │ └── org3-crypto.yaml ├── .gitmodules ├── bin ├── killganache.sh ├── solc_bin ├── solc_yul ├── obsidianinvoke ├── cleanup.sh ├── obsidiandown ├── obsidianup ├── obsidianautoup ├── skipped_tests.sh ├── run_obs_yul_all.sh ├── obsidianc ├── travisdebug └── solc_optimized_yul ├── Obsidian_Runtime ├── src │ └── main │ │ ├── java │ │ └── Runtime │ │ │ └── edu │ │ │ └── cmu │ │ │ └── cs │ │ │ └── obsidian │ │ │ ├── stdlib │ │ │ ├── Comparator.obs │ │ │ ├── IO.obs │ │ │ ├── IO.java │ │ │ └── Integer.obs │ │ │ ├── chaincode │ │ │ ├── NoSuchTransactionException.java │ │ │ ├── ReentrancyException.java │ │ │ ├── BadTransactionException.java │ │ │ ├── BadArgumentException.java │ │ │ ├── ObsidianChaincodeException.java │ │ │ ├── ReturnedReferenceState.java │ │ │ ├── StateLockException.java │ │ │ ├── IllegalOwnershipConsumptionException.java │ │ │ ├── ObsidianRevertException.java │ │ │ ├── InvalidStateException.java │ │ │ ├── UUIDFactory.java │ │ │ └── WrongNumberOfArgumentsException.java │ │ │ └── client │ │ │ ├── ChaincodeClientAbortTransactionException.java │ │ │ ├── ChaincodeClientTransactionBugException.java │ │ │ └── ChaincodeClientTransactionFailedException.java │ │ └── yul_templates │ │ └── function.mustache ├── README.md └── publish.sh ├── Makefile ├── readthedocs.yaml ├── travis_specific ├── install-protobuf.sh ├── fabric_tests.sh └── README.MD ├── src └── main │ └── scala │ └── edu │ └── cmu │ └── cs │ └── obsidian │ ├── codegen │ ├── CodeGenerator.scala │ └── FuncScope.scala │ ├── lexer │ └── TokenReader.scala │ └── util │ └── Util.scala └── .github └── ISSUE_TEMPLATE └── bug_report.md /docs/.gitignore: -------------------------------------------------------------------------------- 1 | _site 2 | -------------------------------------------------------------------------------- /docs/CNAME: -------------------------------------------------------------------------------- 1 | obsidian-lang.com -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-slate 2 | -------------------------------------------------------------------------------- /project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.5.0 2 | -------------------------------------------------------------------------------- /formalization/.gitignore: -------------------------------------------------------------------------------- 1 | *.agdai 2 | MAlonzo/** 3 | -------------------------------------------------------------------------------- /resources/tests/simple.obs: -------------------------------------------------------------------------------- 1 | main contract Simple {} -------------------------------------------------------------------------------- /user_guide/requirements.txt: -------------------------------------------------------------------------------- 1 | pygments-lexer-obsidian 2 | -------------------------------------------------------------------------------- /.idea/modules/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.5.2 2 | -------------------------------------------------------------------------------- /fabric/java/src/main/java/org/hyperledger/fabric/example/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /formalization/sources.cfg: -------------------------------------------------------------------------------- 1 | false.elf 2 | nat.elf 3 | silica.elf 4 | -------------------------------------------------------------------------------- /resources/tests/compilerTests/Simple.obs: -------------------------------------------------------------------------------- 1 | main contract Simple { } -------------------------------------------------------------------------------- /resources/tests/parser_tests/UnclosedContract.obs: -------------------------------------------------------------------------------- 1 | contract Foo { 2 | -------------------------------------------------------------------------------- /solidity_user_guide/requirements.txt: -------------------------------------------------------------------------------- 1 | pygments-lexer-solidity 2 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/NoMainContract.obs: -------------------------------------------------------------------------------- 1 | contract Simple { } -------------------------------------------------------------------------------- /obs-vscode-extension/.gitignore: -------------------------------------------------------------------------------- 1 | **/node_modules/ 2 | *.vsix 3 | **/out/ 4 | -------------------------------------------------------------------------------- /resources/tests/tests_to_run.txt: -------------------------------------------------------------------------------- 1 | resources/tests/TestIntContainer.obstest 2 | -------------------------------------------------------------------------------- /project/assembly.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10") 2 | -------------------------------------------------------------------------------- /papers/yul_evm_writeup/relatedwork.tex: -------------------------------------------------------------------------------- 1 | \todo{Text that puts our work into context!} 2 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/EmptyContract.obs: -------------------------------------------------------------------------------- 1 | main contract EmptyContract { 2 | } 3 | -------------------------------------------------------------------------------- /docs/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | gem 'github-pages', group: :jekyll_plugins 3 | -------------------------------------------------------------------------------- /docs/repository/edu/cmu/cs/obsidian/runtime/maven-metadata.xml.md5: -------------------------------------------------------------------------------- 1 | 2913d8187813798e0542c2a27bd9d833 -------------------------------------------------------------------------------- /docs/working-draft.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcoblenz/Obsidian/HEAD/docs/working-draft.pdf -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/BadInitialization.obs: -------------------------------------------------------------------------------- 1 | contract Bad { 2 | int x = 3; 3 | } -------------------------------------------------------------------------------- /solidity_user_guide/source/getting_started.rst: -------------------------------------------------------------------------------- 1 | Getting Started 2 | =============== 3 | 4 | TODO -------------------------------------------------------------------------------- /docs/repository/edu/cmu/cs/obsidian/runtime/0.1/runtime-0.1.jar.md5: -------------------------------------------------------------------------------- 1 | 96d5bcb30d9039bfda6c75da8d1509b4 -------------------------------------------------------------------------------- /docs/repository/edu/cmu/cs/obsidian/runtime/0.1/runtime-0.1.pom.md5: -------------------------------------------------------------------------------- 1 | f8bcfd0d70a29da0ca59a51da9c03752 -------------------------------------------------------------------------------- /docs/stable-formalism.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcoblenz/Obsidian/HEAD/docs/stable-formalism.pdf -------------------------------------------------------------------------------- /docs/images/blacktocat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcoblenz/Obsidian/HEAD/docs/images/blacktocat.png -------------------------------------------------------------------------------- /docs/repository/edu/cmu/cs/obsidian/runtime/0.1/runtime-0.1.jar.sha1: -------------------------------------------------------------------------------- 1 | dbec030ce2a41dad045b948ab62d4cda0b5a0e2f -------------------------------------------------------------------------------- /docs/repository/edu/cmu/cs/obsidian/runtime/0.1/runtime-0.1.pom.sha1: -------------------------------------------------------------------------------- 1 | c0ff44ced61462a8663ee97e290fed051bed0d9c -------------------------------------------------------------------------------- /docs/repository/edu/cmu/cs/obsidian/runtime/maven-metadata.xml.sha1: -------------------------------------------------------------------------------- 1 | 93b9f5334186d39712ae4bfc41d9433d30a3c65a -------------------------------------------------------------------------------- /docs/contracts-WETSEB2019.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcoblenz/Obsidian/HEAD/docs/contracts-WETSEB2019.pdf -------------------------------------------------------------------------------- /docs/obsidian-case-study.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcoblenz/Obsidian/HEAD/docs/obsidian-case-study.pdf -------------------------------------------------------------------------------- /obs-vscode-extension/.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | .gitignore 4 | vsc-extension-quickstart.md 5 | -------------------------------------------------------------------------------- /papers/obsidian-user-studies.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcoblenz/Obsidian/HEAD/papers/obsidian-user-studies.pdf -------------------------------------------------------------------------------- /docs/tutorial/ownership-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcoblenz/Obsidian/HEAD/docs/tutorial/ownership-diagram.png -------------------------------------------------------------------------------- /evaluation/solidity_participant_template/auction-exercises/build/Auction/src/main/java/org/hyperledger/fabric/example/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /resources/tests/parser_tests/EmptyBody.obs: -------------------------------------------------------------------------------- 1 | main contract DefaultState { 2 | DefaultState@Owned() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /evaluation/P41/auction-exercises/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic" 3 | } -------------------------------------------------------------------------------- /evaluation/P41/auction-exercises/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "chaincode": "auction.obs", 3 | "client": "auction_client.obs" 4 | } -------------------------------------------------------------------------------- /evaluation/pilot7/auction-exercises/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "chaincode": "auction.obs", 3 | "client": "auction_client.obs" 4 | } -------------------------------------------------------------------------------- /evaluation/pilot8/auction-exercises/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "chaincode": "auction.obs", 3 | "client": "auction_client.obs" 4 | } -------------------------------------------------------------------------------- /resources/tests/TestIntContainer.obstest: -------------------------------------------------------------------------------- 1 | server: IntContainer.obs 2 | client: IntContainerClient.obs 3 | *** 4 | 5 5 | 3 6 | -------------------------------------------------------------------------------- /user_guide/source/vscode-commands.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcoblenz/Obsidian/HEAD/user_guide/source/vscode-commands.png -------------------------------------------------------------------------------- /evaluation/pilot10/auction-exercises/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "chaincode": "auction.obs", 3 | "client": "auction_client.obs" 4 | } -------------------------------------------------------------------------------- /evaluation/pilot11/auction-exercises/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "chaincode": "auction.obs", 3 | "client": "auction_client.obs" 4 | } -------------------------------------------------------------------------------- /evaluation/pilot6/auction-exercises/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "chaincode": "Auction_R6.obs", 3 | "client": "auction_client.obs" 4 | } -------------------------------------------------------------------------------- /evaluation/pilot7/auction-exercises/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic" 3 | } -------------------------------------------------------------------------------- /pygments_lexer_obsidian/pygments_lexer_obsidian/__init__.py: -------------------------------------------------------------------------------- 1 | from .lexer import ObsidianLexer 2 | 3 | __all__ = ['ObsidianLexer'] 4 | -------------------------------------------------------------------------------- /resources/tests/parser_tests/BadTransactionOptions.obs: -------------------------------------------------------------------------------- 1 | main contract C { 2 | private static static transaction t1() { 3 | } 4 | } -------------------------------------------------------------------------------- /user_guide/source/tutorial/syntax-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcoblenz/Obsidian/HEAD/user_guide/source/tutorial/syntax-diagram.png -------------------------------------------------------------------------------- /evaluation/casino-exercises/CasinoSequence.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcoblenz/Obsidian/HEAD/evaluation/casino-exercises/CasinoSequence.png -------------------------------------------------------------------------------- /evaluation/casino-exercises/structuralDiagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcoblenz/Obsidian/HEAD/evaluation/casino-exercises/structuralDiagram.png -------------------------------------------------------------------------------- /evaluation/obsidian_participant_template/auction-exercises/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "chaincode": "auction.obs", 3 | "client": "auction_client.obs" 4 | } -------------------------------------------------------------------------------- /evaluation/solidity_participant_template/auction-exercises/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic" 3 | } -------------------------------------------------------------------------------- /evaluation/solidity_participant_template/auction-exercises/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "chaincode": "auction.obs", 3 | "client": "auction_client.obs" 4 | } -------------------------------------------------------------------------------- /papers/PLATEAU_2017/VoterRegistrationDiagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcoblenz/Obsidian/HEAD/papers/PLATEAU_2017/VoterRegistrationDiagram.png -------------------------------------------------------------------------------- /papers/PLATEAU_2017/VoterRegistrationDiagramv2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcoblenz/Obsidian/HEAD/papers/PLATEAU_2017/VoterRegistrationDiagramv2.png -------------------------------------------------------------------------------- /resources/demos/ERC20/Comparator.obs: -------------------------------------------------------------------------------- 1 | interface Comparator[KeyType] { 2 | transaction equals(KeyType@Unowned a, KeyType@Unowned b) returns bool; 3 | } -------------------------------------------------------------------------------- /user_guide/source/tutorial/ownership-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcoblenz/Obsidian/HEAD/user_guide/source/tutorial/ownership-diagram.png -------------------------------------------------------------------------------- /evaluation/Tutorials/obsidian/ownership-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcoblenz/Obsidian/HEAD/evaluation/Tutorials/obsidian/ownership-diagram.png -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/InterfaceWithReturn.obs: -------------------------------------------------------------------------------- 1 | interface Test { 2 | transaction f() returns int; 3 | } 4 | 5 | main contract C {} 6 | 7 | -------------------------------------------------------------------------------- /user_guide/source/tutorial/aliasing-before-after.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcoblenz/Obsidian/HEAD/user_guide/source/tutorial/aliasing-before-after.png -------------------------------------------------------------------------------- /resources/case_studies/Insurance/case-study-outline.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcoblenz/Obsidian/HEAD/resources/case_studies/Insurance/case-study-outline.odg -------------------------------------------------------------------------------- /resources/tests/GanacheTests/PrimOpsAdd.obs: -------------------------------------------------------------------------------- 1 | main contract PrimOpsAdd{ 2 | transaction primopsadd() returns int { 3 | return(5+8); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/PrimOpsDiv.obs: -------------------------------------------------------------------------------- 1 | main contract PrimOpsDiv{ 2 | transaction primopsdiv() returns int { 3 | return(4/2); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/PrimOpsEq.obs: -------------------------------------------------------------------------------- 1 | main contract PrimOpsEq{ 2 | transaction primopseq() returns bool { 3 | return(5 == 9); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/PrimOpsMul.obs: -------------------------------------------------------------------------------- 1 | main contract PrimOpsMul{ 2 | transaction primopsmul() returns int { 3 | return(5*4); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/PrimOpsNeg.obs: -------------------------------------------------------------------------------- 1 | main contract PrimOpsNeg{ 2 | transaction primopsneg() returns int { 3 | return(-20); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /resources/tests/compilerTests/StubExceptions.obs: -------------------------------------------------------------------------------- 1 | import "resources/tests/compilerTests/StubExceptionsLib.obs" 2 | 3 | main contract StubExceptions {} 4 | 5 | -------------------------------------------------------------------------------- /resources/tests/parser_tests/ConstructorPermissionRequired.obs: -------------------------------------------------------------------------------- 1 | main contract A { 2 | state S1; 3 | 4 | A@S1() { 5 | ->S1; 6 | } 7 | } 8 | 9 | -------------------------------------------------------------------------------- /user_guide/source/tutorial/aliasing_counterexample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcoblenz/Obsidian/HEAD/user_guide/source/tutorial/aliasing_counterexample.png -------------------------------------------------------------------------------- /network-framework/.gitignore: -------------------------------------------------------------------------------- 1 | /channel-artifacts/*.tx 2 | /channel-artifacts/*.block 3 | /crypto-config/* 4 | /docker-compose-e2e.yaml 5 | /ledgers 6 | /ledgers-backup -------------------------------------------------------------------------------- /papers/yul_evm_writeup/ACM-Reference-Format.cbx: -------------------------------------------------------------------------------- 1 | \ProvidesFile{ACM-Reference-Format.cbx}[2017-09-27 v0.1] 2 | 3 | \RequireCitationStyle{numeric} 4 | 5 | \endinput 6 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/PrimOpsLess.obs: -------------------------------------------------------------------------------- 1 | main contract PrimOpsLess{ 2 | transaction primopsless() returns bool { 3 | return(9 < 10); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/PrimOpsMod.obs: -------------------------------------------------------------------------------- 1 | main contract PrimOpsMod{ 2 | transaction primopsmod() returns int { 3 | return(13 % 8); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/PrimOpsNEq.obs: -------------------------------------------------------------------------------- 1 | main contract PrimOpsNEq{ 2 | transaction primopsneq() returns bool { 3 | return(5 != 9); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /resources/tests/parser_tests/ConstructorPermissionRequiredMissing.obs: -------------------------------------------------------------------------------- 1 | main contract A { 2 | state S1; 3 | 4 | A() { 5 | ->S1; 6 | } 7 | } 8 | 9 | -------------------------------------------------------------------------------- /solidity_user_guide/source/tutorial/ownership-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcoblenz/Obsidian/HEAD/solidity_user_guide/source/tutorial/ownership-diagram.png -------------------------------------------------------------------------------- /formalization/all.agda: -------------------------------------------------------------------------------- 1 | -- This file serves to aggregate all the top-level dependencies in the Silica project. 2 | 3 | open import preservation 4 | open import progress 5 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/PrimOpsAnd.obs: -------------------------------------------------------------------------------- 1 | main contract PrimOpsAnd{ 2 | transaction primopsand() returns bool { 3 | return(true && false); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/PrimOpsOr.obs: -------------------------------------------------------------------------------- 1 | main contract PrimOpsOr{ 2 | transaction primopsor() returns bool { 3 | return(true || false); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/PrimOpsSubNeg.obs: -------------------------------------------------------------------------------- 1 | main contract PrimOpsSubNeg{ 2 | transaction primopssubneg() returns int { 3 | return(5-20); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/PrimOpsSubPos.obs: -------------------------------------------------------------------------------- 1 | main contract PrimOpsSubPos{ 2 | transaction primopssubpos() returns int { 3 | return(20-5); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/PrimOpsGreater.obs: -------------------------------------------------------------------------------- 1 | main contract PrimOpsGreater{ 2 | transaction primopsgreater() returns bool { 3 | return(12 > 19); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/PrimOpsLessEq.obs: -------------------------------------------------------------------------------- 1 | main contract PrimOpsLessEq{ 2 | transaction primopslesseq() returns bool { 3 | return(9 <= 19); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/PrimOpsNotTrue.obs: -------------------------------------------------------------------------------- 1 | main contract PrimOpsNotTrue{ 2 | transaction primopsnottrue() returns bool { 3 | return(! true); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /docs/repository/edu/cmu/cs/obsidian/runtime/0.1/runtime-0.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcoblenz/Obsidian/HEAD/docs/repository/edu/cmu/cs/obsidian/runtime/0.1/runtime-0.1.jar -------------------------------------------------------------------------------- /resources/tests/GanacheTests/PrimOpsNotFalse.obs: -------------------------------------------------------------------------------- 1 | main contract PrimOpsNotFalse{ 2 | transaction primopsnotfalse() returns bool { 3 | return(! false); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /resources/tests/compilerTests/TestFFI.obs: -------------------------------------------------------------------------------- 1 | import "IO.obs" 2 | 3 | main contract TestFFI { 4 | transaction Hello() { 5 | new IO().print("hello"); 6 | } 7 | } 8 | 9 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/PrimOpsGreaterEq.obs: -------------------------------------------------------------------------------- 1 | main contract PrimOpsGreaterEq{ 2 | transaction primopsgreatereq() returns bool { 3 | return(12 >= 12); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /resources/tests/compilerTests/StubExceptionsLib.obs: -------------------------------------------------------------------------------- 1 | contract C { 2 | transaction f(C@Unowned other) {} 3 | 4 | transaction g() { 5 | f(new C()); 6 | } 7 | } 8 | 9 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/DuplicateContractDecl.obs: -------------------------------------------------------------------------------- 1 | // Not allowed: Contract is analagous to Object in Java, and is defined by the compiler 2 | main contract Contract {} 3 | 4 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "resources/case_studies/Shipping"] 2 | path = resources/case_studies/Shipping 3 | url = https://github.com/laredo/Shipping.git 4 | branch = generic-linked-list 5 | -------------------------------------------------------------------------------- /bin/killganache.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # kill stray ganache cli instances by scanning that port 4 | 5 | if [ "$(lsof -t -i:8545)" ] 6 | then 7 | kill -9 "$(lsof -t -i:8545)" 8 | fi 9 | -------------------------------------------------------------------------------- /bin/solc_bin: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # solc_bin runs solc on a solidity program and produces a binary 4 | 5 | docker run -v "$( pwd -P )":/sources ethereum/solc:stable --bin /sources/"$1" 6 | -------------------------------------------------------------------------------- /resources/tests/simpleVerification.obs: -------------------------------------------------------------------------------- 1 | main contract SimpleVerification { 2 | int x; 3 | 4 | transaction doStuff() 5 | ensures true; 6 | { 7 | x = 0; 8 | } 9 | } -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /Obsidian_Runtime/src/main/java/Runtime/edu/cmu/cs/obsidian/stdlib/Comparator.obs: -------------------------------------------------------------------------------- 1 | interface Comparator[KeyType] { 2 | transaction equals(KeyType@Unowned a, KeyType@Unowned b) returns bool; 3 | } -------------------------------------------------------------------------------- /network-framework/.env: -------------------------------------------------------------------------------- 1 | COMPOSE_PROJECT_NAME=net 2 | IMAGE_TAG=latest 3 | CHAINCODE_DIRECTORY=/Users/mcoblenz/code/Obsidian/evaluation/pilot6/auction-exercises/build/Auction 4 | CHAINCODE_NAME=Auction 5 | -------------------------------------------------------------------------------- /fabric/java/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright IBM Corp. 2017 All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | rootProject.name = 'fabric-chaincode-example-gradle' 7 | 8 | -------------------------------------------------------------------------------- /resources/tests/compilerTests/SimpleVerification.obs: -------------------------------------------------------------------------------- 1 | main contract SimpleVerification { 2 | int x; 3 | 4 | transaction doStuff() 5 | ensures true; 6 | { 7 | x = 0; 8 | } 9 | } -------------------------------------------------------------------------------- /.idea/hydra.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /network-framework/scripts/capabilities.json: -------------------------------------------------------------------------------- 1 | { 2 | "mod_policy": "Admins", 3 | "value": { 4 | "capabilities": { 5 | "V1_3": {} 6 | } 7 | }, 8 | "version": "0" 9 | } 10 | -------------------------------------------------------------------------------- /resources/tests/parser_tests/ValidTransactions.obs: -------------------------------------------------------------------------------- 1 | main contract C { 2 | state S1 { 3 | } 4 | transaction t(C@S1 this) returns int { return x; } 5 | transaction t(C@S1 this, T x) { return x; } 6 | } -------------------------------------------------------------------------------- /resources/tests/compilerTests/ReentrantClient.obs: -------------------------------------------------------------------------------- 1 | import "Reentrant.obs" 2 | 3 | main contract ReentrantClient { 4 | transaction main(remote Reentrant c) { 5 | A a = new A(); 6 | int x = c.t2(a); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /papers/yul_evm_writeup/sizes.csv: -------------------------------------------------------------------------------- 1 | optimized test file, size in bytes 2 | LinkedListMed-pretty.yul, 7184 3 | LinkedListMedNoGC-pretty.yul, 2664 4 | LinkedListShort-pretty.yul, 5765 5 | LinkedListShortNoGC-pretty.yul, 2330 6 | -------------------------------------------------------------------------------- /papers/yul_evm_writeup/small_bench.csv: -------------------------------------------------------------------------------- 1 | Test,Obsidian depl.,Obsidian inv.,Solidity depl.,Solidity inv. 2 | AssignLocalAdd,98265,21202,81737,21232 3 | PrimOpsEq,91314,21183,79135,21213 4 | Return,106044,21237,85409,21244 5 | -------------------------------------------------------------------------------- /pygments_lexer_obsidian/README.rst: -------------------------------------------------------------------------------- 1 | Based on https://gitlab.com/veox/pygments-lexer-solidity/ by Noel Maersk. 2 | 3 | To publish a new version: 4 | python setup.py sdist bdist_wheel 5 | python -m twine upload dist/* 6 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/ForbiddenShadowing.obs: -------------------------------------------------------------------------------- 1 | main contract C2 { 2 | int x; 3 | 4 | C2@S1(){ 5 | ->S1(x=1); 6 | } 7 | 8 | state S1 { 9 | int x; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # This Makefile builds the compiler into a jar file, which bin/obsidianc invokes. 2 | 3 | all: obsidianc 4 | 5 | obsidianc: 6 | sbt assembly 7 | 8 | notest: 9 | sbt 'set assembly / test := {}' assembly 10 | -------------------------------------------------------------------------------- /bin/solc_yul: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # solc_bin runs solc on a solidity program and produces yul 4 | 5 | bn=$(basename -s '.sol' "$1") 6 | docker run -v "$( pwd -P )":/sources ethereum/solc:stable --ir /sources/"$1" > "$bn-sol.yul" 7 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/Return2.obs: -------------------------------------------------------------------------------- 1 | main contract Return2 { 2 | transaction f() returns int{ 3 | return (4+4); 4 | } 5 | transaction g(){ 6 | f(); 7 | return; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /resources/tests/StateClient.obs: -------------------------------------------------------------------------------- 1 | import "State.obs" 2 | 3 | main contract StateClient { 4 | transaction main(remote StateTest st) { 5 | st.setX(2); 6 | st.setX(1); 7 | st.f("hi"); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /resources/tests/parser_tests/TransactionOptions.obs: -------------------------------------------------------------------------------- 1 | main contract C { 2 | private static transaction t1() { 3 | } 4 | 5 | transaction t2() { 6 | } 7 | 8 | static private transaction t3() { 9 | } 10 | } -------------------------------------------------------------------------------- /bin/obsidianinvoke: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | bin_dir="$(cd "$(dirname $BASH_SOURCE)"; pwd)" 4 | root_dir="$bin_dir/.." 5 | export OBSIDIAN_COMPILER_DIR="$root_dir" 6 | 7 | ${OBSIDIAN_COMPILER_DIR}/network-framework/invoke.sh "$@" 8 | 9 | -------------------------------------------------------------------------------- /docs/stylesheet.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 14px; 3 | font-family: Poppins; 4 | } 5 | 6 | .code { 7 | font-family: courier new, courier, monospace; 8 | } 9 | 10 | .boxed { 11 | padding: 25px; 12 | max-width: 500px; 13 | } -------------------------------------------------------------------------------- /formalization/heapProperties.agda: -------------------------------------------------------------------------------- 1 | {-# OPTIONS --allow-unsolved-metas #-} 2 | {-# OPTIONS --show-implicit #-} 3 | 4 | module HeapProperties where 5 | open import HeapPropertiesDefs public 6 | open import HeapLemmasForSplitting public 7 | -------------------------------------------------------------------------------- /papers/yul_evm_writeup/medium_bench.csv: -------------------------------------------------------------------------------- 1 | test name,gas used for deploy,gas used for invoke,total gas 2 | SetGetPointer.obs,412039,41219,453258 3 | SetGetNestedPointerPassThrough.obs,203324,33004,236328 4 | SetGetLogs.obs,394966,54308,449274 5 | -------------------------------------------------------------------------------- /resources/tests/SolidityBenchmarks/PrimOpsEq.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD 2 | 3 | pragma solidity >=0.8.0; 4 | 5 | contract PrimOpsEq { 6 | function main() public pure returns (bool) { 7 | return (5 == 9); 8 | } 9 | } -------------------------------------------------------------------------------- /resources/tests/GanacheTests/ReturnAdd.obs: -------------------------------------------------------------------------------- 1 | main contract ReturnAdd { 2 | transaction f() returns int{ 3 | return (4+4); 4 | } 5 | 6 | transaction main() returns int{ 7 | return f() + f(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /resources/tests/endToEndTests/InterfaceUseTest.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | source "lib.sh" 4 | 5 | init "InterfaceUse" 6 | 7 | check "./invoke.sh -q f" "\000" 8 | check "./invoke.sh -q g" "\001" 9 | 10 | cleanup "InterfaceUse" 11 | 12 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/FieldOwnershipDiscrepancy.obs: -------------------------------------------------------------------------------- 1 | contract C { 2 | C@Owned() {} 3 | } 4 | 5 | main contract FieldOwnershipDiscrepancy { 6 | C@Unowned c; 7 | 8 | transaction t() { 9 | c = new C(); 10 | } 11 | } -------------------------------------------------------------------------------- /evaluation/Tutorials/stylesheet.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 14px; 3 | font-family: Poppins; 4 | } 5 | 6 | .code { 7 | font-family: courier new, courier, monospace; 8 | } 9 | 10 | .boxed { 11 | padding: 25px; 12 | max-width: 500px; 13 | } -------------------------------------------------------------------------------- /evaluation/solidity_participant_template/auction-exercises/build/Auction/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright IBM Corp. 2017 All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | rootProject.name = 'fabric-chaincode-example-gradle' 7 | 8 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/IntConst.obs: -------------------------------------------------------------------------------- 1 | main contract IntConst{ 2 | transaction intconst() { 3 | int x; 4 | x = 12; 5 | return; 6 | } 7 | 8 | transaction main() returns int { 9 | return 12; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/DuplicateArgs.obs: -------------------------------------------------------------------------------- 1 | main contract Names { 2 | // Shouldn't have duplicate names 3 | transaction duplicateNames(int y, int y) { 4 | } 5 | } 6 | 7 | interface Duplicates { 8 | transaction duplicateNames(int y, int y); 9 | } -------------------------------------------------------------------------------- /Obsidian_Runtime/src/main/java/Runtime/edu/cmu/cs/obsidian/chaincode/NoSuchTransactionException.java: -------------------------------------------------------------------------------- 1 | package edu.cmu.cs.obsidian.chaincode; 2 | 3 | /** 4 | * Created by Miles Baker on 7/3/18. 5 | */ 6 | public class NoSuchTransactionException extends Exception { 7 | } 8 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/UndefinedContract.obs: -------------------------------------------------------------------------------- 1 | main contract Thing { 2 | // should fail 3 | OtherThing@Shared other; 4 | int x; 5 | 6 | // should fail 7 | transaction a(OtherThing@Shared other) { 8 | int x = 2; 9 | } 10 | } -------------------------------------------------------------------------------- /resources/tests/endToEndTests/GenericInterfaceParamsTest.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | source "lib.sh" 4 | 5 | init "GenericInterfaceParams" 6 | 7 | check "./invoke.sh -q f" "test" 8 | check "./invoke.sh -q g" "180" 9 | 10 | cleanup "GenericInterfaceParams" 11 | 12 | -------------------------------------------------------------------------------- /Obsidian_Runtime/README.md: -------------------------------------------------------------------------------- 1 | ##How to publish runtime files to your local maven 2 | First, you need a Gradle of version 4.9 or higher. In the Obsidian_Runtime directory, run "gradle publishToMavenLocal" 3 | on the terminal. The jar file can be found in your local maven repository. 4 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/BoolLiteral.obs: -------------------------------------------------------------------------------- 1 | main contract BoolLiteral{ 2 | transaction boolliteral () { 3 | bool x; 4 | x = true; 5 | x = false; 6 | } 7 | 8 | transaction main() returns bool { 9 | return false; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /resources/tests/parser_tests/FSMs.obs: -------------------------------------------------------------------------------- 1 | main contract SimpleFSM { 2 | state S1; 3 | state S2; 4 | state S3; 5 | 6 | SimpleFSM@S1() { 7 | ->S1; 8 | } 9 | 10 | transitions { 11 | S1 -> S2, S3; 12 | S2 -> S1; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /bin/cleanup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | rm -f benchmarks*.csv 4 | 5 | for f in resources/tests/GanacheTests/*.obs 6 | do 7 | name=$(basename -s '.obs' "$f") 8 | rm -f "$name/$name.yul" 9 | rm -f "$name/$name-pretty.yul" 10 | [ -d "$name" ] && rmdir "$name" 11 | done 12 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/TransactionParamShadow.obs: -------------------------------------------------------------------------------- 1 | main contract TransactionParamShadow[X@s] { 2 | // Error: X here shadows the X above 3 | transaction f[X@t](X@t x) {} 4 | 5 | // Error: s here shadows the s above 6 | transaction f[Y@s](Y@s x) {} 7 | } 8 | 9 | -------------------------------------------------------------------------------- /Obsidian_Runtime/src/main/java/Runtime/edu/cmu/cs/obsidian/client/ChaincodeClientAbortTransactionException.java: -------------------------------------------------------------------------------- 1 | package edu.cmu.cs.obsidian.client; 2 | 3 | /** 4 | * Created by mcoblenz on 4/4/17. 5 | */ 6 | public class ChaincodeClientAbortTransactionException extends Exception { 7 | } 8 | -------------------------------------------------------------------------------- /obs-vscode-extension/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to the "obs" extension will be documented in this file. 4 | 5 | Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. 6 | 7 | ## [Unreleased] 8 | 9 | - Initial release -------------------------------------------------------------------------------- /resources/tests/GanacheTests/SimpleCall.obs: -------------------------------------------------------------------------------- 1 | main contract SimpleCall{ 2 | transaction val() returns int { 3 | return 4; 4 | } 5 | transaction main() returns int{ 6 | int x; 7 | x = 9; 8 | x = val(); 9 | return x; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /solidity_user_guide/source/tutorial/tutorial.rst: -------------------------------------------------------------------------------- 1 | Solidity Tutorial 2 | ================== 3 | 4 | .. toctree:: 5 | ownership1 6 | ownership2 7 | ownership3 8 | ownership4 9 | assets 10 | states1 11 | states2 12 | states3 13 | states-assets 14 | blockchain 15 | -------------------------------------------------------------------------------- /Obsidian_Runtime/src/main/java/Runtime/edu/cmu/cs/obsidian/stdlib/IO.obs: -------------------------------------------------------------------------------- 1 | interface IOInterface { 2 | transaction print(string s); 3 | transaction println(string s); 4 | transaction printInt(int n); 5 | } 6 | 7 | contract IO implements IOInterface with java : edu.cmu.cs.obsidian.stdlib.IO; 8 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Obsidian_Runtime/src/main/java/Runtime/edu/cmu/cs/obsidian/chaincode/ReentrancyException.java: -------------------------------------------------------------------------------- 1 | package edu.cmu.cs.obsidian.chaincode; 2 | 3 | public class ReentrancyException extends ObsidianChaincodeException { 4 | public ReentrancyException(String f, int l) { 5 | super (f, l); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /resources/tests/parser_tests/BadTransactionOrdering.obs: -------------------------------------------------------------------------------- 1 | main contract C { 2 | state S1 { 3 | function f() { return x; } 4 | function f(T x) { return x; } 5 | } 6 | transaction t(C@S1 this) returns int { return x; } 7 | transaction t(C@S1 this. T x) returns int { return x; } 8 | } -------------------------------------------------------------------------------- /resources/tests/simple3.obs: -------------------------------------------------------------------------------- 1 | main contract Simple3 { 2 | int x; 3 | int y; 4 | 5 | transaction t1() { 6 | y = 1; 7 | } 8 | 9 | transaction t2() { 10 | if y > 3 { 11 | y = 0; 12 | } else { 13 | revert; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /resources/tests/GanacheTests/Return.obs: -------------------------------------------------------------------------------- 1 | main contract Return { 2 | transaction f() returns int{ 3 | return (4+4); 4 | } 5 | transaction g(){ 6 | int x = f(); 7 | return; 8 | } 9 | 10 | transaction main() returns int{ 11 | return f(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /user_guide/source/tutorial/tutorial.rst: -------------------------------------------------------------------------------- 1 | Obsidian Tutorial 2 | ================== 3 | 4 | .. toctree:: 5 | ownership1 6 | ownership2 7 | ownership3 8 | ownership4 9 | assets 10 | states1 11 | states2 12 | states3 13 | states-assets 14 | blockchain 15 | capabilities 16 | -------------------------------------------------------------------------------- /bin/obsidiandown: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | bin_dir="$(cd "$(dirname $BASH_SOURCE)"; pwd)" 4 | root_dir="$bin_dir/.." 5 | export OBSIDIAN_COMPILER_DIR="$root_dir" 6 | 7 | network_framework="${root_dir}/network-framework" 8 | 9 | cd ${network_framework} 10 | 11 | ${root_dir}/network-framework/down.sh 12 | -------------------------------------------------------------------------------- /evaluation/solidity_participant_template/auction-exercises/build/Auction/src/main/java/org/hyperledger/fabric/example/Contract.java: -------------------------------------------------------------------------------- 1 | package org.hyperledger.fabric.example; 2 | 3 | import edu.cmu.cs.obsidian.chaincode.ObsidianSerialized; 4 | 5 | public interface Contract 6 | extends ObsidianSerialized 7 | { 8 | } 9 | -------------------------------------------------------------------------------- /papers/yul_evm_writeup/ll_bench.csv: -------------------------------------------------------------------------------- 1 | Test,Obsidian depl.,Obsidian inv., Solidity depl., Solidity inv. 2 | LinkedListAllocate4Field,601774,276477,178377,225900 3 | LinkedListAllocate8Field,1067520,543837,187893,406604 4 | LinkedListAllocate4Local,340647,41201,N/A,N/A 5 | LinkedListAllocate8Local,533042,42786,N/A,N/A 6 | -------------------------------------------------------------------------------- /resources/tests/compilerTests/MultipleConstructorGroup.obs: -------------------------------------------------------------------------------- 1 | contract B { 2 | state S1; 3 | state S2 { 4 | int x; 5 | } 6 | 7 | B@S1() { ->S1; } 8 | 9 | B@S2(int _x) { 10 | ->S2(x = _x); 11 | } 12 | } 13 | 14 | main contract MultipleConstructorGroup { 15 | } 16 | 17 | -------------------------------------------------------------------------------- /resources/tests/compilerTests/NegativeNumber.obs: -------------------------------------------------------------------------------- 1 | main contract NegativeNumber { 2 | int x; 3 | 4 | NegativeNumber@Owned() { 5 | x = -5; 6 | } 7 | 8 | transaction decrement() returns int { 9 | int oldX = x; 10 | x = x - 1; 11 | return oldX; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /resources/tests/compilerTests/Simple3.obs: -------------------------------------------------------------------------------- 1 | main contract Simple3 { 2 | int x; 3 | int y; 4 | 5 | transaction t1() { 6 | y = 1; 7 | } 8 | 9 | transaction t2() { 10 | if y > 3 { 11 | y = 0; 12 | } else { 13 | revert; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/Revert.obs: -------------------------------------------------------------------------------- 1 | main contract Revert { 2 | transaction t1() { 3 | revert; 4 | } 5 | 6 | transaction t2() { 7 | revert "error"; 8 | } 9 | 10 | transaction t3() { 11 | // ERROR: revert requires a string. 12 | revert 3; 13 | } 14 | } -------------------------------------------------------------------------------- /bin/obsidianup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | bin_dir="$(cd "$(dirname $BASH_SOURCE)"; pwd)" 4 | root_dir="$bin_dir/.." 5 | export OBSIDIAN_COMPILER_DIR="$root_dir" 6 | 7 | network_framework="${root_dir}/network-framework" 8 | 9 | cd ${network_framework} 10 | 11 | ${root_dir}/network-framework/up.sh $@ 12 | 13 | 14 | -------------------------------------------------------------------------------- /bin/obsidianautoup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | bin_dir="$(cd "$(dirname $BASH_SOURCE)"; pwd)" 4 | root_dir="$bin_dir/.." 5 | export OBSIDIAN_COMPILER_DIR="$root_dir" 6 | 7 | network_framework="${root_dir}/network-framework" 8 | 9 | cd ${network_framework} 10 | 11 | ${root_dir}/network-framework/autoup.sh $@ 12 | 13 | 14 | -------------------------------------------------------------------------------- /network-framework/channel-artifacts/README.md: -------------------------------------------------------------------------------- 1 | # About 2 | 3 | This directory contains the genesis block for the Fabric network and associated files. 4 | It exists in the Git repository because otherwise Fabric may create a directory which only root has permission to modify, which can cause the rest of setup process to fail. 5 | 6 | -------------------------------------------------------------------------------- /obs-vscode-extension/server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "obsidian-lsp-server", 3 | "version": "1.0.0", 4 | "description": "LSP implementation for Obsidian ", 5 | "author": "Ishan", 6 | "dependencies": { 7 | "vscode-languageserver": "^6.1.1", 8 | "vscode-languageserver-textdocument": "^1.0.1" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /obs-vscode-extension/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es6", 5 | "outDir": "out", 6 | "sourceMap": true, 7 | "strict": true, 8 | "rootDir": "src" 9 | }, 10 | "include": ["src"], 11 | "compileOnSave": true, 12 | "exclude": ["node_modules", ".vscode-test"] 13 | } -------------------------------------------------------------------------------- /Obsidian_Runtime/src/main/java/Runtime/edu/cmu/cs/obsidian/client/ChaincodeClientTransactionBugException.java: -------------------------------------------------------------------------------- 1 | package edu.cmu.cs.obsidian.client; 2 | 3 | /** 4 | * Created by mcoblenz on 4/4/17. 5 | * Should only occur in cases of Obsidian bugs. 6 | */ 7 | public class ChaincodeClientTransactionBugException extends Exception { 8 | } 9 | -------------------------------------------------------------------------------- /readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # readthedocs.yml 2 | # Read the Docs configuration file 3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 4 | 5 | version: 2 6 | 7 | sphinx: 8 | configuration: user_guide/source/conf.py 9 | 10 | python: 11 | install: 12 | - requirements: user_guide/requirements.txt 13 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/AssignLocalAdd.obs: -------------------------------------------------------------------------------- 1 | main contract AssignLocalAdd{ 2 | transaction assignlocaladd() { 3 | int x; 4 | bool y; 5 | x = 5 + 12; 6 | return; 7 | } 8 | 9 | transaction main() returns int { 10 | int x = 5 + 12; 11 | return x; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /resources/tests/compilerTests/Reentrant.obs: -------------------------------------------------------------------------------- 1 | 2 | main contract Reentrant { 3 | 4 | transaction t2(A a) returns int { 5 | return a.t1(); 6 | } 7 | } 8 | 9 | contract A { 10 | 11 | transaction t1() returns int { 12 | Reentrant c = new Reentrant(); 13 | return c.t2(this); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /user_guide/source/reference/reference.rst: -------------------------------------------------------------------------------- 1 | Obsidian Language Reference 2 | ============================ 3 | 4 | Before using this reference guide, please read the entire tutorial first, since the reference guide uses concepts explained in the tutorial. 5 | 6 | .. toctree:: 7 | Language Basics 8 | Obsidian Clients -------------------------------------------------------------------------------- /Obsidian_Runtime/publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PUBLISH="$(gradle publish)" 4 | echo "publish result: $PUBLISH" 5 | 6 | if [[ $PUBLISH =~ .*SUCCESS.* ]] 7 | then 8 | scp -r ../docs/repository mcoblenz@linux.gp.cs.cmu.edu:~/www/ 9 | rm -rf ~/.gradle/caches/ 10 | exit 0 11 | else 12 | exit 1 13 | fi 14 | -------------------------------------------------------------------------------- /evaluation/pilot3/tutorial-exercises/code1.obs: -------------------------------------------------------------------------------- 1 | 2 | //Write a contract called Person that has an Owned reference to a House and a Shared reference to a Park. 3 | //The House and Park contracts are given below. 4 | //The Person contract MUST be main 5 | 6 | 7 | contract House { 8 | 9 | } 10 | 11 | contract Park { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /resources/protos/InterfaceImplementerWrapper.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option java_outer_classname = "InterfaceImplementerWrapperOuterClass"; 4 | 5 | option java_package = "org.hyperledger.fabric.example"; 6 | 7 | 8 | message InterfaceImplementerWrapper { 9 | string __className = 1; 10 | 11 | string __guid = 2; 12 | } -------------------------------------------------------------------------------- /resources/tests/compilerTests/ConstructorWithArgs2.obs: -------------------------------------------------------------------------------- 1 | contract A {} 2 | 3 | main contract C { 4 | string a; 5 | A@Shared b; 6 | 7 | C@Owned(string x, A@Shared y) { 8 | a = x; 9 | b = y; 10 | ->S1; 11 | } 12 | 13 | state S1 {} 14 | 15 | state S { 16 | string x; 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /evaluation/solidity_participant_template/tutorial-exercises/code1.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.5.11; 2 | 3 | //Write a contract called Person that has an owned reference to a House and a shared reference to a Park. 4 | //The House and Park contracts are given below. 5 | 6 | 7 | contract House { 8 | 9 | } 10 | 11 | contract Park { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /resources/tests/LinkedListAppendClient.obs: -------------------------------------------------------------------------------- 1 | import "resources/tests/LinkedList.obs" 2 | 3 | main contract LinkedListAppendClient { 4 | // TODO: support arbitrary parameters to main. 5 | // For now, the parameters are limited to on-chain contract instances. 6 | transaction main(remote IntList list) { 7 | list.append(42); 8 | } 9 | } -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/AssetStateTracking.obs: -------------------------------------------------------------------------------- 1 | main contract AssetStateTracking { 2 | asset state S1 { 3 | int x; 4 | } 5 | 6 | AssetStateTracking@Owned() { 7 | ->S1(x = 0); 8 | } 9 | 10 | transaction f() { 11 | AssetStateTracking c = new AssetStateTracking(); 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org2.example.com/msp/config.yaml: -------------------------------------------------------------------------------- 1 | NodeOUs: 2 | Enable: true 3 | ClientOUIdentifier: 4 | Certificate: cacerts/ca.org2.example.com-cert.pem 5 | OrganizationalUnitIdentifier: client 6 | PeerOUIdentifier: 7 | Certificate: cacerts/ca.org2.example.com-cert.pem 8 | OrganizationalUnitIdentifier: peer -------------------------------------------------------------------------------- /evaluation/obsidian_participant_template/tutorial-exercises/code1.obs: -------------------------------------------------------------------------------- 1 | 2 | //Write a contract called Person that has an Owned reference to a House and a Shared reference to a Park. 3 | //The House and Park contracts are given below. 4 | //The Person contract MUST be main 5 | 6 | 7 | contract House { 8 | 9 | } 10 | 11 | contract Park { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /network-framework/crypto-config/ordererOrganizations/example.com/users/Admin@example.com/tls/client.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg7dDZxjTHithln4mf 3 | 8KSz0OQUbJ4Lv0TS91aO9lK5FmChRANCAARsKH1JddbU5G5uL1W6Z5tkAX5Ou7/n 4 | BJq9ZK66yVNtBP3Ia/MQv4TBtN88KbTzqoazjqLYT2E0QUaX/Lj7i8P5 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org1.example.com/msp/config.yaml: -------------------------------------------------------------------------------- 1 | NodeOUs: 2 | Enable: true 3 | ClientOUIdentifier: 4 | Certificate: cacerts/ca.org1.example.com-cert.pem 5 | OrganizationalUnitIdentifier: client 6 | PeerOUIdentifier: 7 | Certificate: cacerts/ca.org1.example.com-cert.pem 8 | OrganizationalUnitIdentifier: peer 9 | -------------------------------------------------------------------------------- /network-framework/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg+3YoQ93Dx6nq6QmP 3 | XPjGt2CP7hY3PWTGju8YtKK3CRmhRANCAARK/TIdIj67N+fza/hcUx6WmlBiWusN 4 | QZthl/s4rUFJSS5kl5zMLiOkoZhHufx/zV2F0BvA9P5aODUUx/yi3jPv 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgJ8fKskHbIqv9lywp 3 | hgYASAHLW6ilNCRELahBwnSCA4yhRANCAATHuAjCWdFWHYM5TmjvsGjXDp/Y/VBo 4 | QhFZm0UMUmX5mM2G+QbKJXGUiGeGv0RgseyD+edFJBdC2OkKgl1Evx8w 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls/server.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgfWP2TD/o6ghxlWb/ 3 | tA96OBg+d4RIzVdHbol+FnRr81qhRANCAAQa3Af2B8jttJbGYIGpROkQzFkMexk1 4 | jo8pUGsWEbVyNMD14gCc0UHTIb3Qkfj+qrWk7qg3O64ZgOqBwmW6Xd/h 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/tls/client.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg1QwWSdjQFe2qn00x 3 | SzNWbR3spwC0nEFAlwe4+PxuceChRANCAASjZaVWFbixt9PuDCCy/Krqzfvs1P9I 4 | cT3XfzeYyT9kRtZk4KO23caP+83Asa3KCGP2VKm2M9eqecU2wz4eAwMi 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/tls/client.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgY2KLiJwXdvOITCUY 3 | 8Ok2g7Kd/h3OOnFvtt3/zwK+A+KhRANCAAQbPcmg6lhcsYydojK+BKXwS0GNZDA0 4 | Vknf64d2a0Y2NlBMVY29IFp+ksPmhhcAvr72/DN3G3lzd771x51+HG41 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/server.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgsyx0AuGk1Vg1ExOX 3 | oRAb4LfTEKrW9KIQgvcThJgq95qhRANCAASuWbr2sucHU7bVV5/Ahs/qjszZd6IO 4 | dD+SUBVIrQvCYIdvrQvf1b2X5K+CT4NJU3I37tuqds0dlPF5E84HC/Fq 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls/server.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg+4vVy1DzKhasEP4l 3 | 4fWP4iFytv7CgFjOFLbVQHngANehRANCAASmUF0Tm1dpcpUxDsg+nhSSNeuo65js 4 | f5Q9ZOz86d+eM2J0jUneETsGry5fBnRAYpymBuF8dHcMbeNUMgjfMRvf 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/tls/client.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgs4QB3jdh9VY5ilaN 3 | Y57bwBH3mD2RF8LuJwM9Dm2oKguhRANCAAR6JLFu9M3PL1531oSsQgkwHeslpzH2 4 | B9e7zGJTJi12oMO85W0bT8mBOAXdDknuqvOiy1D5SYVww7H0sW4lLbLp 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org2.example.com/users/User1@org2.example.com/tls/client.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgDCxUptCTLjEyZ0Ju 3 | PPbYwt2FHBSwGm77nxDd5PpDC4OhRANCAAREG0y8PiDQhLQ5hKlrbxzFoe/VI8Dj 4 | XniBURWYAhbZejppQ8iuaVUQSpdGNQSZP465IKWAYOA6lCJVGGvD1xA5 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /resources/tests/compilerTests/IntContainerClient.obs: -------------------------------------------------------------------------------- 1 | import "IO.obs" 2 | 3 | import "resources/tests/IntContainer.obs" 4 | 5 | main contract IntContainerClient { 6 | transaction main(remote IntContainer@Shared container) { 7 | int oldX = container.setX(3); 8 | container.setX(4); 9 | new IO().printInt(4); 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/EndsInState.obs: -------------------------------------------------------------------------------- 1 | main contract C { 2 | // error: constructor for 'C' ends in S1 instead of S2 3 | C@S2() { 4 | ->S1; 5 | } 6 | 7 | // error: t ends in S2 instead of S1 8 | transaction t(C@S2 >> S1 this) { 9 | int x = 1; 10 | } 11 | 12 | 13 | state S1 {} 14 | state S2 {} 15 | } -------------------------------------------------------------------------------- /obs-vscode-extension/server/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "sourceMap": true, 7 | "strict": true, 8 | "outDir": "out", 9 | "rootDir": "src" 10 | }, 11 | "include": ["src"], 12 | "exclude": ["node_modules", ".vscode-test"], 13 | "compileOnSave": true 14 | } 15 | -------------------------------------------------------------------------------- /resources/tests/compilerTests/ConstructorWithArgs.obs: -------------------------------------------------------------------------------- 1 | contract A {} 2 | 3 | main contract ConstructorWithArgs { 4 | int a; 5 | A@Shared b; 6 | 7 | ConstructorWithArgs@Owned(int x, A@Shared y) { 8 | a = x; 9 | b = y; 10 | ->S1; 11 | } 12 | 13 | state S1 {} 14 | 15 | state S { 16 | int x; 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/AssetStateTrackingOkay.obs: -------------------------------------------------------------------------------- 1 | main contract AssetStateTracking { 2 | asset state S1 { 3 | int x; 4 | } 5 | 6 | AssetStateTracking@Owned() { 7 | ->S1(x = 0); 8 | } 9 | 10 | transaction f() { 11 | AssetStateTracking c = new AssetStateTracking(); 12 | disown c; 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /Obsidian_Runtime/src/main/java/Runtime/edu/cmu/cs/obsidian/chaincode/BadTransactionException.java: -------------------------------------------------------------------------------- 1 | package edu.cmu.cs.obsidian.chaincode; 2 | 3 | /** 4 | * Created by mcoblenz on 4/6/17. 5 | */ 6 | public class BadTransactionException extends ObsidianChaincodeException { 7 | public BadTransactionException(String f, int l) { 8 | super (f, l); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/If.obs: -------------------------------------------------------------------------------- 1 | main contract If { 2 | transaction iftest() { 3 | int x; 4 | if (true) { 5 | x = 1; 6 | } 7 | return; 8 | } 9 | 10 | transaction main() returns int { 11 | int x = 0; 12 | if (true) { 13 | x = 1; 14 | } 15 | return x; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /resources/tests/IntContainer.obs: -------------------------------------------------------------------------------- 1 | main contract IntContainer { 2 | int x; 3 | string s; 4 | bool b; 5 | 6 | IntContainer@Owned() { 7 | x = 5; 8 | s = "aaa"; 9 | b = true; 10 | } 11 | 12 | transaction setX(int newX) returns int { 13 | int oldX = x; 14 | x = newX; 15 | return oldX; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /resources/tests/PrimitiveTypesClient.obs: -------------------------------------------------------------------------------- 1 | import "PrimitiveTypes.obs" 2 | 3 | main contract PrimitiveTypesClient { 4 | transaction main(remote PrimitiveTypes container) { 5 | int oldX = container.setInt(42); 6 | container.setInt(oldX); 7 | container.setInt(42); 8 | 9 | container.setBool(true); 10 | 11 | container.setString("Hello, world!"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /formalization/README.txt: -------------------------------------------------------------------------------- 1 | This directory contains a mechanization in Agda of a very small fragment of 2 | Silica, consisting only of variables. I stopped working on this after determining that mechanizing the entire Silica language would take a prohibitive amount of time. Nonetheless, some key properties of Silica are proved here, so I am keeping this around as evidence of those properties. -------------------------------------------------------------------------------- /network-framework/README.md: -------------------------------------------------------------------------------- 1 | ## Build Your First Network (BYFN) 2 | 3 | The directions for using this are documented in the Hyperledger Fabric 4 | ["Build Your First Network"](http://hyperledger-fabric.readthedocs.io/en/latest/build_network.html) tutorial. 5 | 6 | *NOTE:* After navigating to the documentation, choose the documentation version that matches your version of Fabric 7 | 8 | -------------------------------------------------------------------------------- /resources/tests/IntContainerClient.obs: -------------------------------------------------------------------------------- 1 | import "IntContainer.obs" 2 | 3 | import "IO.obs" 4 | 5 | main contract IntContainerClient { 6 | transaction main(remote IntContainer@Shared container) { 7 | int oldX = container.setX(3); 8 | new IO().println(oldX); 9 | oldX = container.setX(4); 10 | new IO().println(oldX); 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/VariableDeclarations.obs: -------------------------------------------------------------------------------- 1 | contract C { 2 | state S1; 3 | state S2; 4 | 5 | C@S1() { 6 | ->S1; 7 | } 8 | } 9 | 10 | main contract VariableDeclarations { 11 | C@S1 cField; 12 | 13 | transaction t(C@S2 cArg) { 14 | // Error: can't specify typestate on local variable 15 | C@S1 c; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /network-framework/crypto-config/ordererOrganizations/example.com/ca/dd6afe68adf9c80e6afc4da59262928556f3e3b7c21140088a4b78580feae756_sk: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgx17VPdZS0Ubg/u0r 3 | QvblsaKRyZzHzcMLFex4P8CbSjGhRANCAAQGXA/LB3ufSeJ/exXLLmpxRRlt1X// 4 | Xnv6y+xWQ2z3kHXwraGJtbC33UAlyTo7ihwdw7MzEJyeYg7Mu4IOron2 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org1.example.com/ca/537d87b1a79409452b77983258b32a31d7ff20c6760defcdb1c7460576040989_sk: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgOXO1HDOeG85wGM1k 3 | OT7OGAbxyGn2vgS6+LgLBC4UfF6hRANCAARUevcEtVHEabtXfJ2/rVSkfk+Jdqeg 4 | FqHfxDbed0kFaM8hRUITwy1MQW/eBp/Lt9KacFZbBbMLFhhGib1iSpKg 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/config.yaml: -------------------------------------------------------------------------------- 1 | NodeOUs: 2 | Enable: true 3 | ClientOUIdentifier: 4 | Certificate: cacerts/ca.org1.example.com-cert.pem 5 | OrganizationalUnitIdentifier: client 6 | PeerOUIdentifier: 7 | Certificate: cacerts/ca.org1.example.com-cert.pem 8 | OrganizationalUnitIdentifier: peer 9 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp/config.yaml: -------------------------------------------------------------------------------- 1 | NodeOUs: 2 | Enable: true 3 | ClientOUIdentifier: 4 | Certificate: cacerts/ca.org1.example.com-cert.pem 5 | OrganizationalUnitIdentifier: client 6 | PeerOUIdentifier: 7 | Certificate: cacerts/ca.org1.example.com-cert.pem 8 | OrganizationalUnitIdentifier: peer 9 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org2.example.com/ca/1124c4985d7363fa48511a22900843c0b121228df9ad270687e8fcfe03a435d7_sk: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg8iH3U8S0kwNiVBFm 3 | hOAPg8eCFDLqX1k6QMRERM7XmRKhRANCAAQIQQ8BwwBgd6f6KNweQdEJ617RmxwT 4 | bQN2ORt+qeQsg65+kipyxACndkpRqxVGOfd3PYlHeqM2NZxwGPkt3+Hn 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/config.yaml: -------------------------------------------------------------------------------- 1 | NodeOUs: 2 | Enable: true 3 | ClientOUIdentifier: 4 | Certificate: cacerts/ca.org2.example.com-cert.pem 5 | OrganizationalUnitIdentifier: client 6 | PeerOUIdentifier: 7 | Certificate: cacerts/ca.org2.example.com-cert.pem 8 | OrganizationalUnitIdentifier: peer 9 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp/config.yaml: -------------------------------------------------------------------------------- 1 | NodeOUs: 2 | Enable: true 3 | ClientOUIdentifier: 4 | Certificate: cacerts/ca.org2.example.com-cert.pem 5 | OrganizationalUnitIdentifier: client 6 | PeerOUIdentifier: 7 | Certificate: cacerts/ca.org2.example.com-cert.pem 8 | OrganizationalUnitIdentifier: peer 9 | -------------------------------------------------------------------------------- /formalization/false.elf: -------------------------------------------------------------------------------- 1 | %{ This is part of a proof of the soundness of Featherweight Java (Atsushi Igarashi, 2 | Benjamin Pierce and Philip Wadler) in the Twelf logical Framework. 3 | It was developed by Stephanie Weirich and 4 | Geoffrey Washburn . }% 5 | 6 | % Library about false. 7 | 8 | false : type. 9 | %name false FALSE f. 10 | 11 | -------------------------------------------------------------------------------- /network-framework/crypto-config/ordererOrganizations/example.com/tlsca/952b1e43ab3ec5859693d8e8f510489e3dff1504e75a7a484a55bd579e80de01_sk: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgOPIMf6oZx7tHTF2A 3 | IdVCQ0Wci30JZc2Ca1Ixa4/50YuhRANCAARfYAR0ugG5lwRGLKm4Bc4FcRYKrFRR 4 | vzylqtqGo1qDcH1RHr0AeoeSUdp0D7Hd06Mtd0pUmLeFkNbjqx153PxI 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org1.example.com/tlsca/8968b62998908f7a3ac997d3eac4c66b951b13bf50819cac539052bfbf10d5b8_sk: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgoo/CDqmAmFNoBw8S 3 | nALCM64h/ZhSo7QIuP73j7PZd5ChRANCAAQRd1iVG7VoePzQe9rH22ABKb69PSkR 4 | kbpBrTevGS3ufuFZ5+CU2EFGIHCF2QxXrlkDacd7g3em1VSklV/fI1LC 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org2.example.com/tlsca/090420edbb352674a18308ce5352ca80f7e88206490453a91b07ec8e18bda502_sk: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg2FXWvcrE3qY4wVFL 3 | gLyL53wHIj3npwp7dLl1aJzjp9+hRANCAATtgRWXLvEsFVY+WrbIZclNM4y1cm0D 4 | hC0w/RV0InI1QAJTh7aaSeaEy6S20OO+V7fqbXeZjIf1QhKmSkZ0CiWh 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /resources/tests/compilerTests/IntContainer.obs: -------------------------------------------------------------------------------- 1 | main contract IntContainer { 2 | int x; 3 | string s; 4 | bool b; 5 | 6 | IntContainer@Owned() { 7 | x = 5; 8 | s = "aaa"; 9 | b = true; 10 | } 11 | 12 | transaction setX(int newX) returns int { 13 | int oldX = x; 14 | x = newX; 15 | return oldX; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /resources/tests/parser_tests/AvailableInRepeats.obs: -------------------------------------------------------------------------------- 1 | main contract C { 2 | state S1 { 3 | } 4 | state S2 { 5 | // Disabled fuctions pending #159. 6 | //function f() returns int available in S1 { return x; } 7 | //function f(T x) { return x; } 8 | } 9 | transaction t(C@(S1|S2) this) { return x; } 10 | transaction t(C@S1 this, T x) { return x; } 11 | } -------------------------------------------------------------------------------- /resources/tests/SolidityBenchmarks/AssignLocalAdd.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD 2 | 3 | pragma solidity >=0.8.0; 4 | 5 | contract AssignLocalAdd { 6 | function assignlocaladd() public pure { 7 | int x; 8 | x = 5 + 12; 9 | return; 10 | } 11 | 12 | function main() public pure returns (int) { 13 | int x = 5 + 12; 14 | return x; 15 | } 16 | } -------------------------------------------------------------------------------- /resources/tests/StringContainer.obs: -------------------------------------------------------------------------------- 1 | main contract StringContainer { 2 | string s; 3 | 4 | StringContainer() { 5 | s = "aaa"; 6 | } 7 | 8 | transaction getString() returns string { 9 | return s; 10 | } 11 | 12 | transaction setString(string newS) returns string { 13 | string oldS = s; 14 | s = newS; 15 | return oldS; 16 | } 17 | } -------------------------------------------------------------------------------- /resources/tests/simple2.obs: -------------------------------------------------------------------------------- 1 | main contract Simple2 { 2 | int x; 3 | int y; 4 | 5 | state S1 { 6 | } 7 | 8 | transaction t1() available in S1 { 9 | y = 1; 10 | ->S2; 11 | } 12 | 13 | state S2 { 14 | function f() { 15 | y = y + y; 16 | } 17 | } 18 | 19 | transaction t2() { 20 | f(); 21 | ->S1; 22 | } 23 | } -------------------------------------------------------------------------------- /Obsidian_Runtime/src/main/java/Runtime/edu/cmu/cs/obsidian/stdlib/IO.java: -------------------------------------------------------------------------------- 1 | package edu.cmu.cs.obsidian.stdlib; 2 | import java.lang.*; 3 | 4 | public class IO { 5 | public void print(String s) { 6 | System.out.print(s); 7 | } 8 | public void println(String s) { 9 | System.out.println(s); 10 | } 11 | public void printInt(java.math.BigInteger n) { System.out.print(n); } 12 | } -------------------------------------------------------------------------------- /evaluation/pilot4/tutorial-exercises/code1.obs: -------------------------------------------------------------------------------- 1 | 2 | //Write a contract called Person that has an Owned reference to a House and a Shared reference to a Park. 3 | //The House and Park contracts are given below. 4 | //The Person contract MUST be main 5 | main contract Person { 6 | House@Owned p; 7 | Park@Shared p1; 8 | } 9 | 10 | contract House { 11 | 12 | } 13 | 14 | contract Park { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /papers/yul_evm_writeup/macros.tex: -------------------------------------------------------------------------------- 1 | \newcommand{\obssrc}[1]{\texttt{#1}} 2 | \newcommand{\yulsrc}[1]{\texttt{#1}} 3 | \newcommand{\cmu}{\affiliation{ 4 | \institution{Carnegie Mellon University} 5 | \streetaddress{5000 Forbes Ave} 6 | \city{Pittsburgh} 7 | \state{PA} 8 | \postcode{15217} 9 | \country{USA} 10 | } 11 | } 12 | \newcommand{\solc}{\texttt{solc}} 13 | \newcommand{\todo}[1]{TODO: #1} 14 | -------------------------------------------------------------------------------- /resources/tests/parser_tests/StateInitialization.obs: -------------------------------------------------------------------------------- 1 | main contract Test { 2 | state S1 { 3 | int x1; 4 | int x2; 5 | } 6 | 7 | state S2 { 8 | int x2; 9 | int x3; 10 | } 11 | 12 | state S3 {} 13 | 14 | int shared available in S1, S2; 15 | 16 | Test@S1() { 17 | S1::x1 = 42; 18 | S1::shared = 44; 19 | 20 | S1::x1 = 45; 21 | shared = 2; 22 | } 23 | } -------------------------------------------------------------------------------- /evaluation/pilot7/tutorial-exercises/code1.obs: -------------------------------------------------------------------------------- 1 | 2 | //Write a contract called Person that has an Owned reference to a House and a Shared reference to a Park. 3 | //The House and Park contracts are given below. 4 | //The Person contract MUST be main 5 | 6 | 7 | contract House { 8 | 9 | } 10 | 11 | contract Park { 12 | 13 | } 14 | 15 | main contract Person{ 16 | House@Owned h; 17 | Park@Shared p; 18 | } -------------------------------------------------------------------------------- /evaluation/pilot8/tutorial-exercises/code1.obs: -------------------------------------------------------------------------------- 1 | 2 | //Write a contract called Person that has an Owned reference to a House and a Shared reference to a Park. 3 | //The House and Park contracts are given below. 4 | //The Person contract MUST be main 5 | 6 | 7 | contract House { 8 | 9 | } 10 | 11 | contract Park { 12 | 13 | } 14 | 15 | main contract Person { 16 | House@Owned h; 17 | Park@Shared p; 18 | } -------------------------------------------------------------------------------- /evaluation/pilot6/tutorial-exercises/code1.obs: -------------------------------------------------------------------------------- 1 | 2 | //Write a contract called Person that has an Owned reference to a House and a Shared reference to a Park. 3 | //The House and Park contracts are given below. 4 | //The Person contract MUST be main 5 | 6 | main contract Person { 7 | House @ Owned house; 8 | Park @ Shared park; 9 | } 10 | 11 | contract House { 12 | } 13 | 14 | contract Park { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /network-framework/crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp/keystore/652029aab9649a19fe92c8baa893fae96cebcfec06eb63037bc71149eec43b5f_sk: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgDUoF4iUsfY6HD8m6 3 | gabuqQ7UOmW4EpiqixCVrVIvQKqhRANCAARfbIY0ijbV5eCoxytELOFErhbY9frd 4 | 45c0fVzqykaWjCArAVXloF4VQzxZpncHeOFPP8gzqsQbF/msjCphRpiJ 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /resources/tests/SolidityBenchmarks/Return.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD 2 | 3 | pragma solidity >=0.8.0; 4 | 5 | 6 | contract Return { 7 | function f() public pure returns (int) { 8 | return (4+4); 9 | } 10 | function g() pure public { 11 | int x = f(); 12 | return; 13 | } 14 | 15 | function main() public returns (int) { 16 | return f(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /resources/tests/compilerTests/StringContainerContainerClient.obs: -------------------------------------------------------------------------------- 1 | import "StringContainerContainer.obs" 2 | 3 | main contract StringContainerContainerClient { 4 | transaction main(remote StringContainerContainer@Shared c) { 5 | StringContainer container = new StringContainer("test", 2); 6 | c.setContainer(container); 7 | remote StringContainer getCont = c.getContainer(); 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/UndefinedVariable.obs: -------------------------------------------------------------------------------- 1 | // checks that undefined variable errors are thrown at proper times 2 | 3 | main contract Variable { 4 | 5 | transaction accessVariable() { 6 | // error: x not defined 7 | x = 7; 8 | // error: z not defined (use before definition) 9 | int y = z + 5; 10 | 11 | int z = 5; 12 | z = 5 + 3; 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /evaluation/P41/tutorial-exercises/code1.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.5.11; 2 | 3 | //Write a contract called Person that has an owned reference to a House and a shared reference to a Park. 4 | //The House and Park contracts are given below. 5 | contract Person { 6 | House house; // house is owned 7 | Park park; // park is shared 8 | } 9 | 10 | contract House { 11 | 12 | } 13 | 14 | contract Park { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /evaluation/pilot3/tutorial-exercises/code1_R3.obs: -------------------------------------------------------------------------------- 1 | 2 | //Write a contract called Person that has an Owned reference to a House and a Shared reference to a Park. 3 | //The House and Park contracts are given below. 4 | //The Person contract MUST be main 5 | 6 | 7 | contract House { 8 | 9 | } 10 | 11 | contract Park { 12 | 13 | } 14 | 15 | main contract Person { 16 | House@Owned h; 17 | Park@Shared p; 18 | 19 | } -------------------------------------------------------------------------------- /evaluation/pilot5/tutorial-exercises/code1.obs: -------------------------------------------------------------------------------- 1 | 2 | //Write a contract called Person that has an Owned reference to a House and a Shared reference to a Park. 3 | //The House and Park contracts are given below. 4 | //The Person contract MUST be main 5 | 6 | 7 | contract House { 8 | 9 | } 10 | 11 | contract Park { 12 | 13 | } 14 | 15 | main contract Person { 16 | House@Owned house; 17 | Park@Shared shared; 18 | } -------------------------------------------------------------------------------- /network-framework/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp/keystore/05640e8a4054bac9e9396b90f73ae49127bc28433e96bd55b1b771cac46d530b_sk: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgM7Kh/HKRiZ+Enyiv 3 | 0PqwvXgybqbUR9i1cs09rnnGCE2hRANCAATltb/RHEVvu6BvXKnSB74k+ODFD6WR 4 | 4+c2qBtbb7LHVGDe3mRoSbzV3EXvokEvrqAJ+I/3zbmN5rOFgV51CKio 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/keystore/d9eb52653e83ebd36793367da6eb2858abc470bd2ccfc0f71c2dc6197d9b74e7_sk: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgYeEmNmVA2UX40lji 3 | 7r/eTphirkRJiSEmBh9YMvPoHvOhRANCAARszZWZ/Xpqkj834B3Td4QfNal9sLkA 4 | 1y0ArkCgWSWm4Iux+B3pXK2PjA0xJs1C5fSGMCVTQqUxixSe9jegGGi3 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp/keystore/c7718967d22ef526fbcca7b455b2f06f667b40fe9c2c2edaed259286642e1faa_sk: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgqQVrJFrr+caWYzA3 3 | JeOyXAm/vn2x7LxMVs/JhLPIQN6hRANCAASB2z1IG+AHSvLcF5XAUdS7NaYRctxX 4 | MK5lUGS/OYdsMG5TPh3G8QO6cAuxMKnNAbU9a8EJ9Oyoo9E5kHyfIswD 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/1143cbd6e5746190bb865d20dc6668236217c2fb76e2a666ff5615f2713947e9_sk: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg9rbLyNAbrS3ioXfk 3 | qQGj+G5N+HWx3rvbiUTk8QgO9d+hRANCAAT81nwTr7k5jjMyF0azHxcPOLSb7cOB 4 | eG1YWYyuyyvb7WF+Va26Tr4iowoXj40RU6PsR9yEfOwbLtDWqAKdPuaN 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/keystore/5d0c74202ab8720c0c36615291dc436d40052a914617af1eba01965e008e7462_sk: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg8FQ1oWrOczTkEYt5 3 | xqn8JUjlxnX2z2+CUgZukusmkBKhRANCAAQacZWSh8tmTGoAAkVbBmFcr9rCdNTu 4 | VRxQmR2GoUkci6tbnytWuhCVRT4k8myOdUTrPZWX5zhJx5lFaYTDGiCb 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/keystore/6af06030e89043e0a2ed077e39a82f19aa5665a83f74261b995570dfec44b62a_sk: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgCG5Ogi37qxmR2AWb 3 | 8CCYKzz/pV5mGmqkGmp9vnOHoDShRANCAAQ+rx0adwbeF36WOdZba2ui3WgjS4F1 4 | rYWio1doji6NHiOIbcsstCy6DGegn2JSGDrEw+WhUpVuSA8DN0MrNbcX 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp/keystore/81feddf769d2bf55b65cdc9b70ddf16be819c27bf1a90491d11285518a180659_sk: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgRCNuQbVlEGoTkPQD 3 | 9qx2ZlN3jc/U5sjzuqFZ8w9Tjh+hRANCAATqe/ddxYIZTM/zcj5XR9y+KILmJGjG 4 | LG3wLjYR62NhIT0u8aNmVrV5R8mpKw3IaJvvbbWY+lZVR7rMkjovP5Ex 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/keystore/a9998f4a439f51c97191286c7965509f7a989e56da9d84a129fef279237da5a7_sk: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgY10Jk131eK07+lZE 3 | sIPO0fTJb7ojN37bWJBVrqosPQGhRANCAASMz1OzHgihyERMrzIqukG1mAYQc+5S 4 | XXf0u6eD9kCj7kmKOorIcHROutwPRxSK+HlF0n8w5hE82KhfegLbtd7A 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /network-framework/crypto-config/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/keystore/7ac50fa632e9f3bdc3fed1c1d8f06c9ece77c24425ce9fecdb656e12c4e040cd_sk: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg1qdKgv9gZaKgI25u 3 | m8koruBH1IzOe+VuU1PYxIWbaa+hRANCAARm/BPIkB1esBeYsCGSeW0DDN9NmSl4 4 | TXyRibl1eSwVtLfgyD+oduPhX7i8uiGZBmC4zJ8WUZ4rMm2lQOmyiAkJ 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /evaluation/P41/betting-exercises/betting.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.5.11; 2 | 3 | import "./betting_utils.sol"; 4 | 5 | contract Casino { 6 | Game currentGame; //The game that is currently being played 7 | BetList bets; //The bets for the current game being played 8 | 9 | constructor(Game g, BetList b) public { 10 | currentGame = g; 11 | bets = b; 12 | } 13 | 14 | //TODO: Add your code here. 15 | } -------------------------------------------------------------------------------- /resources/tests/compilerTests/TransactionInConstructor.obs: -------------------------------------------------------------------------------- 1 | main contract TransactionInConstructor { 2 | int y; 3 | 4 | TransactionInConstructor@Owned() { 5 | y = simpleTransaction(); 6 | } 7 | 8 | transaction simpleTransaction(TransactionInConstructor@Unowned this) returns int { 9 | return 1; 10 | } 11 | 12 | transaction getY() returns int { 13 | return y; 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /resources/tests/owned.obs: -------------------------------------------------------------------------------- 1 | asset contract IsOwned { 2 | int x; 3 | 4 | transaction setX(int y) { 5 | x = y; 6 | } 7 | 8 | IsOwned(int x_init) { 9 | x = x_init; 10 | } 11 | } 12 | 13 | main contract UsesOwned { 14 | IsOwned u; 15 | 16 | transaction changeOwned(int y) { 17 | u.setX(y); 18 | } 19 | 20 | UsesOwned() { 21 | u = new IsOwned(5); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/MultipleConstructors.obs: -------------------------------------------------------------------------------- 1 | // testing for main contracts to only have one constructor 2 | 3 | main contract C { 4 | int x; 5 | int y; 6 | 7 | C@Owned(int first) { 8 | x = first; 9 | y = 0; 10 | } 11 | // error: main contracts should have one constructor 12 | C@Owned(int first, int second) { 13 | x = first; 14 | y = second; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /travis_specific/install-protobuf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | # check to see if protobuf folder is empty 5 | if [ ! -d "${HOME}/protobuf/" ]; then 6 | mkdir -p ${HOME}/protobuf/ 7 | wget https://github.com/google/protobuf/releases/download/v3.7.0/protoc-3.7.0-linux-x86_64.zip 8 | unzip protoc-3.7.0-linux-x86_64.zip 9 | mv bin/protoc ${HOME}/protobuf/ 10 | else 11 | echo "Using cached directory." 12 | fi 13 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/NoSideEffects.obs: -------------------------------------------------------------------------------- 1 | // checks that there are errors for statements that don't have side effects 2 | 3 | main contract NoSideEffects { 4 | 5 | transaction a() { 6 | int x = 2; 7 | // should fail 8 | x; 9 | // should fail 10 | 1 + 3; 11 | // should fail 12 | 1 < x; 13 | // should fail 14 | true || false; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /docs/repository/edu/cmu/cs/obsidian/runtime/maven-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | edu.cmu.cs.obsidian 4 | runtime 5 | 6 | 0.1 7 | 0.1 8 | 9 | 0.1 10 | 11 | 20200410214536 12 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/scala_compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /evaluation/pilot2/Betting_R2.obs: -------------------------------------------------------------------------------- 1 | import "resources/sample_programs/pilot2/betting_utils.obs" 2 | import "resources/sample_programs/pilot2/games.obs" 3 | 4 | 5 | main asset contract Casino { 6 | 7 | Money@Owned money; 8 | GameRecordList@Shared gamerecords; 9 | 10 | Casino@Owned() { 11 | money = new Money(100000); 12 | gamerecords = new GameRecordList(); 13 | } 14 | //TODO: Add your code here. 15 | 16 | 17 | } -------------------------------------------------------------------------------- /resources/tests/GanacheTests/SetGetWithArgs.obs: -------------------------------------------------------------------------------- 1 | contract IntContainer{ 2 | int x; 3 | 4 | transaction set(int value) { 5 | x = value; 6 | } 7 | transaction get() returns int{ 8 | return x; 9 | } 10 | } 11 | 12 | main contract SetGetWithArgs{ 13 | transaction main() returns int{ 14 | IntContainer ic = new IntContainer(); 15 | ic.set(5); 16 | return (ic.get()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /evaluation/pilot2/betting_pilot.obs: -------------------------------------------------------------------------------- 1 | import "resources/sample_programs/pilot2/betting_utils.obs" 2 | import "resources/sample_programs/pilot2/games.obs" 3 | 4 | 5 | main asset contract Casino { 6 | 7 | Money@Owned money; 8 | GameRecordList@Shared gamerecords; 9 | 10 | Casino@Owned() { 11 | money = new Money(100000); 12 | gamerecords = new GameRecordList(); 13 | } 14 | //TODO: Add your code here. 15 | 16 | 17 | } -------------------------------------------------------------------------------- /src/main/scala/edu/cmu/cs/obsidian/codegen/CodeGenerator.scala: -------------------------------------------------------------------------------- 1 | package edu.cmu.cs.obsidian.codegen 2 | 3 | import java.nio.file.Path 4 | 5 | import edu.cmu.cs.obsidian.CompilerOptions 6 | import edu.cmu.cs.obsidian.parser.SymbolTable 7 | 8 | trait CodeGenerator { 9 | def gen(filename: String, srcDir: Path, outputPath: Path, protoDir: Path, 10 | options: CompilerOptions, checkedTable: SymbolTable, transformedTable: SymbolTable): Boolean 11 | } -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/InStateOwnershipChange.obs: -------------------------------------------------------------------------------- 1 | contract Key {} 2 | 3 | contract Lock { 4 | transaction unlock (Key @ Owned >> Unowned k) returns Key @ Owned { 5 | return new Key(); 6 | } 7 | } 8 | 9 | main contract Thief { 10 | transaction unlock(Lock@Shared l, Key@Shared k) { 11 | if (k in Owned) { 12 | Key newKey = l.unlock(k); 13 | // ERROR: k is no longer owned. 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/SameNameFields.obs: -------------------------------------------------------------------------------- 1 | main contract C { 2 | 3 | C@S1(){ 4 | ->S1(x=1,shared=1,test=1); 5 | } 6 | 7 | state S1 { 8 | int x; 9 | } 10 | 11 | state S2 { 12 | } 13 | 14 | state S3 { 15 | int x; 16 | } 17 | 18 | int shared available in S1, S2; 19 | int shared available in S3; 20 | 21 | int test; 22 | int test available in S1; 23 | 24 | int x; 25 | 26 | } -------------------------------------------------------------------------------- /evaluation/pilot3/betting-exercises/betting_pilot.obs: -------------------------------------------------------------------------------- 1 | import "resources/sample_programs/pilot2/betting_utils.obs" 2 | import "resources/sample_programs/pilot2/games.obs" 3 | 4 | 5 | main asset contract Casino { 6 | 7 | Money@Owned money; 8 | GameRecordList@Shared gamerecords; 9 | 10 | Casino@Owned() { 11 | money = new Money(100000); 12 | gamerecords = new GameRecordList(); 13 | } 14 | //TODO: Add your code here. 15 | 16 | 17 | } -------------------------------------------------------------------------------- /papers/yul_evm_writeup/conclusion.tex: -------------------------------------------------------------------------------- 1 | Obsidian offers significant promise to make programming easier and safer on the Ethereum platform. Gas costs are comparable for simple transactions, and although memory allocation can be expensive, it is orders of magnitude cheaper than allocating fresh contracts, and both easier and safer than having programmers allocate memory manually. We look forward to working together in the future to make Obsidian practical for Ethereum developers. -------------------------------------------------------------------------------- /resources/tests/GanacheTests/SetGetNoArgsNoConstructNoInit.obs: -------------------------------------------------------------------------------- 1 | contract IntContainer{ 2 | int x; 3 | 4 | transaction set() { 5 | x = 5; 6 | } 7 | 8 | transaction get() returns int{ 9 | return x; 10 | } 11 | } 12 | 13 | main contract SetGetNoArgsNoConstructNoInit{ 14 | transaction main() returns int{ 15 | IntContainer ic = new IntContainer(); 16 | ic.set(); 17 | return ic.get(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /user_guide/source/tutorial/states-assets.rst: -------------------------------------------------------------------------------- 1 | States and Assets 2 | ------------------ 3 | 4 | States can also be declared as ``asset`` s, which means the contract is an asset (see :doc:`assets`) only when in that state. 5 | For example, see an alternate definition of ``Wallet`` below, in which a ``Wallet`` is an ``asset`` only 6 | when it is ``Full``. 7 | 8 | :: 9 | 10 | contract Wallet { 11 | asset state Full; 12 | state Empty; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /src/main/scala/edu/cmu/cs/obsidian/lexer/TokenReader.scala: -------------------------------------------------------------------------------- 1 | package edu.cmu.cs.obsidian.lexer 2 | 3 | import scala.util.parsing.input._ 4 | 5 | class TokenReader(tokens : Seq[Token]) extends Reader[Token] { 6 | override def atEnd : Boolean = tokens.isEmpty 7 | override def pos: Position = if (atEnd) NoPosition else first.pos 8 | 9 | override def first : Token = tokens.head 10 | override def rest : Reader[Token] = new TokenReader(tokens.tail) 11 | } 12 | -------------------------------------------------------------------------------- /travis_specific/fabric_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ./travis_specific/install-protobuf.sh 4 | curl -sSL http://bit.ly/2ysbOFE | bash -s 1.4.1 -s 5 | mv bin/* $HOME/bin/ 6 | export PATH=${PATH}:${HOME}/protobuf/ 7 | export PATH=${PATH}:${HOME}/bin/ 8 | 9 | sbt ++$TRAVIS_SCALA_VERSION assembly 10 | 11 | # Fabric tests 12 | cd resources/tests/FabricTests || exit 1 13 | 14 | bash IntContainerTest.sh 15 | bash MultipleConstructorsTest.sh 16 | bash TransactionInConstructorTest.sh 17 | -------------------------------------------------------------------------------- /bin/skipped_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # when run from the top level of the repo, this prints out the names of the obsidian files 4 | # in the ganache tests that do not also have a json file paired with them -- that means that 5 | # they won't be run by travis. this also appears in the output of the travis script at the very top. 6 | comm -13 <(ls resources/tests/GanacheTests/*.json | xargs basename -s '.json' | sort) <(ls resources/tests/GanacheTests/*.obs | xargs basename -s '.obs' | sort) 7 | -------------------------------------------------------------------------------- /evaluation/pilot7/betting-exercises/betting.obs: -------------------------------------------------------------------------------- 1 | import "betting_utils.obs" 2 | 3 | main asset contract Casino { 4 | Money@Owned money; 5 | Game@Owned currentGame; //The game that is currently being played 6 | BetList@Shared bets; //The bets for the current game being played 7 | 8 | Casino@Owned() { 9 | money = new Money(100000); 10 | currentGame = new Game(); 11 | bets = new BetList(); 12 | } 13 | 14 | //TODO: Add your code here. 15 | } -------------------------------------------------------------------------------- /obs-vscode-extension/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // See https://go.microsoft.com/fwlink/?LinkId=733558 2 | // for the documentation about the tasks.json format 3 | { 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "type": "npm", 8 | "script": "watch", 9 | "problemMatcher": "$tsc-watch", 10 | "isBackground": true, 11 | "presentation": { 12 | "reveal": "never" 13 | }, 14 | "group": { 15 | "kind": "build", 16 | "isDefault": true 17 | } 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /resources/tests/GanacheTests/IfThenElse.obs: -------------------------------------------------------------------------------- 1 | main contract IfThenElse { 2 | transaction ifthenelse() { 3 | int x; 4 | if (true) { 5 | x = 1; 6 | } else { 7 | x = 0; 8 | } 9 | return; 10 | } 11 | 12 | transaction main() returns int { 13 | int x = 9; 14 | if (false) { 15 | x = 50; 16 | } else { 17 | x = 90; 18 | } 19 | return x; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/SetGetRefCountDecrNoRelease.obs: -------------------------------------------------------------------------------- 1 | contract IntContainer{ 2 | int x; 3 | 4 | transaction set(int value) { 5 | x = value; 6 | } 7 | transaction get() returns int{ 8 | return x; 9 | } 10 | } 11 | 12 | main contract SetGetRefCountDecrNoRelease{ 13 | transaction main() returns int{ 14 | IntContainer ic1 = new IntContainer(); 15 | ic1.set(5); 16 | int r = ic1.get(); 17 | return r; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/MaybeDroppedAsset.obs: -------------------------------------------------------------------------------- 1 | asset contract Money {} 2 | 3 | main asset contract Wallet { 4 | Wallet@Owned() { 5 | ->Empty; 6 | } 7 | 8 | state Full { 9 | Money@Owned m; 10 | } 11 | 12 | state Empty { 13 | } 14 | 15 | transaction loseMoney(Wallet@Full >> Empty this) { 16 | // Error -- maybe losing Money! 17 | ->Empty; 18 | } 19 | 20 | transaction loseMoney(Money@Owned >> Unowned n) { 21 | disown n; 22 | } 23 | } -------------------------------------------------------------------------------- /resources/demos/ERC20/Integer.obs: -------------------------------------------------------------------------------- 1 | import "Comparator.obs" 2 | 3 | main contract Integer { 4 | int value; 5 | 6 | Integer@Owned(int _value) { 7 | value = _value; 8 | } 9 | 10 | transaction getValue() returns int { 11 | return value; 12 | } 13 | } 14 | 15 | 16 | contract IntegerComparator implements Comparator[Integer] { 17 | transaction equals(Integer@Unowned a, Integer@Unowned b) returns bool { 18 | return a.getValue() == b.getValue(); 19 | } 20 | } -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/GenericsIntStringMismatch.obs: -------------------------------------------------------------------------------- 1 | contract A[T] { 2 | T@Unowned x; 3 | 4 | A@Owned(T@Unowned x) { 5 | this.x = x; 6 | } 7 | 8 | transaction f() returns T@Unowned { 9 | return x; 10 | } 11 | } 12 | 13 | main contract C { 14 | transaction f() returns string { 15 | A[int] a = new A[int](1); 16 | 17 | // This should be an error, because a.f() : int, not string 18 | return a.f(); 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/CheckFields.obs: -------------------------------------------------------------------------------- 1 | // ensures that fields are checked appropriately 2 | 3 | contract C1 { 4 | C1@S(){ 5 | ->S; 6 | } 7 | state S {} 8 | } 9 | 10 | asset contract C2 { 11 | C2@S(){ 12 | ->S; 13 | } 14 | state S {} 15 | } 16 | 17 | main asset contract C { 18 | // okay 19 | 20 | C2@S f3; 21 | 22 | C1@Shared f5; 23 | C1@Unowned f6; 24 | C2@Shared f7; 25 | C2@Unowned f8; 26 | int f9; 27 | string f10; 28 | bool f11; 29 | } 30 | -------------------------------------------------------------------------------- /resources/case_studies/Insurance/solidity/insurancebid.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.0; 2 | import "./money.sol"; 3 | 4 | 5 | contract InsuranceBid { 6 | uint public expirationTime; 7 | uint public cost; 8 | Money public payout; 9 | address public insurer; 10 | 11 | constructor (uint _expirationTime, uint _cost, Money _payout) public { 12 | insurer = msg.sender; 13 | expirationTime = _expirationTime; 14 | cost = _cost; 15 | payout = _payout; 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /resources/tests/GanacheTests/SetGetConstructorNoArgsNoSet.obs: -------------------------------------------------------------------------------- 1 | contract IntContainer{ 2 | int x; 3 | 4 | IntContainer@Owned() { 5 | x = 0; 6 | } 7 | 8 | transaction set(int value) { 9 | x = value; 10 | } 11 | transaction get() returns int{ 12 | return x; 13 | } 14 | } 15 | 16 | main contract SetGetConstructorNoArgsNoSet{ 17 | transaction main() returns int{ 18 | IntContainer ic = new IntContainer(); 19 | return (ic.get()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/Uninitialized.obs: -------------------------------------------------------------------------------- 1 | main contract Uninitialized { 2 | int x; 3 | int y; 4 | int z; 5 | int a; 6 | 7 | Uninitialized@Owned() { 8 | // ERROR: failed to initialize field "x". 9 | // ERROR: failed to initialize field "z". 10 | y = 3; 11 | if (true) { 12 | z = 4; 13 | } 14 | 15 | if (true) { 16 | a = 5; 17 | } 18 | else { 19 | revert; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /evaluation/pilot4/betting-exercises/Betting_R4.obs: -------------------------------------------------------------------------------- 1 | import "resources/sample_programs/betting_utils.obs" 2 | 3 | main asset contract Casino { 4 | 5 | Money@Owned money; 6 | Game@Owned currentGame; //The game that is currently being played 7 | BetList@Shared bets; //The bets for the current game being played 8 | 9 | Casino@Owned() { 10 | money = new Money(100000); 11 | currentGame = new Game(); 12 | bets = new BetList(); 13 | } 14 | 15 | //TODO: Add your code here. 16 | } -------------------------------------------------------------------------------- /evaluation/pilot4/betting-exercises/betting_pilot.obs: -------------------------------------------------------------------------------- 1 | import "resources/sample_programs/betting_utils.obs" 2 | 3 | main asset contract Casino { 4 | 5 | Money@Owned money; 6 | Game@Owned currentGame; //The game that is currently being played 7 | BetList@Shared bets; //The bets for the current game being played 8 | 9 | Casino@Owned() { 10 | money = new Money(100000); 11 | currentGame = new Game(); 12 | bets = new BetList(); 13 | } 14 | 15 | //TODO: Add your code here. 16 | } -------------------------------------------------------------------------------- /evaluation/pilot5/betting-exercises/betting_pilot.obs: -------------------------------------------------------------------------------- 1 | import "resources/sample_programs/betting_utils.obs" 2 | 3 | main asset contract Casino { 4 | 5 | Money@Owned money; 6 | Game@Owned currentGame; //The game that is currently being played 7 | BetList@Shared bets; //The bets for the current game being played 8 | 9 | Casino@Owned() { 10 | money = new Money(100000); 11 | currentGame = new Game(); 12 | bets = new BetList(); 13 | } 14 | 15 | //TODO: Add your code here. 16 | } -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/SimplePDT.obs: -------------------------------------------------------------------------------- 1 | contract C { 2 | contract T { 3 | state S1 {} 4 | state S2 {} 5 | } 6 | 7 | // should fail but not important for test: unused ownership 8 | transaction t1(this.T b) { 9 | return; 10 | } 11 | 12 | transaction t2() returns this.T { 13 | return new T(); 14 | } 15 | } 16 | 17 | main contract UsesC { 18 | const C f; 19 | 20 | transaction t() { 21 | this.f.T x = f.t2(); 22 | f.t1(x); 23 | } 24 | } -------------------------------------------------------------------------------- /resources/tests/GanacheTests/ICGeneratedCons.obs: -------------------------------------------------------------------------------- 1 | contract TwoIntContainer{ 2 | int x; 3 | int a; 4 | 5 | transaction set(int value) { 6 | x = value; 7 | a = value*value; 8 | } 9 | 10 | transaction get() returns int{ 11 | return x+a; 12 | } 13 | } 14 | 15 | main contract ICGeneratedCons{ 16 | int f; 17 | TwoIntContainer@Owned ic1; 18 | TwoIntContainer@Owned ic2; 19 | int x; 20 | 21 | transaction main() returns int{ 22 | return (10); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/MultiLineIfRet.obs: -------------------------------------------------------------------------------- 1 | main contract MultiLineIfRet { 2 | transaction val() returns int { 3 | int x = 0; 4 | if ( true && ! false ) { 5 | x = 4+20; 6 | x = 11; 7 | return 4 + x; 8 | } else { 9 | x = 13; 10 | x = 90; 11 | return 13; 12 | } 13 | } 14 | transaction main() returns int{ 15 | int x; 16 | x = 9 + 0; 17 | x = val(); 18 | return x; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/SetGetConstructorNoArgs.obs: -------------------------------------------------------------------------------- 1 | contract IntContainer{ 2 | int x; 3 | 4 | IntContainer@Owned() { 5 | x = 0; 6 | } 7 | 8 | transaction set(int value) { 9 | x = value; 10 | } 11 | transaction get() returns int{ 12 | return x; 13 | } 14 | } 15 | 16 | main contract SetGetConstructorNoArgs{ 17 | transaction main() returns int{ 18 | IntContainer ic = new IntContainer(); 19 | ic.set(12); 20 | return (ic.get()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/SetGetMainArgs1.obs: -------------------------------------------------------------------------------- 1 | contract IntContainer{ 2 | int x; 3 | 4 | IntContainer@Owned(int init) { 5 | x = init; 6 | } 7 | 8 | transaction set(int value) { 9 | x = value; 10 | } 11 | transaction get() returns int{ 12 | return x; 13 | } 14 | } 15 | 16 | main contract SetGetMainArgs1{ 17 | transaction main(int fromclient) returns int{ 18 | IntContainer ic = new IntContainer(fromclient); 19 | return (ic.get() + 2); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Obsidian_Runtime/src/main/java/Runtime/edu/cmu/cs/obsidian/chaincode/BadArgumentException.java: -------------------------------------------------------------------------------- 1 | package edu.cmu.cs.obsidian.chaincode; 2 | 3 | /** 4 | * Created by mcoblenz on 3/19/19. 5 | */ 6 | public class BadArgumentException extends Exception { 7 | private String badArgument; 8 | 9 | public BadArgumentException(String badArgument) { 10 | this.badArgument = badArgument; 11 | } 12 | 13 | public String toString() { 14 | return "Failed to parse argument: '" + badArgument + "'."; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /bin/run_obs_yul_all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | # this is a wrapper on the run_obs_yul script, which produces yul for the ganache tests programs 5 | # without actually running them, that runs it on all of the test programs in a batch mode. it is 6 | # kind of a hack but it works for now and saves a rewrite of the run_obs_yul script. 7 | 8 | for f in $(run_obs_yul.sh | tail -n +2) 9 | do 10 | echo "---------------------------" 11 | echo $f 12 | echo "---------------------------" 13 | run_obs_yul.sh "$f" 14 | done 15 | -------------------------------------------------------------------------------- /resources/tests/compilerTests/StateTransactions.obs: -------------------------------------------------------------------------------- 1 | // testing whether transactions available only in certain states are generated properly 2 | main contract StateTransactions { 3 | 4 | StateTransactions@S1() { 5 | ->S1; 6 | } 7 | 8 | state S1 {} 9 | state S2 {}; 10 | state S3 { 11 | int y; 12 | } 13 | 14 | 15 | transaction t(StateTransactions@(S1|S2) this) { 16 | int x = 3; 17 | } 18 | 19 | transaction inState3(StateTransactions@S3 this) { 20 | y = 4; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/SetGetConstructorArgs.obs: -------------------------------------------------------------------------------- 1 | contract IntContainer{ 2 | int x; 3 | 4 | IntContainer@Owned(int init) { 5 | x = init; 6 | } 7 | 8 | transaction set(int value) { 9 | x = value; 10 | } 11 | transaction get() returns int{ 12 | return x; 13 | } 14 | } 15 | 16 | main contract SetGetConstructorArgs{ 17 | transaction main() returns int{ 18 | IntContainer ic = new IntContainer(5); 19 | ic.set(12); 20 | return (ic.get()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Obsidian_Runtime/src/main/java/Runtime/edu/cmu/cs/obsidian/stdlib/Integer.obs: -------------------------------------------------------------------------------- 1 | import "Comparator.obs" 2 | 3 | main contract Integer { 4 | int value; 5 | 6 | Integer@Owned(int _value) { 7 | value = _value; 8 | } 9 | 10 | transaction getValue() returns int { 11 | return value; 12 | } 13 | } 14 | 15 | 16 | contract IntegerComparator implements Comparator[Integer] { 17 | transaction equals(Integer@Unowned a, Integer@Unowned b) returns bool { 18 | return a.getValue() == b.getValue(); 19 | } 20 | } -------------------------------------------------------------------------------- /bin/obsidianc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | bin_dir="$(cd "$(dirname $BASH_SOURCE)"; pwd)" 4 | root_dir="$bin_dir/.." 5 | export OBSIDIAN_COMPILER_DIR="$root_dir" 6 | 7 | obsidian_jar="$(find "$root_dir/target" -name "obsidianc.jar" | head -n1)" 8 | 9 | if [[ -z "$obsidian_jar" ]]; then 10 | ( 11 | cd "$root_dir" 12 | sbt assembly 13 | ) 14 | 15 | if [[ "$?" != "0" ]]; then 16 | echo "Error building jar file, exiting." 17 | exit 1 18 | fi 19 | fi 20 | 21 | java -jar "$obsidian_jar" $@ 22 | 23 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/SetGetMainArgs3.obs: -------------------------------------------------------------------------------- 1 | contract IntContainer{ 2 | int x; 3 | 4 | IntContainer@Owned(int init) { 5 | x = init; 6 | } 7 | 8 | transaction set(int value) { 9 | x = value; 10 | } 11 | transaction get() returns int{ 12 | return x; 13 | } 14 | } 15 | 16 | main contract SetGetMainArgs3{ 17 | transaction main(int fc1, int fc2, int fc3) returns int{ 18 | IntContainer ic = new IntContainer(fc1 + fc2 + fc3); 19 | return (ic.get() + 2); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/SetGetNoArgsNoConstruct.obs: -------------------------------------------------------------------------------- 1 | contract IntContainer{ 2 | int x; 3 | 4 | transaction set1() { 5 | x = 5; 6 | } 7 | 8 | transaction set2() { 9 | x = 10; 10 | } 11 | 12 | transaction get() returns int{ 13 | return x; 14 | } 15 | } 16 | 17 | main contract SetGetNoArgsNoConstruct{ 18 | transaction main() returns int{ 19 | IntContainer ic = new IntContainer(); 20 | ic.set1(); 21 | ic.set2(); 22 | return (ic.get()); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/MultiConstrDistinguishable.obs: -------------------------------------------------------------------------------- 1 | contract B { 2 | B@Owned(C@(S1 | S2 | S3) s1c, int blah) {} 3 | B@Owned(C@S2 s2c) {} 4 | } 5 | 6 | main contract C { 7 | state S1; 8 | state S2; 9 | state S3; 10 | 11 | C@S1() { ->S1; } 12 | } 13 | 14 | contract D { 15 | D@Owned(C@(S1 | S3) s1c) {} 16 | D@Owned(C@S2 s2c) {} 17 | } 18 | 19 | contract E { 20 | E@Owned(C@Unowned s2c) {} 21 | } 22 | 23 | contract F { 24 | F@Owned(C@S1 s1c) {} 25 | F@Owned(C@S2 s2c) {} 26 | } 27 | 28 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/SetGetRefCountDecr.obs: -------------------------------------------------------------------------------- 1 | contract IntContainer{ 2 | int x; 3 | 4 | transaction set(int value) { 5 | x = value; 6 | } 7 | transaction get() returns int{ 8 | return x; 9 | } 10 | } 11 | 12 | main contract SetGetRefCountDecr{ 13 | transaction main() returns int{ 14 | IntContainer ic1 = new IntContainer(); 15 | ic1.set(5); 16 | int r = ic1.get(); 17 | ic1.release(); // should see that ic1 actually gets freed 18 | return r; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Obsidian_Runtime/src/main/yul_templates/function.mustache: -------------------------------------------------------------------------------- 1 | {{! This is a template used by mustache to generate the final string of yul code. The 2 | structures of these templates are referenced from github repo 3 | ethereum/solidity/libsolidity/codegen/ir/IRGenerator.cpp 4 | (https://github.com/ethereum/solidity/blob/develop/libsolidity/codegen/ir/IRGenerator.cpp) }} 5 | 6 | function {{functionName}}({{arg0}}{{#params}}, {{name}}{{/params}}){{#hasRetVal}} -> {{retParams}}{{/hasRetVal}} { 7 | {{#body}} 8 | {{code}} 9 | {{/body}} 10 | } 11 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/GenericsOwnership.obs: -------------------------------------------------------------------------------- 1 | contract A[T] { 2 | T@Owned x; 3 | 4 | A@Owned(T@Owned >> Unowned x) { 5 | this.x = x; 6 | } 7 | 8 | transaction f() returns T@Unowned { 9 | return x; 10 | } 11 | 12 | transaction g() returns T@Owned { 13 | // This one should fail, because field types will no longer be consistent 14 | return x; 15 | } 16 | } 17 | 18 | main contract C { 19 | transaction f() returns A[C]@Owned { 20 | return new A[C](new C()); 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/StringConcat.obs: -------------------------------------------------------------------------------- 1 | main contract StringConcat { 2 | transaction mkString() returns string { 3 | return "Hello world"; 4 | } 5 | 6 | transaction foo(string x, string y) returns string { return x + y; } 7 | transaction bar() returns string { 8 | return foo(mkString(), mkString() + mkString()); 9 | } 10 | 11 | transaction local_vars() { 12 | string x = "Hello "; 13 | string y = "world"; 14 | 15 | string z = x + y; 16 | string w = x + mkString(); 17 | } 18 | } -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/MultiConstrAmbiguous.obs: -------------------------------------------------------------------------------- 1 | contract B { 2 | B@Owned(C@(S1 | S2 | S3) s1c) {} 3 | B@Owned(C@S2 s2c) {} 4 | } 5 | 6 | main contract C { 7 | state S1; 8 | state S2; 9 | state S3; 10 | 11 | C@S1() { ->S1; } 12 | } 13 | 14 | contract D { 15 | D@Owned(C@Owned s1c) {} 16 | D@Owned(C@S2 s2c) {} 17 | } 18 | 19 | contract E { 20 | E@Owned(C@(S1 | S2 | S3) s1c) {} 21 | E@Owned(C@Unowned s2c) {} 22 | } 23 | 24 | contract F { 25 | F@Owned(C@Owned s1c) {} 26 | F@Owned(C@Shared s2c) {} 27 | } 28 | 29 | -------------------------------------------------------------------------------- /resources/case_studies/Insurance/Bank.obs: -------------------------------------------------------------------------------- 1 | import "Money.obs" 2 | 3 | main asset contract Bank { 4 | Money@Owned mon; 5 | // the bank's private key for making tokens 6 | int key; 7 | 8 | Bank@Owned() { 9 | // TODO: generate key 10 | mon = new Money(1000000); 11 | key = 35; 12 | } 13 | 14 | transaction withdrawMoney(int amount) returns Money@Owned{ 15 | return mon.getAmountOfMoney(amount); 16 | } 17 | 18 | transaction depositMoney(Money@Owned >> Unowned m) { 19 | mon.addMoney(m); 20 | } 21 | 22 | } 23 | 24 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/ArgumentShadowing.obs: -------------------------------------------------------------------------------- 1 | main contract C { 2 | 3 | C@S() { ->S(x=0, y=0); } 4 | 5 | state S { 6 | int x; 7 | int y; 8 | } 9 | 10 | transaction t(C@Owned >> S this, C@Unowned x) { 11 | ->S(x = 3, y = 4); 12 | } 13 | 14 | transaction t2(A@Owned >> Unowned a) { 15 | if (this in S) { 16 | if (true) { 17 | A a = new A(); // shadow parameter a 18 | } 19 | } 20 | disown a; 21 | } 22 | 23 | } 24 | 25 | asset contract A { 26 | A@Owned() {} 27 | } -------------------------------------------------------------------------------- /resources/case_studies/Insurance/Signature.obs: -------------------------------------------------------------------------------- 1 | import "WeatherRecord.obs" 2 | 3 | contract Signature { 4 | string signature; // If we had arrays of bytes, we'd use those, but we don't. 5 | 6 | // Constructor makes a Signature object that corresponds to a particular object. 7 | Signature@Owned (WeatherRecord c) { 8 | signature = ""; // TODO 9 | } 10 | 11 | // verify takes a contract and returns true iff the receiver is a signature of that contract. 12 | transaction verify(Signature@Unowned this, WeatherRecord c) returns bool { 13 | return true; // TODO 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /Obsidian_Runtime/src/main/java/Runtime/edu/cmu/cs/obsidian/client/ChaincodeClientTransactionFailedException.java: -------------------------------------------------------------------------------- 1 | package edu.cmu.cs.obsidian.client; 2 | 3 | /** 4 | * Created by mcoblenz on 4/4/17. 5 | * 6 | * Represents transaction failure. 7 | * 8 | */ 9 | public class ChaincodeClientTransactionFailedException extends Exception { 10 | protected final String error; 11 | 12 | public ChaincodeClientTransactionFailedException(String e) { 13 | error = e; 14 | } 15 | 16 | public String toString() { 17 | return "An exception occurred: " + error; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /resources/tests/PrimitiveTypes.obs: -------------------------------------------------------------------------------- 1 | main contract PrimitiveTypes { 2 | string s; 3 | int n; 4 | bool b; 5 | 6 | transaction setString (string newString) returns string { 7 | string oldString = s; 8 | s = newString; 9 | return oldString; 10 | } 11 | 12 | transaction setBool (bool newBool) returns bool { 13 | bool oldBool = b; 14 | b = newBool; 15 | return oldBool; 16 | } 17 | 18 | transaction setInt (int newInt) returns int { 19 | int oldInt = n; 20 | n = newInt; 21 | return oldInt; 22 | } 23 | } -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/BasicGenerics.obs: -------------------------------------------------------------------------------- 1 | contract A[T] { 2 | T@Unowned x; 3 | 4 | A@Owned(T@Unowned x) { 5 | this.x = x; 6 | } 7 | 8 | transaction f() returns T@Unowned { 9 | return x; 10 | } 11 | } 12 | 13 | main contract C { 14 | transaction f() returns A[int]@Owned { 15 | return new A[int](1); 16 | } 17 | 18 | transaction g() returns int { 19 | return new A[int](1).f(); 20 | } 21 | 22 | transaction h() returns A[int]@Unowned { 23 | return new A[A[int]](new A[int](1)).f(); 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /evaluation/pilot7/tutorial-exercises/code2.obs: -------------------------------------------------------------------------------- 1 | 2 | //Fill in the code in the /* TODO */ below 3 | //Note: s is a Share owned by another ShareHolder that is passed as a parameter to the receiveShare transaction, and will be set to the field "share" 4 | 5 | contract Share { 6 | 7 | } 8 | 9 | main contract ShareHolder { 10 | Share@Owned share; 11 | 12 | ShareHolder@Owned() { 13 | share = new Share(); 14 | } 15 | 16 | transaction receiveShare(Share@Owned s) { 17 | 18 | } 19 | 20 | transaction checkShareValue(Share@Owned s) { 21 | //... 22 | } 23 | } -------------------------------------------------------------------------------- /travis_specific/README.MD: -------------------------------------------------------------------------------- 1 | # Framework of integration tests 2 | 1. Go to resources/tests/endToEndTests and create a new bash script 3 | 2. In order to generate java code that will be deployed on hyperledger, 4 | you must run sbt to generate it. To generate it in the Obsidian root directory, 5 | first cd to this directory and do 6 | ` 7 | sbt "runMain edu.cmu.cs.obsidian.Main [path to obs code]" 8 | ` 9 | 3. Next step is to cd to network-framework and write the actual test code 10 | 4. Always bring down the container and remove the generated java code keep 11 | make sure this test is standalone and portable -------------------------------------------------------------------------------- /evaluation/pilot3/tutorial-exercises/code2.obs: -------------------------------------------------------------------------------- 1 | 2 | //Fill in the code in the /* TODO */ below 3 | //Note: s is a Share owned by another ShareHolder that is passed as a parameter to the receiveShare transaction, and will be set to the field "share" 4 | 5 | contract Share { 6 | 7 | } 8 | 9 | main contract ShareHolder { 10 | Share@Owned share; 11 | 12 | ShareHolder@Owned() { 13 | share = new Share(); 14 | } 15 | 16 | transaction receiveShare( /* TODO */ s) { 17 | //... 18 | } 19 | 20 | transaction checkShareValue(Share@Owned s) { 21 | //... 22 | } 23 | } -------------------------------------------------------------------------------- /evaluation/pilot4/tutorial-exercises/code2.obs: -------------------------------------------------------------------------------- 1 | 2 | //Fill in the code in the /* TODO */ below 3 | //Note: s is a Share owned by another ShareHolder that is passed as a parameter to the receiveShare transaction, and will be set to the field "share" 4 | 5 | contract Share { 6 | 7 | } 8 | 9 | main contract ShareHolder { 10 | Share@Owned share; 11 | 12 | ShareHolder@Owned() { 13 | share = new Share(); 14 | } 15 | 16 | transaction receiveShare(Share@Owned s) { 17 | //... 18 | } 19 | 20 | transaction checkShareValue(Share@Owned s) { 21 | //... 22 | } 23 | } -------------------------------------------------------------------------------- /evaluation/pilot8/tutorial-exercises/code2.obs: -------------------------------------------------------------------------------- 1 | 2 | //Fill in the code in the /* TODO */ below 3 | //Note: s is a Share owned by another ShareHolder that is passed as a parameter to the receiveShare transaction, and will be set to the field "share" 4 | 5 | contract Share { 6 | 7 | } 8 | 9 | main contract ShareHolder { 10 | Share@Owned share; 11 | 12 | ShareHolder@Owned() { 13 | share = new Share(); 14 | } 15 | 16 | transaction receiveShare(Share@Owned s) { 17 | //... 18 | } 19 | 20 | transaction checkShareValue(Share@Owned s) { 21 | //... 22 | } 23 | } -------------------------------------------------------------------------------- /resources/tests/GanacheTests/SG.obs: -------------------------------------------------------------------------------- 1 | contract IntContainer{ 2 | int x; 3 | int y; 4 | int z; 5 | int f; 6 | 7 | transaction set() { 8 | x = -1; 9 | f = -1; 10 | z = -1; 11 | y = -1; 12 | x = 5; 13 | y = 10; 14 | z = 4; 15 | f = 9; 16 | } 17 | 18 | transaction get() returns int{ 19 | return x*y*z*f; // 1800 20 | } 21 | } 22 | 23 | main contract SG{ 24 | transaction main() returns int{ 25 | IntContainer ic = new IntContainer(); 26 | ic.set(); 27 | return ic.get(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /resources/tests/compilerTests/PrimitiveTypes.obs: -------------------------------------------------------------------------------- 1 | main contract PrimitiveTypes { 2 | string s; 3 | int n; 4 | bool b; 5 | 6 | transaction setString (string newString) returns string { 7 | string oldString = s; 8 | s = newString; 9 | return oldString; 10 | } 11 | 12 | transaction setBool (bool newBool) returns bool { 13 | bool oldBool = b; 14 | b = newBool; 15 | return oldBool; 16 | } 17 | 18 | transaction setInt (int newInt) returns int { 19 | int oldInt = n; 20 | n = newInt; 21 | return oldInt; 22 | } 23 | } -------------------------------------------------------------------------------- /evaluation/pilot3/tutorial-exercises/code2_R3.obs: -------------------------------------------------------------------------------- 1 | 2 | //Fill in the code in the /* TODO */ below 3 | //Note: s is a Share owned by another ShareHolder that is passed as a parameter to the receiveShare transaction, and will be set to the field "share" 4 | 5 | contract Share { 6 | 7 | } 8 | 9 | main contract ShareHolder { 10 | Share@Owned share; 11 | 12 | ShareHolder@Owned() { 13 | share = new Share(); 14 | } 15 | 16 | transaction receiveShare(Share@Owned >> Unowned s) { 17 | //... 18 | } 19 | 20 | transaction checkShareValue(Share@Owned s) { 21 | //... 22 | } 23 | } -------------------------------------------------------------------------------- /evaluation/pilot6/tutorial-exercises/code2.obs: -------------------------------------------------------------------------------- 1 | 2 | //Fill in the code in the /* TODO */ below 3 | //Note: s is a Share owned by another ShareHolder that is passed as a parameter to the receiveShare transaction, and will be set to the field "share" 4 | 5 | contract Share { 6 | 7 | } 8 | 9 | main contract ShareHolder { 10 | Share@Owned share; 11 | 12 | ShareHolder@Owned() { 13 | share = new Share(); 14 | } 15 | 16 | transaction receiveShare(Share@Owned >> Unowned s) { 17 | //... 18 | } 19 | 20 | transaction checkShareValue(Share@Owned s) { 21 | //... 22 | } 23 | } -------------------------------------------------------------------------------- /resources/tests/endToEndTests/BasicGenericsTests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cd ../../../ 4 | # Generate java code 5 | sbt "runMain edu.cmu.cs.obsidian.Main resources/tests/compilerTests/BasicGenerics.obs" 6 | # Then go to run the tests 7 | cd network-framework 8 | ./down.sh 9 | ./up.sh -s ../BasicGenerics 10 | 11 | check() { 12 | echo "$1" 13 | res="$($1)" 14 | 15 | if [[ "$res" != "$2" ]]; then 16 | echo "Expected '$2' from '$1' but got '$res'" 17 | exit 1 18 | fi 19 | } 20 | 21 | check "./invoke.sh -q g" "2" 22 | 23 | ./down.sh 24 | cd ../ 25 | rm -rf BasicGenerics 26 | 27 | -------------------------------------------------------------------------------- /Obsidian_Runtime/src/main/java/Runtime/edu/cmu/cs/obsidian/chaincode/ObsidianChaincodeException.java: -------------------------------------------------------------------------------- 1 | package edu.cmu.cs.obsidian.chaincode; 2 | 3 | /** 4 | * Created by Miles Baker on 7/3/18. 5 | */ 6 | public class ObsidianChaincodeException extends Exception { 7 | protected final String filename; 8 | protected final int line; 9 | 10 | public ObsidianChaincodeException(String f, int l) { 11 | filename = f; 12 | line = l; 13 | } 14 | 15 | public String toString() { 16 | return filename + ":" + line + ": Exception " + getClass().getName() + " occurred."; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Obsidian_Runtime/src/main/java/Runtime/edu/cmu/cs/obsidian/chaincode/ReturnedReferenceState.java: -------------------------------------------------------------------------------- 1 | package edu.cmu.cs.obsidian.chaincode; 2 | 3 | 4 | public class ReturnedReferenceState { 5 | final Class aClass; 6 | final boolean isOwnedReference; 7 | 8 | public ReturnedReferenceState(Class aClass, boolean isOwnedReference) { 9 | this.aClass = aClass; 10 | this.isOwnedReference = isOwnedReference; 11 | } 12 | 13 | public Class getClassRef() { 14 | return aClass; 15 | } 16 | 17 | public boolean getIsOwnedReference() { 18 | return isOwnedReference; 19 | } 20 | } -------------------------------------------------------------------------------- /evaluation/pilot5/tutorial-exercises/code2.obs: -------------------------------------------------------------------------------- 1 | 2 | //Fill in the code in the /* TODO */ below 3 | //Note: s is a Share owned by another ShareHolder that is passed as a parameter to the 4 | //receiveShare transaction, and will be set to the field "share" 5 | 6 | contract Share { 7 | 8 | } 9 | 10 | main contract ShareHolder { 11 | Share@Owned share; 12 | 13 | ShareHolder@Owned() { 14 | share = new Share(); 15 | } 16 | 17 | transaction receiveShare(Share@Owned >> Unowned s) { 18 | //... 19 | } 20 | 21 | transaction checkShareValue(Share@Owned s) { 22 | //... 23 | } 24 | } -------------------------------------------------------------------------------- /evaluation/solidity_participant_template/tutorial-exercises/code5.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.5.11; 2 | 3 | //A Drink can be hot, cold, or lukewarm. If the Drink is cold, it has an IceCube object. If it is hot, it has a CupSleeve. 4 | //The Drink always has an integer value to keep track of its temperature. 5 | //A Drink always starts out lukewarm. 6 | 7 | //Write the Drink contract below with the necessary states and fields for the situation described above. 8 | //The contracts for IceCube and CupSleeve are given below. 9 | 10 | 11 | contract IceCube { 12 | //... 13 | } 14 | 15 | contract CupSleeve { 16 | //... 17 | } -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/SimpleComparisons.obs: -------------------------------------------------------------------------------- 1 | // checks primitive comparison operators 2 | 3 | main contract Comparisons { 4 | 5 | transaction doComparisons() { 6 | bool a = 3 < 4; 7 | // should fail: bool is not int 8 | a = 2 < true; 9 | // should fail: bool is not int 10 | bool b = true > 6; 11 | // should fail: string is not int 12 | bool c = "hi" <= 7; 13 | // should fail: string is not int 14 | bool d = 8 >= "aaaa"; 15 | // should fail twice (2 errors): bool is not int 16 | bool e = true > false; 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /Obsidian_Runtime/src/main/java/Runtime/edu/cmu/cs/obsidian/chaincode/StateLockException.java: -------------------------------------------------------------------------------- 1 | // This exception occurs when a program attempts to transition a statelocked object via a Shared reference. 2 | 3 | package edu.cmu.cs.obsidian.chaincode; 4 | 5 | public class StateLockException extends ObsidianChaincodeException { 6 | 7 | public StateLockException(String f, int l) { 8 | super (f, l); 9 | } 10 | 11 | @Override 12 | public String getMessage() { 13 | return "[" + filename + ": " + line + "]: Cannot transition object while it is being used in a dynamic state test."; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /evaluation/obsidian_participant_template/tutorial-exercises/code2.obs: -------------------------------------------------------------------------------- 1 | 2 | //Fill in the code in the /* TODO */ below 3 | //Note: s is a Share owned by another ShareHolder that is passed as a parameter to the receiveShare transaction, and will be set to the field "share" 4 | 5 | contract Share { 6 | 7 | } 8 | 9 | main contract ShareHolder { 10 | Share@Owned share; 11 | 12 | ShareHolder@Owned() { 13 | share = new Share(); 14 | } 15 | 16 | transaction receiveShare( /* TODO */ s) { 17 | //... 18 | } 19 | 20 | transaction checkShareValue(Share@Owned s) { 21 | //... 22 | } 23 | } -------------------------------------------------------------------------------- /resources/tests/GanacheTests/CombinedBasicsRet.obs: -------------------------------------------------------------------------------- 1 | /* this test shows the same amount of compositionality of the simple 2 | * language features as CombinedBasics, but also with multiple exit points 3 | * from different branches of an if-then-else. 4 | */ 5 | 6 | main contract CombinedBasicsRet { 7 | transaction val() returns int { 8 | if ( true && ! false ) { 9 | return 4 + 20; 10 | } else { 11 | return 13; 12 | } 13 | } 14 | transaction main() returns int{ 15 | int x; 16 | x = 9 + 0; 17 | x = val(); 18 | return x; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/Equality.obs: -------------------------------------------------------------------------------- 1 | // checks "==" and "!=" operators 2 | 3 | main contract Equality { 4 | 5 | transaction checkEqual() { 6 | int a = 7; 7 | string b = ""; 8 | string str1 = "hi"; 9 | string str2 = "a"; 10 | 11 | // should fail: incompatible types 12 | bool c = (a == b); 13 | // should fail: incompatible types 14 | bool d = (true != 5); 15 | // should fail: incompatible types 16 | bool e = (1 == false); 17 | bool f = (1 != 3); 18 | bool g = (2 == 2); 19 | bool h = (str1 == str2); 20 | } 21 | } -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/Prescription.obs: -------------------------------------------------------------------------------- 1 | asset contract Prescription {} 2 | 3 | interface Pharmacy { 4 | transaction depositPrescription(Prescription @ Owned >> Unowned p); 5 | transaction removePrescription(Prescription @ Unowned p) returns Prescription @ Owned; 6 | } 7 | 8 | contract Patient { 9 | transaction fillPrescription(Pharmacy @ Unowned pharmacy, Prescription @ Unowned pre) { 10 | pharmacy.depositPrescription(pre); // Location (A) 11 | Prescription p = pharmacy.removePrescription(pre); [p @ Owned]; // Location (B) 12 | pharmacy.depositPrescription(p); [p @ Unowned]; // Location (C) 13 | } 14 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **To Reproduce** 11 | Steps to reproduce the behavior: 12 | 1. Go to '...' 13 | 2. Click on '....' 14 | 3. Scroll down to '....' 15 | 4. See error 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | 20 | **Screenshots** 21 | If applicable, add screenshots to help explain your problem. 22 | 23 | **Additional context** 24 | Add any other context about the problem here. 25 | -------------------------------------------------------------------------------- /Obsidian_Runtime/src/main/java/Runtime/edu/cmu/cs/obsidian/chaincode/IllegalOwnershipConsumptionException.java: -------------------------------------------------------------------------------- 1 | package edu.cmu.cs.obsidian.chaincode; 2 | 3 | /** 4 | * Created by mcoblenz on 3/19/19. 5 | */ 6 | public class IllegalOwnershipConsumptionException extends Exception { 7 | String guid; 8 | 9 | public IllegalOwnershipConsumptionException(String guid) { 10 | this.guid = guid; 11 | } 12 | 13 | public String toString() { 14 | return "Cannot consume ownership of object " + guid + 15 | " because that object is already owned by another reference on the blockchain."; 16 | } 17 | } -------------------------------------------------------------------------------- /evaluation/pilot3/tutorial-exercises/code5.obs: -------------------------------------------------------------------------------- 1 | 2 | //A Drink can be hot, cold, or lukewarm. If the Drink is cold, it has an IceCube object. If it is hot, it has a CupSleeve. 3 | //The Drink always has an integer value to keep track of its temperature. 4 | //A Drink always starts out lukewarm. 5 | 6 | //Write the Drink contract below with the necessary states, fields, and constructors for the situation described above. 7 | //The contracts for IceCube and CupSleeve are given below. 8 | 9 | //Note: the Drink contract MUST be main 10 | 11 | 12 | contract IceCube { 13 | //... 14 | } 15 | 16 | contract CupSleeve { 17 | //... 18 | } -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/SimpleOperations.obs: -------------------------------------------------------------------------------- 1 | // checks primitive operators (boolean and numeric) 2 | 3 | main contract Operations { 4 | 5 | transaction doOperations() { 6 | int a = 3 + 5; 7 | // should fail: adding with a boolean 8 | a = 3 + true; 9 | // should fail: adding with a string 10 | int b = "hi" * 1; 11 | // should fail: dividing with boolean 12 | int c = true/10; 13 | // should fail: bool op with string 14 | bool d = true && "false"; 15 | // should fail twice (2 errors): bool op with ints 16 | bool e = 5 || 6; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/States.obs: -------------------------------------------------------------------------------- 1 | main contract C { 2 | 3 | C@Start() { 4 | ->Start; 5 | } 6 | 7 | state Start { 8 | } 9 | 10 | transaction a(C@Start >> S1 this) { 11 | ->S1; 12 | // should fail: need to assign x 13 | ->S2; 14 | // should fail: no such state 15 | ->S3; 16 | ->S2(x = 2); 17 | // should fail: no such field x 18 | ->S1(x = 1); 19 | } 20 | 21 | transaction b(C@Start >> S1 this) { 22 | ->S1; 23 | } 24 | 25 | state S1 { 26 | 27 | } 28 | 29 | state S2 { 30 | int x; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /evaluation/obsidian_participant_template/tutorial-exercises/code5.obs: -------------------------------------------------------------------------------- 1 | 2 | //A Drink can be hot, cold, or lukewarm. If the Drink is cold, it has an IceCube object. If it is hot, it has a CupSleeve. 3 | //The Drink always has an integer value to keep track of its temperature. 4 | //A Drink always starts out lukewarm. 5 | 6 | //Write the Drink contract below with the necessary states and fields for the situation described above. 7 | //The contracts for IceCube and CupSleeve are given below. 8 | 9 | //Note: the Drink contract MUST be main 10 | 11 | 12 | contract IceCube { 13 | //... 14 | } 15 | 16 | contract CupSleeve { 17 | //... 18 | } -------------------------------------------------------------------------------- /resources/tests/GanacheTests/SetGetTwoConstructors.obs: -------------------------------------------------------------------------------- 1 | contract IntContainer{ 2 | int x; 3 | 4 | IntContainer@Owned(int init) { 5 | x = init; 6 | } 7 | 8 | IntContainer@Owned(int a, int b) { 9 | x = a + b; 10 | } 11 | 12 | transaction set(int value) { 13 | x = value; 14 | } 15 | transaction get() returns int{ 16 | return x; 17 | } 18 | } 19 | 20 | main contract SetGetTwoConstructors{ 21 | transaction main() returns int{ 22 | IntContainer ic = new IntContainer(5,5); 23 | int x = ic.get(); 24 | ic.set(x+5); 25 | return (ic.get()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /.idea/sbt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /resources/tests/FabricTests/TransactionInConstructorTest.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cd ../../../ 4 | # Generate java code 5 | sbt "runMain edu.cmu.cs.obsidian.Main resources/tests/compilerTests/TransactionInConstructor.obs" 6 | # Then go to run the tests 7 | cd network-framework 8 | ./down.sh 9 | ./up.sh -s ../TransactionInConstructor 10 | 11 | check() { 12 | echo "$1" 13 | res="$($1)" 14 | 15 | if [[ "$res" != "$2" ]]; then 16 | echo "Expected '$2' from '$1' but got '$res'" 17 | exit 1 18 | fi 19 | } 20 | 21 | check "./invoke.sh -q getY" "1" 22 | 23 | ./down.sh 24 | cd ../ 25 | rm -rf TransactionInConstructor 26 | 27 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/ParentPDT.obs: -------------------------------------------------------------------------------- 1 | // checks path-dependent types involving "parent" 2 | 3 | contract C { 4 | contract T { 5 | this.parent.T f; 6 | C x; 7 | transaction t(T arg) { 8 | T a = this; 9 | this.parent.T b = arg; 10 | this.parent.T c = this; 11 | parent.T d = arg; 12 | parent.T e = this; 13 | C f = parent; 14 | } 15 | } 16 | } 17 | 18 | main contract UsesC { 19 | transaction t() { 20 | readonlyState UsesC a = this; 21 | // should fail: no parent for UsesC 22 | UsesC b = parent; 23 | } 24 | } -------------------------------------------------------------------------------- /evaluation/pilot3/tutorial-exercises/code8.obs: -------------------------------------------------------------------------------- 1 | /* 2 | Write a contract Restaurant that has two transactions: dineIn and takeOut. 3 | You do NOT need to fill in the bodies of these transactions, only write the transaction declarations. 4 | The dineIn transaction should take in a Person as well as an integer number of people in the party as parameters. 5 | takeOut should only take in a Person parameter. Both of these transactions should ONLY be allowed when the Restaurant is open. 6 | If it is closed, neither transaction can be done. 7 | 8 | Please write your code below. The Person contract is given below. 9 | */ 10 | 11 | contract Person { 12 | //... 13 | } -------------------------------------------------------------------------------- /evaluation/pilot7/tutorial-exercises/code8.obs: -------------------------------------------------------------------------------- 1 | /* 2 | Write a contract Restaurant that has two transactions: dineIn and takeOut. 3 | You do NOT need to fill in the bodies of these transactions, only write the transaction declarations. 4 | The dineIn transaction should take in a Person as well as an integer number of people in the party as parameters. 5 | takeOut should only take in a Person parameter. Both of these transactions should ONLY be allowed when the Restaurant is open. 6 | If it is closed, neither transaction can be done. 7 | 8 | Please write your code below. The Person contract is given below. 9 | */ 10 | 11 | contract Person { 12 | //... 13 | } -------------------------------------------------------------------------------- /evaluation/pilot8/tutorial-exercises/code8.obs: -------------------------------------------------------------------------------- 1 | /* 2 | Write a contract Restaurant that has two transactions: dineIn and takeOut. 3 | You do NOT need to fill in the bodies of these transactions, only write the transaction declarations. 4 | The dineIn transaction should take in a Person as well as an integer number of people in the party as parameters. 5 | takeOut should only take in a Person parameter. Both of these transactions should ONLY be allowed when the Restaurant is open. 6 | If it is closed, neither transaction can be done. 7 | 8 | Please write your code below. The Person contract is given below. 9 | */ 10 | 11 | contract Person { 12 | //... 13 | } -------------------------------------------------------------------------------- /resources/tests/GanacheTests/CombinedBasics.obs: -------------------------------------------------------------------------------- 1 | /* this test combines the features of the other smaller tests that all come 2 | * conceptually prior to structure types into one file, showing that they 3 | * still work when they also interact. 4 | */ 5 | 6 | main contract CombinedBasics { 7 | transaction val() returns int { 8 | int x = 70; 9 | if ( true && ! false ) { 10 | x = 4 + 20; 11 | } else { 12 | x = 13; 13 | } 14 | return x; 15 | } 16 | transaction main() returns int{ 17 | int x; 18 | x = 9 + 0; 19 | x = val(); 20 | return x; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/SGTwoContainers.obs: -------------------------------------------------------------------------------- 1 | contract IntContainer{ 2 | int x; 3 | int y; 4 | int z; 5 | int f; 6 | 7 | transaction set() { 8 | x = -1; 9 | f = -1; 10 | z = -1; 11 | y = -1; 12 | x = 5; 13 | y = 10; 14 | z = 4; 15 | f = 9; 16 | } 17 | 18 | transaction get() returns int{ 19 | return x*y*z*f; // 1800 20 | } 21 | } 22 | 23 | main contract SGTwoContainers{ 24 | transaction main() returns int{ 25 | IntContainer ic1 = new IntContainer(); 26 | ic1.set(); 27 | IntContainer ic2 = new IntContainer(); 28 | ic2.set(); 29 | return ic1.get()+ic2.get(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /evaluation/pilot2/betting_help.obs: -------------------------------------------------------------------------------- 1 | import "resources/sample_programs/pilot2/betting_utils.obs" 2 | import "resources/sample_programs/pilot2/games.obs" 3 | 4 | 5 | main asset contract Casino { 6 | 7 | Money@Owned money; 8 | GameRecordList@Shared gamerecords; 9 | 10 | Casino@Owned() { 11 | money = new Money(100000); 12 | gamerecords = new GameRecordList(); 13 | } 14 | 15 | transaction makeBet(Casino@Owned this, Bettor@Unowned b, Money@Owned >> Unowned m, Player@Unowned predictedWinner, Game@Unowned g) { 16 | 17 | } 18 | 19 | transaction returnMoney(Casino@Owned this, Bettor@Unowned b, Game@Owned g) { 20 | 21 | } 22 | } -------------------------------------------------------------------------------- /user_guide/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SOURCEDIR = source 8 | BUILDDIR = build 9 | 10 | # Put it first so that "make" without argument is like "make help". 11 | help: 12 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 13 | 14 | .PHONY: help Makefile 15 | 16 | # Catch-all target: route all unknown targets to Sphinx using the new 17 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 18 | %: Makefile 19 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -------------------------------------------------------------------------------- /evaluation/pilot2/Betting_help_R2.obs: -------------------------------------------------------------------------------- 1 | import "resources/sample_programs/pilot2/betting_utils.obs" 2 | import "resources/sample_programs/pilot2/games.obs" 3 | 4 | 5 | main asset contract Casino { 6 | 7 | Money@Owned money; 8 | GameRecordList@Shared gamerecords; 9 | 10 | Casino@Owned() { 11 | money = new Money(100000); 12 | gamerecords = new GameRecordList(); 13 | } 14 | 15 | transaction makeBet(Casino@Owned this, Bettor@Unowned b, Money@Owned >> Unowned m, Player@Unowned predictedWinner, Game@Unowned g) { 16 | 17 | } 18 | 19 | transaction returnMoney(Casino@Owned this, Bettor@Unowned b, Game@Owned g) { 20 | 21 | } 22 | } -------------------------------------------------------------------------------- /resources/tests/GanacheTests/SetGetLogs.obs: -------------------------------------------------------------------------------- 1 | contract IntContainer{ 2 | int x; 3 | 4 | transaction set(int value) { 5 | x = value; 6 | } 7 | transaction get() returns int{ 8 | return x; 9 | } 10 | } 11 | 12 | main contract SetGetLogs{ 13 | IntContainer@Owned ic1; 14 | IntContainer@Owned ic2; 15 | IntContainer@Owned ic3; 16 | 17 | transaction main_sgl() returns int{ 18 | ic1 = new IntContainer(); 19 | ic2 = new IntContainer(); 20 | ic3 = new IntContainer(); 21 | ic1.set(5); 22 | ic2.set(5); 23 | ic3.set(5); 24 | return (ic1.get() + ic2.get() + ic3.get()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /solidity_user_guide/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SOURCEDIR = source 8 | BUILDDIR = build 9 | 10 | # Put it first so that "make" without argument is like "make help". 11 | help: 12 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 13 | 14 | .PHONY: help Makefile 15 | 16 | # Catch-all target: route all unknown targets to Sphinx using the new 17 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 18 | %: Makefile 19 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -------------------------------------------------------------------------------- /evaluation/obsidian_participant_template/tutorial-exercises/code8.obs: -------------------------------------------------------------------------------- 1 | /* 2 | Write a contract Restaurant that has two transactions: dineIn and takeOut. 3 | You do NOT need to fill in the bodies of these transactions, only write the transaction declarations. 4 | The dineIn transaction should take in a Person as well as an integer number of people in the party as parameters. 5 | takeOut should only take in a Person parameter. Both of these transactions should ONLY be allowed when the Restaurant is open. 6 | If it is closed, neither transaction can be done. 7 | 8 | Please write your code below. The Person contract is given below. 9 | */ 10 | 11 | contract Person { 12 | //... 13 | } -------------------------------------------------------------------------------- /evaluation/solidity_participant_template/tutorial-exercises/code2.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.5.11; 2 | 3 | //Fill in the code in the /* TODO */ below 4 | //Note: s is a Share owned by another ShareHolder that is passed as a parameter to the receiveShare transaction, and will be set to the field "share" 5 | 6 | contract Share { 7 | 8 | } 9 | 10 | contract ShareHolder { 11 | Share share; // owned 12 | 13 | constructor() public { 14 | share = new Share(); 15 | } 16 | 17 | function receiveShare(Share s) public { // TODO 18 | //... 19 | } 20 | 21 | // s is owned 22 | function checkShareValue(Share s) public { 23 | //... 24 | } 25 | } -------------------------------------------------------------------------------- /resources/tests/GanacheTests/SetGetRefCountNested.obs: -------------------------------------------------------------------------------- 1 | contract IntContainer{ 2 | int x; 3 | 4 | transaction set(int value) { 5 | x = value; 6 | } 7 | transaction get() returns int{ 8 | return x; 9 | } 10 | } 11 | 12 | contract IntContainerContainer { 13 | IntContainer@Owned ic1; 14 | 15 | IntContainerContainer@Owned(){ 16 | ic1 = new IntContainer(); 17 | } 18 | } 19 | 20 | main contract SetGetRefCountNested{ 21 | transaction main() returns int{ 22 | IntContainerContainer icc1 = new IntContainerContainer(); 23 | icc1.release(); // should see that things get cleared out 24 | return 0; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /evaluation/P41/tutorial-exercises/code8.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.5.11; 2 | 3 | /* 4 | Write a contract Restaurant that has two transactions: dineIn and takeOut. 5 | You do NOT need to fill in the bodies of these transactions, only write the transaction declarations. 6 | The dineIn transaction should take in a Person as well as an integer number of people in the party as parameters. 7 | takeOut should only take in a Person parameter. Both of these transactions should ONLY be allowed when the Restaurant is open. 8 | If it is closed, neither transaction can be done. 9 | 10 | Please write your code below. The Person contract is given below. 11 | */ 12 | 13 | contract Person { 14 | //... 15 | } -------------------------------------------------------------------------------- /evaluation/pilot3/betting-exercises/Betting_help_R3.obs: -------------------------------------------------------------------------------- 1 | import "resources/sample_programs/pilot2/betting_utils.obs" 2 | import "resources/sample_programs/pilot2/games.obs" 3 | 4 | 5 | main asset contract Casino { 6 | 7 | Money@Owned money; 8 | GameRecordList@Shared gamerecords; 9 | 10 | Casino@Owned() { 11 | money = new Money(100000); 12 | gamerecords = new GameRecordList(); 13 | } 14 | 15 | transaction makeBet(Casino@Owned this, Bettor@Unowned b, Money@Owned >> Unowned m, Player@Unowned predictedWinner, Game@Unowned g) { 16 | 17 | } 18 | 19 | transaction returnMoney(Casino@Owned this, Bettor@Unowned b, Game@Owned g) { 20 | 21 | } 22 | } -------------------------------------------------------------------------------- /evaluation/pilot3/betting-exercises/betting_help.obs: -------------------------------------------------------------------------------- 1 | import "resources/sample_programs/pilot2/betting_utils.obs" 2 | import "resources/sample_programs/pilot2/games.obs" 3 | 4 | 5 | main asset contract Casino { 6 | 7 | Money@Owned money; 8 | GameRecordList@Shared gamerecords; 9 | 10 | Casino@Owned() { 11 | money = new Money(100000); 12 | gamerecords = new GameRecordList(); 13 | } 14 | 15 | transaction makeBet(Casino@Owned this, Bettor@Unowned b, Money@Owned >> Unowned m, Player@Unowned predictedWinner, Game@Unowned g) { 16 | 17 | } 18 | 19 | transaction returnMoney(Casino@Owned this, Bettor@Unowned b, Game@Owned g) { 20 | 21 | } 22 | } -------------------------------------------------------------------------------- /resources/tests/State.obs: -------------------------------------------------------------------------------- 1 | main contract StateTest { 2 | int x; 3 | string s; 4 | bool b; 5 | 6 | StateTest() { 7 | x = 2; 8 | s = "abc"; 9 | b = true; 10 | } 11 | 12 | transaction setX(int newX) returns int { 13 | int oldX = x; 14 | x = newX; 15 | -> S1; 16 | return oldX; 17 | } 18 | 19 | state S1{ 20 | } 21 | 22 | transaction setX(int newX) returns int available in S1 { 23 | x = newX; 24 | return 5; 25 | } 26 | 27 | state S2 { 28 | } 29 | 30 | transaction f(string newS) returns string available in S2 { 31 | s = "b"; 32 | return s; 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /evaluation/P41/tutorial-exercises/code2.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.5.11; 2 | 3 | //Fill in the code in the /* TODO */ below 4 | //Note: s is a Share owned by another ShareHolder that is passed as a parameter to the receiveShare transaction, and will be set to the field "share" 5 | 6 | contract Share { 7 | 8 | } 9 | 10 | contract ShareHolder { 11 | Share share; // owned 12 | 13 | constructor() public { 14 | share = new Share(); 15 | } 16 | 17 | function receiveShare(Share s) public { // s is owned initially but must be Unowned at the end. 18 | //... 19 | } 20 | 21 | // s is owned 22 | function checkShareValue(Share s) public { 23 | //... 24 | } 25 | } -------------------------------------------------------------------------------- /resources/tests/FabricTests/MultipleConstructorsTest.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cd ../../../ 4 | # Generate java code 5 | sbt "runMain edu.cmu.cs.obsidian.Main resources/tests/compilerTests/MultipleConstructors.obs" 6 | # Then go to run the tests 7 | cd network-framework 8 | ./down.sh 9 | ./up.sh -s ../MultipleConstructors 10 | 11 | check() { 12 | echo "$1" 13 | res="$($1)" 14 | 15 | if [[ "$res" != "$2" ]]; then 16 | echo "Expected '$2' from '$1' but got '$res'" 17 | exit 1 18 | fi 19 | } 20 | 21 | check "./invoke.sh -q doS1" "1" 22 | check "./invoke.sh -q doS2" "2" 23 | check "./invoke.sh -q doS3" "1" 24 | 25 | ./down.sh 26 | cd ../ 27 | rm -rf MultipleConstructors 28 | 29 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/ExampleTypeFailure.obs: -------------------------------------------------------------------------------- 1 | contract C { 2 | C@Owned(string s) { 3 | ->HasString(s = s); 4 | } 5 | 6 | state HasString { 7 | string s; 8 | } 9 | } 10 | 11 | main contract IntContainer { 12 | int x; 13 | string s; 14 | bool b; 15 | 16 | transaction setX(int newX) returns int { 17 | int oldX = this.x; 18 | // type failure: adding with a boolean 19 | this.x = newX + true; 20 | // wrong arity 21 | createC(); 22 | // not the correct return value 23 | return this.b; 24 | } 25 | 26 | transaction createC(string s) returns C@Owned { 27 | return new C(s); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /evaluation/Tutorials/fused-type-inference/Q16.2.html: -------------------------------------------------------------------------------- 1 | The following code is a partial implementation of a vending machine, which takes special VendingTokens and returns Beverage objects. 2 |
 3 | 
 4 | class VendingToken {}
 5 | 
 6 | class VendingMachine {
 7 |   public Beverage processSale(VendingToken token) { // Location (A)
 8 |     // Dispense beverage (code not shown)
 9 |   }
10 | }
11 | 
12 | class User {
13 |   public buyBeverage(VendingMachine machine, VendingToken token) {  // Location (B)
14 |     machine.processSale(token);
15 |   }
16 | }
17 | 
18 | 
19 | 20 | The declaration of processSale (Location A) is missing ownership annotations. Please re-write it correctly. -------------------------------------------------------------------------------- /evaluation/solidity_participant_template/tutorial-exercises/code8.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.5.11; 2 | 3 | /* 4 | Write a contract Restaurant that has two transactions: dineIn and takeOut. 5 | You do NOT need to fill in the bodies of these transactions, only write the transaction declarations. 6 | The dineIn transaction should take in a Person as well as an integer number of people in the party as parameters. 7 | takeOut should only take in a Person parameter. Both of these transactions should ONLY be allowed when the Restaurant is open. 8 | If it is closed, neither transaction can be done. 9 | 10 | Please write your code below. The Person contract is given below. 11 | */ 12 | 13 | contract Person { 14 | //... 15 | } -------------------------------------------------------------------------------- /resources/tests/parser_tests/InvokableSpec.obs: -------------------------------------------------------------------------------- 1 | 2 | // NOTE: this file should parse, but not type-check 3 | 4 | asset contract C_Owned {} 5 | contract C { 6 | state S1 {} 7 | state S2 {} 8 | 9 | C@Owned() { return; } 10 | 11 | C@S1() { return; } 12 | 13 | C@(S1|S2)() { return; } 14 | 15 | 16 | transaction t() { return; } 17 | 18 | transaction t() returns int { return; } 19 | 20 | transaction t() returns C_Owned { return; } 21 | 22 | transaction t() returns C_Owned { return; } 23 | 24 | transaction t() returns C_Owned { return; } 25 | 26 | transaction t(C@S1 this) returns C_Owned { return; } 27 | 28 | transaction t(C@(S1|S2) this) returns C_Owned { return; } 29 | } 30 | -------------------------------------------------------------------------------- /network-framework/org3-artifacts/org3-crypto.yaml: -------------------------------------------------------------------------------- 1 | # Copyright IBM Corp. All Rights Reserved. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | 6 | # --------------------------------------------------------------------------- 7 | # "PeerOrgs" - Definition of organizations managing peer nodes 8 | # --------------------------------------------------------------------------- 9 | PeerOrgs: 10 | # --------------------------------------------------------------------------- 11 | # Org3 12 | # --------------------------------------------------------------------------- 13 | - Name: Org3 14 | Domain: org3.example.com 15 | EnableNodeOUs: true 16 | Template: 17 | Count: 2 18 | Users: 19 | Count: 1 20 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/SetGetConstructorField.obs: -------------------------------------------------------------------------------- 1 | contract IntContainer{ 2 | int x; 3 | 4 | IntContainer@Owned(int init) { 5 | x = init; 6 | } 7 | 8 | transaction set(int value) { 9 | x = value; 10 | } 11 | transaction get() returns int{ 12 | return x; 13 | } 14 | } 15 | 16 | main contract SetGetConstructorField{ 17 | IntContainer@Owned ic; 18 | 19 | SetGetConstructorField@Owned(){ 20 | ic = new IntContainer(5); 21 | } 22 | 23 | transaction main() returns int{ 24 | SetGetConstructorField local = new SetGetConstructorField(); 25 | ic = new IntContainer(5); 26 | ic.set(12); 27 | return (ic.get()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /resources/tests/endToEndTests/GenericsStateVariablesTest.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | source "lib.sh" 6 | 7 | init "GenericsStateVariables" 8 | 9 | check "./invoke.sh -q g" "14" 10 | check "./invoke.sh -q stateTestTrue" "\001" 11 | check "./invoke.sh -q stateTestFalse" "\000" 12 | check "./invoke.sh -q testStoreOwned" "\001" 13 | check "./invoke.sh -q testStoreOwnedNotOwned" "\001" 14 | check "./invoke.sh -q testStoreShared" "\001" 15 | check "./invoke.sh -q testStoreSharedNotShared" "\001" 16 | check "./invoke.sh -q testStoreUnowned" "\001" 17 | check "./invoke.sh -q testStoreUnownedNotUnowned" "\001" 18 | check "./invoke.sh -q testStoreStateShared" "\001" 19 | 20 | cleanup "GenericsStateVariables" 21 | 22 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/SetGetRefCountIncr.obs: -------------------------------------------------------------------------------- 1 | contract IntContainer{ 2 | int x; 3 | 4 | transaction set(int value) { 5 | x = value; 6 | } 7 | transaction get() returns int{ 8 | return x; 9 | } 10 | } 11 | 12 | main contract SetGetRefCountIncr{ 13 | IntContainer@Unowned ic1; // this is unowned, now, compared to SetGetLogs 14 | IntContainer@Owned ic2; 15 | 16 | transaction main() returns int{ 17 | ic1 = new IntContainer(); 18 | ic2 = ic1; // the reference counter field should be 2 after this 19 | ic2.retain(); 20 | ic1.set(5); 21 | ic2.set(8); 22 | return (ic1.get() + ic2.get()); //16; the 8 should overwrite the 5 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/MultistateFields.obs: -------------------------------------------------------------------------------- 1 | main contract MultistateFields { 2 | state S1 {} 3 | state S2 {} 4 | state S3 {} 5 | 6 | MultistateFields@S1() { 7 | ->S1(foo = 0); 8 | } 9 | 10 | int foo available in S1, S2; 11 | 12 | transaction setFoo(MultistateFields@(S1|S2) this, int f) { 13 | foo = f; 14 | int x = foo; 15 | } 16 | 17 | transaction invalidSetFoo1(MultistateFields@S3 this, int f) { 18 | // Error: foo not available in S3 19 | foo = f; 20 | } 21 | 22 | transaction invalidSetFoo2(MultistateFields@(S2|S3) this, int f) { 23 | // Error: foo not available in S3 24 | foo = f; 25 | 26 | // Error: foo not available in S3 27 | int x = foo; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /resources/tests/ManualSolidityBenchmarks/SetGetPointer_Contract.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD 2 | 3 | pragma solidity >=0.8.0; 4 | 5 | contract Main { 6 | function main() public returns (int) { 7 | IntContainer d = new IntContainer(); 8 | d.set(); 9 | return d.get(); 10 | } 11 | } 12 | 13 | contract IntContainer { 14 | int x; 15 | int y; 16 | int z; 17 | int f; 18 | 19 | function set() public { 20 | x = -1; 21 | f = -1; 22 | z = -1; 23 | y = -1; 24 | x = 5; 25 | y = 10; 26 | z = 4; 27 | f = 9; 28 | } 29 | 30 | function get() public view returns (int) { 31 | return x*y*z*f; // 1800 32 | } 33 | 34 | } 35 | 36 | -------------------------------------------------------------------------------- /papers/yul_evm_writeup/ACM-Reference-Format.dbx: -------------------------------------------------------------------------------- 1 | % Teach biblatex about numpages field 2 | \DeclareDatamodelFields[type=field, datatype=literal]{numpages} 3 | \DeclareDatamodelEntryfields{numpages} 4 | 5 | % Teach biblatex about articleno field 6 | \DeclareDatamodelFields[type=field, datatype=literal]{articleno} 7 | \DeclareDatamodelEntryfields{articleno} 8 | 9 | % Teach biblatex about urls field 10 | \DeclareDatamodelFields[type=list, datatype=uri]{urls} 11 | \DeclareDatamodelEntryfields{urls} 12 | 13 | % Teach biblatex about school field 14 | \DeclareDatamodelFields[type=list, datatype=literal]{school} 15 | \DeclareDatamodelEntryfields[thesis]{school} 16 | 17 | \DeclareDatamodelFields[type=field, datatype=literal]{key} 18 | \DeclareDatamodelEntryfields{key} -------------------------------------------------------------------------------- /src/main/scala/edu/cmu/cs/obsidian/codegen/FuncScope.scala: -------------------------------------------------------------------------------- 1 | package edu.cmu.cs.obsidian.codegen 2 | 3 | class FuncScope(f: FunctionDefinition) { 4 | class Param(val name: String) {} 5 | 6 | class Body(val code: String) {} 7 | 8 | val functionName: String = f.name 9 | val (arg0, argRest) = f.parameters match { 10 | case hd +: tl => (hd, tl.map(p => new Param(p.name)).toArray) 11 | case _ => ("", Array[Param]()) 12 | } 13 | 14 | var hasRetVal: Boolean = f.returnVariables.nonEmpty 15 | var retParams: String = f.returnVariables.map(v => v.name).mkString(", ") 16 | 17 | def params(): Array[Param] = argRest 18 | 19 | def body(): Array[Body] = f.body.statements.map(s => new Body(s.toString)).toArray 20 | } 21 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/MultiLineIfRetSm.obs: -------------------------------------------------------------------------------- 1 | /* this test demonstrates that if-then-else blocks can have more than one 2 | * line in them and still function correctly; it stops short of having much 3 | * more than 1 line because of a limit on the number of stack 4 | * variables. (https://github.com/mcoblenz/Obsidian/issues/341) 5 | */ 6 | 7 | main contract MultiLineIfRetSm { 8 | transaction val() returns int { 9 | int x = 0; 10 | if ( true && ! false ) { 11 | x = 20; 12 | return 4 + x; 13 | } else { 14 | return 13; 15 | } 16 | } 17 | transaction main() returns int{ 18 | int x; 19 | x = 9 + 0; 20 | x = val(); 21 | return x; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /evaluation/Tutorials/license-exercises/Money.obs: -------------------------------------------------------------------------------- 1 | // Money is shared, trusted code -- but it only has to be written once. 2 | asset contract Money { 3 | int value; 4 | 5 | Money@Owned(int v) { 6 | value = v; 7 | } 8 | 9 | transaction getValue(Money@Unowned this) returns int { 10 | return value; 11 | } 12 | 13 | transaction split(Money@Owned this, int v) returns Money@Owned { 14 | if (v > value) { 15 | revert; 16 | } 17 | value = value - v; 18 | Money result = new Money(v); 19 | return result; 20 | } 21 | 22 | transaction merge(Money@Owned this, Money@Owned >> Unowned other) { 23 | value = value + other.getValue(); 24 | disown other; 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /resources/demos/TinyVendingMachine/TinyVendingMachineClient.obs: -------------------------------------------------------------------------------- 1 | import "TinyVendingMachine.obs" 2 | 3 | main contract TinyVendingMachineClient { 4 | transaction main(remote TinyVendingMachine@Shared machine) { 5 | restock(machine); 6 | 7 | if (machine in Full) { 8 | Coin c = new Coin(); 9 | remote Candy candy = machine.buy(c); 10 | eat(candy); 11 | } 12 | } 13 | 14 | private transaction restock(remote TinyVendingMachine@Shared machine) { 15 | if (machine in Empty) { 16 | Candy candy = new Candy(); 17 | machine.restock(candy); 18 | } 19 | } 20 | 21 | private transaction eat(remote Candy @ Owned >> Unowned c) { 22 | disown c; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /resources/case_studies/Insurance/TimeService.obs: -------------------------------------------------------------------------------- 1 | main contract TimeService { 2 | int currentTimeInMillis; 3 | 4 | TimeService@Shared() { 5 | currentTimeInMillis = 0; 6 | } 7 | 8 | transaction getTime() returns int { 9 | return currentTimeInMillis; 10 | } 11 | 12 | transaction incrTime() { 13 | currentTimeInMillis = currentTimeInMillis + 1; 14 | } 15 | 16 | transaction hoursToMillis(int hours) returns int { 17 | return hours * 3600000; 18 | } 19 | 20 | transaction setTime(int newMillis) { 21 | if (newMillis >= currentTimeInMillis) { 22 | currentTimeInMillis = newMillis; 23 | } 24 | else { 25 | revert "Can't move time backwards."; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /resources/case_studies/Insurance/solidity/bank.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.0; 2 | import "./money.sol"; 3 | 4 | contract Bank { 5 | Money mon; 6 | address owner; 7 | mapping (address => uint) public balances; 8 | 9 | 10 | constructor() public { 11 | mon = new Money(0); 12 | owner = msg.sender; 13 | } 14 | 15 | function addMoney(uint amount) public { 16 | mon.addMoney(new Money(amount)); // probably doesn't work since both Moneys were made here ? 17 | } 18 | 19 | 20 | function send(address receiver, uint amount) public { 21 | require(balances[msg.sender] >= amount, "Not enough money to send."); 22 | balances[msg.sender] -= amount; 23 | balances[receiver] += amount; 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /bin/travisdebug: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | 4 | # travisdebug kicks a travis instance into debug mode so that you can in 5 | # to it. it takes two arguments, first the authorization token and then 6 | # the job number. see https://docs.travis-ci.com/user/triggering-builds/ 7 | # for details. 8 | 9 | 10 | # chrome-cli list tabs | grep -i travis | grep -i job | grab the id 11 | # chrome-cli id | grab the url, take the end of it 12 | 13 | if [ $# -eq 0 ] 14 | then 15 | echo "No arguments supplied" 16 | exit 1 17 | fi 18 | 19 | curl -s -X POST \ 20 | -H "Content-Type: application/json" \ 21 | -H "Accept: application/json" \ 22 | -H "Travis-API-Version: 3" \ 23 | -H "Authorization: token $1" \ 24 | -d "{\"quiet\": true}" \ 25 | https://api.travis-ci.com/job/$2/debug 26 | -------------------------------------------------------------------------------- /resources/tests/SolidityBenchmarks/SetGetPointer_Struct.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD 2 | 3 | pragma solidity >=0.8.0; 4 | 5 | contract IntContainer { 6 | 7 | struct Data { 8 | int x; 9 | int y; 10 | int z; 11 | int f; 12 | } 13 | 14 | function set(Data memory d) pure public { 15 | d.x = -1; 16 | d.f = -1; 17 | d.z = -1; 18 | d.y = -1; 19 | d.x = 5; 20 | d.y = 10; 21 | d.z = 4; 22 | d.f = 9; 23 | } 24 | 25 | function get(Data memory d) pure public returns (int) { 26 | return d.x*d.y*d.z*d.f; // 1800 27 | } 28 | 29 | function main() public pure returns (int) { 30 | Data memory d; 31 | set(d); 32 | return get(d); 33 | } 34 | 35 | 36 | } -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/StaticAsserts.obs: -------------------------------------------------------------------------------- 1 | main contract C { 2 | state S1; 3 | state S2; 4 | 5 | C@Owned() { 6 | ->S1; [this@S1|S3]; // should fail 7 | [this@S1|S2]; 8 | [this@S1]; 9 | [this @ (S1|S2)]; 10 | 11 | if (true) { 12 | ->S2; 13 | } 14 | 15 | [this @ (S1 | S2)]; 16 | 17 | [this @ S2]; // should fail 18 | } 19 | 20 | transaction t() { 21 | C ow = new C(); 22 | [ow @ Owned]; 23 | 24 | [ow @ Unowned]; // should fail 25 | 26 | // TODO: Not sure why we want this. 27 | // In the interest of making thing more uniform, I ended up accidentally disallowing this---I can put it back if necessary. 28 | // [ow @ Owned | Unowned]; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /resources/tests/FabricTests/IntContainerTest.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cd ../../../ 4 | # First generate int container java code 5 | sbt "runMain edu.cmu.cs.obsidian.Main resources/tests/compilerTests/IntContainer.obs" 6 | # Then go to run the tests 7 | cd network-framework 8 | ./down.sh 9 | ./up.sh -s ../IntContainer 10 | 11 | 12 | testVals=(5 7 8 9 10) 13 | for ((i = 0; i < 4; i++)); do 14 | echo -n "./invoke.sh -q setX ${testVals[i + 1]}" 15 | res=`./invoke.sh -q setX ${testVals[i + 1]}` 16 | sleep 2 17 | if [[ ${res} -ne testVals[i] ]] ; then 18 | echo 19 | echo "The old value in the IntContainer is ${testVals[i]}, but the returned value is $res" 20 | exit 1 21 | fi 22 | echo " pass" 23 | done 24 | 25 | ./down.sh 26 | cd ../ 27 | rm -rf IntContainer -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/Ownership.obs: -------------------------------------------------------------------------------- 1 | // This test focuses on ownership of non-asset objects. 2 | 3 | contract Prescription { 4 | 5 | } 6 | 7 | // Very simple pharmacy — only holds one prescription. 8 | main contract Pharmacy { 9 | Prescription@Owned prescription; 10 | 11 | transaction depositPrescription(Prescription@Owned >> Unowned p) { 12 | prescription = p; 13 | } 14 | 15 | transaction stealPrescription(Prescription@Unowned p) { 16 | prescription = p; 17 | // Error: prescription field's type does not match declaration at the end of this method 18 | // (TODO: https://github.com/mcoblenz/Obsidian/issues/134) 19 | } 20 | 21 | transaction dropPrescription(Prescription@Owned p) { 22 | // OK, since Prescription is not a asset. 23 | } 24 | } -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/Dereference.obs: -------------------------------------------------------------------------------- 1 | // Checks type-checking for field dereferences (e.g. "x.f") 2 | 3 | contract Thing { 4 | int x; 5 | string y; 6 | bool z; 7 | // don't really support inferring types yet 8 | Thing@Shared(int x) { 9 | this.x = x; 10 | this.y = "a"; 11 | this.z = true; 12 | } 13 | 14 | } 15 | 16 | main contract Construct { 17 | 18 | transaction derefThings() { 19 | Thing thing1 = new Thing(5); 20 | 21 | // should fail: not dereferenceable 22 | string c = "hi".y; 23 | 24 | // should fail: cannot access fields of non-this references. 25 | int x = thing1.x; 26 | } 27 | 28 | transaction getBogusField() returns int { 29 | // should fail: no such field 30 | return this.x; 31 | } 32 | } -------------------------------------------------------------------------------- /src/main/scala/edu/cmu/cs/obsidian/util/Util.scala: -------------------------------------------------------------------------------- 1 | package edu.cmu.cs.obsidian.util 2 | 3 | /** 4 | * Created by mcoblenz on 2/24/17. 5 | */ 6 | object Util { 7 | // Protobuf specifications are required to be in snake case, but Java and Obsidian use camel case. 8 | def snakeCaseToCamelCase(s: String): String = { 9 | // TODO 10 | "" 11 | } 12 | 13 | def protobufOuterClassNameForFilename(filename: String): String = { 14 | val lastSlash = filename.lastIndexOf("/") 15 | val fileWithoutPath: String = if (lastSlash >= 0) filename.substring(lastSlash + 1) else filename 16 | val filePrefix = fileWithoutPath.replace(".obs", "") 17 | 18 | filePrefix.substring(0, 1).toUpperCase(java.util.Locale.US) + filePrefix.substring(1) + "OuterClass" 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/StartState.obs: -------------------------------------------------------------------------------- 1 | contract NoStates { 2 | 3 | NoStates@Owned(){ 4 | int x = 1; 5 | } 6 | 7 | } 8 | 9 | contract HasStates { 10 | 11 | // Error: constructor does not transition to a named state 12 | HasStates@Owned() { 13 | int x = 1; 14 | } 15 | 16 | state Start { 17 | 18 | } 19 | 20 | state S1 { 21 | 22 | } 23 | 24 | transaction a(HasStates@Start >> S1 this) { 25 | ->S1; 26 | } 27 | } 28 | 29 | // Error: contract contains states but no constructor 30 | // (i.e. there is no way to get to an initial state) 31 | main contract StatesNoConstr { 32 | 33 | state Start { 34 | 35 | } 36 | 37 | transaction a(StatesNoConstr@Start >> S1 this) { 38 | ->S1; 39 | } 40 | state S1 { 41 | 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /bin/solc_optimized_yul: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # solc_optmized_yul runs solc on an argument yul file with the optimizer 4 | # fully enabled and prints the result to stdout 5 | 6 | if [ "$#" -ne 1 ]; then 7 | echo "usage: solc_optimized_yul fileOfYulCode.yul" 8 | exit 1 9 | fi 10 | 11 | if ! output=$(docker run -v "$( pwd -P )":/sources ethereum/solc:stable --strict-assembly --optimize /sources/"$1") 12 | then 13 | echo "Exiting because solc returned non-zero" 14 | exit 1 15 | fi 16 | 17 | TOP=$(echo "$output" | grep -n "Pretty printed source:" | cut -f1 -d:) 18 | BOT=$(echo "$output" | grep -n "Binary representation:" | cut -f1 -d:) 19 | TOP=$((TOP+1)) # drop the line with the name 20 | BOT=$((BOT-2)) # drop the empty line after the binary 21 | echo -ne "$output" | sed -n $TOP','$BOT'p' | bat -l javascript --style=plain 22 | -------------------------------------------------------------------------------- /evaluation/pilot3/tutorial-exercises/code3.obs: -------------------------------------------------------------------------------- 1 | 2 | //Write a constructor for the Money object shown above so that it accepts an integer as a parameter and sets "amount" to that integer value. 3 | 4 | contract Money { 5 | int amount; 6 | 7 | //TODO: write your constructor here 8 | 9 | transaction getAmount() returns int { 10 | return amount; 11 | } 12 | } 13 | 14 | main contract Wallet { 15 | Money@Owned m; 16 | 17 | Wallet@Owned() { 18 | m = new Money(); //TODO: you will have to change this once you make your new constructor 19 | } 20 | 21 | transaction spendMoney() { 22 | //... 23 | } 24 | 25 | transaction receiveMoney(Money@Owned >> Unowned mon) returns Money@Owned { 26 | Money temp = m; 27 | m = mon; 28 | return temp; 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /resources/tests/compilerTests/BasicGenerics.obs: -------------------------------------------------------------------------------- 1 | contract A[T] { 2 | T@Unowned x; 3 | 4 | A@Owned(T@Unowned x) { 5 | this.x = x; 6 | } 7 | 8 | transaction f() returns T@Unowned { 9 | return x; 10 | } 11 | } 12 | 13 | contract C { 14 | int val; 15 | 16 | C@Owned(int val) { 17 | this.val = val; 18 | } 19 | 20 | transaction getVal(C@Unowned this) returns int { 21 | return val; 22 | } 23 | } 24 | 25 | main contract BasicGenerics { 26 | transaction f() returns A[C]@Owned { 27 | return new A[C](new C(1)); 28 | } 29 | 30 | transaction g() returns int { 31 | return new A[C](new C(2)).f().getVal(); 32 | } 33 | 34 | transaction h() returns A[C]@Unowned { 35 | return new A[A[C]](new A[C](new C(3))).f(); 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /Obsidian_Runtime/src/main/java/Runtime/edu/cmu/cs/obsidian/chaincode/ObsidianRevertException.java: -------------------------------------------------------------------------------- 1 | // This represents an explicit throw statement executed in chaincode. 2 | 3 | package edu.cmu.cs.obsidian.chaincode; 4 | 5 | public class ObsidianRevertException extends ObsidianChaincodeException { 6 | String message; 7 | 8 | public ObsidianRevertException(String f, int l, String message) { 9 | super (f, l); 10 | 11 | this.message = message; 12 | } 13 | 14 | @Override 15 | public String getMessage() { 16 | if (message == null) { 17 | return "[" + filename + ": " + line + "]: Smart contract threw an exception."; 18 | } 19 | else { 20 | return "[" + filename + ": " + line + "]: Smart contract threw an exception: " + message; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/ConstructorFieldTypes.obs: -------------------------------------------------------------------------------- 1 | contract Item { 2 | } 3 | 4 | 5 | main asset contract Auction { 6 | Seller@Unsold seller; 7 | Item@Owned item available in Open, BiddingDone; 8 | 9 | state Open; 10 | 11 | Auction@Owned() { 12 | seller = new Seller(); 13 | -> Open(item = seller.giveItem()); 14 | // ERROR: giveItem() caused seller to be in state InAuction instead of Unsold 15 | } 16 | } 17 | 18 | asset contract Seller { 19 | state Unsold { 20 | Item@Owned item; 21 | }; 22 | state InAuction; 23 | 24 | Seller@Unsold() { 25 | -> Unsold(item = new Item()); 26 | } 27 | 28 | transaction giveItem(Seller@Unsold >> InAuction this) returns Item@Owned { 29 | Item temp = item; 30 | -> InAuction; 31 | return temp; 32 | } 33 | } -------------------------------------------------------------------------------- /evaluation/P41/tutorial-exercises/code5.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.5.11; 2 | 3 | //A Drink can be hot, cold, or lukewarm. If the Drink is cold, it has an IceCube object. If it is hot, it has a CupSleeve. 4 | //The Drink always has an integer value to keep track of its temperature. 5 | //A Drink always starts out lukewarm. 6 | 7 | //Write the Drink contract below with the necessary states, fields, and constructors for the situation described above. 8 | //The contracts for IceCube and CupSleeve are given below. 9 | 10 | //Note: the Drink contract MUST be main 11 | 12 | 13 | contract IceCube { 14 | //... 15 | } 16 | 17 | contract CupSleeve { 18 | //... 19 | } 20 | 21 | contract Drink { 22 | enum State {hot, cold, lukewarm} 23 | int temperature; 24 | 25 | State state; 26 | Icecube icecube; 27 | Cupsleeve cupsleeve; 28 | 29 | 30 | } -------------------------------------------------------------------------------- /evaluation/Tutorials/obsidian/Q14.4.html: -------------------------------------------------------------------------------- 1 | The next several questions concern this code: 2 |
 3 | 
 4 | asset class Money {…}
 5 | asset class Bank {
 6 |   Money@Owned myMoney;
 7 |   
 8 |   void depositMoney(Money @ Owned >> Unowned deposit) { … }  
 9 |   Money@Owned withdrawMoney() {…} // Withdraws all money
10 | }
11 | 
12 | class Test {
13 |    Bank b;
14 | 
15 |   void putMoneyInBank(Money @ Owned >> Unowned m) {     
16 |     // At the beginning of this method, m owns an instance of Money.    
17 |     Money@Owned q = m; // Location (A)
18 |     b.depositMoney(q); // Location (B)
19 |     // Location (C)
20 |     b.depositMoney(b.withdrawMoney()) // Location (D)
21 |   }
22 | }
23 | 
24 | 
25 | At the beginning of putMoneyInBank(), what is the type of m? -------------------------------------------------------------------------------- /evaluation/obsidian_participant_template/tutorial-exercises/code3.obs: -------------------------------------------------------------------------------- 1 | 2 | //Write a constructor for the Money object shown above so that it accepts an integer as a parameter and sets "amount" to that integer value. 3 | 4 | contract Money { 5 | int amount; 6 | 7 | //TODO: write your constructor here 8 | 9 | transaction getAmount() returns int { 10 | return amount; 11 | } 12 | } 13 | 14 | main contract Wallet { 15 | Money@Owned m; 16 | 17 | Wallet@Owned() { 18 | m = new Money(); //TODO: you will have to change this once you make your new constructor 19 | } 20 | 21 | transaction spendMoney() { 22 | //... 23 | } 24 | 25 | transaction receiveMoney(Money@Owned >> Unowned mon) returns Money@Owned { 26 | Money temp = m; 27 | m = mon; 28 | return temp; 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /Obsidian_Runtime/src/main/java/Runtime/edu/cmu/cs/obsidian/chaincode/InvalidStateException.java: -------------------------------------------------------------------------------- 1 | package edu.cmu.cs.obsidian.chaincode; 2 | 3 | /** 4 | * Created by mcoblenz on 3/19/19. 5 | */ 6 | public class InvalidStateException extends Exception { 7 | private ObsidianSerialized statefulObj; 8 | private String currentState; 9 | private String requestedTransaction; 10 | 11 | public InvalidStateException(ObsidianSerialized statefulObj, String currentState, String requestedTransaction) { 12 | this.statefulObj = statefulObj; 13 | this.currentState = currentState; 14 | this.requestedTransaction = requestedTransaction; 15 | } 16 | 17 | public String toString() { 18 | return "Cannot invoke transaction " + requestedTransaction + " with " + statefulObj + " in state " + currentState + "."; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/SetGetPointer.obs: -------------------------------------------------------------------------------- 1 | contract IntContainer{ 2 | int x; 3 | int y; 4 | int z; 5 | int f; 6 | 7 | transaction set() { 8 | x = -1; 9 | f = -1; 10 | z = -1; 11 | y = -1; 12 | x = 5; 13 | y = 10; 14 | z = 4; 15 | f = 9; 16 | } 17 | 18 | transaction get() returns int{ 19 | return x*y*z*f; // 1800 20 | } 21 | } 22 | 23 | 24 | // this differs from the test in SG.obs in that the main contract 25 | // not only has a field but that field is at a non-primitive type 26 | main contract SetGetPointer { 27 | IntContainer@Owned ic; 28 | 29 | transaction main() returns int{ 30 | ic = new IntContainer(); 31 | ic.set(); 32 | int res = ic.get(); 33 | ic.release(); 34 | return res; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /resources/tests/compilerTests/StringContainerContainer.obs: -------------------------------------------------------------------------------- 1 | contract StringContainer { 2 | string str; 3 | int i; 4 | 5 | StringContainer@Owned(string s, int new_i) { 6 | str = s; 7 | i = new_i; 8 | } 9 | 10 | transaction getString() returns string { 11 | return str; 12 | } 13 | 14 | transaction getInt() returns int { 15 | return i; 16 | } 17 | } 18 | 19 | 20 | main contract StringContainerContainer { 21 | StringContainer@Owned container; 22 | 23 | StringContainerContainer() { 24 | container = new StringContainer("hello, world", 5); 25 | } 26 | 27 | transaction setContainer(StringContainer@Owned >> Unowned s) { 28 | container = s; 29 | } 30 | 31 | transaction getContainer() returns StringContainer@Unowned { 32 | return container; 33 | } 34 | } -------------------------------------------------------------------------------- /Obsidian_Runtime/src/main/java/Runtime/edu/cmu/cs/obsidian/chaincode/UUIDFactory.java: -------------------------------------------------------------------------------- 1 | package edu.cmu.cs.obsidian.chaincode; 2 | 3 | import java.util.UUID; 4 | import java.nio.ByteBuffer; 5 | 6 | public class UUIDFactory { 7 | // We store a hash of the transaction ID rather than the whole ID to limit its length to something predictable. 8 | private int transactionIDHash; 9 | private int nextSerialNumber; 10 | 11 | public UUIDFactory (String transactionID) { 12 | this.transactionIDHash = transactionID.hashCode(); 13 | nextSerialNumber = 0; 14 | } 15 | 16 | public UUID newUUID() { 17 | ByteBuffer b = ByteBuffer.allocate(8); 18 | b.putInt(transactionIDHash); 19 | b.putInt(nextSerialNumber); 20 | nextSerialNumber++; 21 | 22 | return UUID.nameUUIDFromBytes(b.array()); 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /Obsidian_Runtime/src/main/java/Runtime/edu/cmu/cs/obsidian/chaincode/WrongNumberOfArgumentsException.java: -------------------------------------------------------------------------------- 1 | package edu.cmu.cs.obsidian.chaincode; 2 | 3 | /** 4 | * Created by mcoblenz on 4/6/17. 5 | */ 6 | public class WrongNumberOfArgumentsException extends Exception { 7 | private String transactionName; 8 | private int actualArgs; 9 | private int expectedArgs; 10 | 11 | public WrongNumberOfArgumentsException(String transactionName, int actualArgs, int expectedArgs) { 12 | this.transactionName = transactionName; 13 | this.actualArgs = actualArgs; 14 | this.expectedArgs = expectedArgs; 15 | } 16 | 17 | public String toString() { 18 | return "Wrong number of arguments invoking transaction " + transactionName + 19 | ". Expected " + expectedArgs + "; got " + actualArgs + "."; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /evaluation/pilot6/tutorial-exercises/code3.obs: -------------------------------------------------------------------------------- 1 | 2 | //Write a constructor for the Money object shown above so that it accepts an integer as a parameter and sets "amount" to that integer value. 3 | 4 | contract Money { 5 | int amount; 6 | 7 | Money@Owned(int amount) { 8 | this.amount = amount; 9 | } 10 | 11 | transaction getAmount() returns int { 12 | return amount; 13 | } 14 | } 15 | 16 | main contract Wallet { 17 | Money@Owned m; 18 | 19 | Wallet@Owned() { 20 | m = new Money(0); //TODO: you will have to change this once you make your new constructor 21 | } 22 | 23 | transaction spendMoney() { 24 | //... 25 | } 26 | 27 | transaction receiveMoney(Money@Owned >> Unowned mon) returns Money@Owned { 28 | Money temp = m; 29 | m = mon; 30 | return temp; 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /evaluation/pilot7/tutorial-exercises/code5.obs: -------------------------------------------------------------------------------- 1 | 2 | //A Drink can be hot, cold, or lukewarm. If the Drink is cold, it has an IceCube object. If it is hot, it has a CupSleeve. 3 | //The Drink always has an integer value to keep track of its temperature. 4 | //A Drink always starts out lukewarm. 5 | 6 | //Write the Drink contract below with the necessary states, fields, and constructors for the situation described above. 7 | //The contracts for IceCube and CupSleeve are given below. 8 | 9 | //Note: the Drink contract MUST be main 10 | 11 | 12 | contract IceCube { 13 | //... 14 | } 15 | 16 | contract CupSleeve { 17 | //... 18 | } 19 | 20 | main contract Drink{ 21 | 22 | int temp; 23 | state hot{ 24 | CupSleeve@Owned c; 25 | } 26 | 27 | state cold{ 28 | IceCube@Owned ic; 29 | } 30 | 31 | state lukewarm{ 32 | 33 | } 34 | } -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/ThisTypePDT.obs: -------------------------------------------------------------------------------- 1 | // more checks where "this" is implicit 2 | 3 | contract C { 4 | contract T { 5 | // [T] here means [this.parent.T] 6 | transaction t1_implicit(T x) { 7 | return; 8 | } 9 | 10 | transaction t1(parent.T x) { 11 | return; 12 | } 13 | 14 | transaction t2_implicit() returns T { 15 | return new T(); 16 | } 17 | 18 | transaction t2() returns parent.T { 19 | return new T(); 20 | } 21 | } 22 | 23 | transaction getT() returns this.T { 24 | return new T(); 25 | } 26 | } 27 | 28 | main contract UsesC { 29 | const C f; 30 | 31 | transaction t() { 32 | f.T x1 = f.getT(); 33 | f.T x2 = x1.t2(); 34 | f.T x2 = x1.t2_implicit(); 35 | x1.t1(x2); 36 | } 37 | } -------------------------------------------------------------------------------- /evaluation/Tutorials/fused-traditional-declarations/Q14.4.html: -------------------------------------------------------------------------------- 1 | The next several questions concern this code: 2 |
 3 | 
 4 | asset class Money {…}
 5 | asset class Bank {
 6 |   Money@Owned myMoney;
 7 |   
 8 |   void depositMoney(Money @ Owned >> Unowned deposit) { … }  
 9 |   Money@Owned withdrawMoney() {…} // Withdraws all money
10 | }
11 | 
12 | class Test {
13 |    Bank b;
14 | 
15 |   void putMoneyInBank(Money @ Owned >> Unowned m) {     
16 |     // At the beginning of this method, m owns an instance of Money.    
17 |     Money@Owned q = m; // Location (A)
18 |     b.depositMoney(q); // Location (B)
19 |     // Location (C)
20 |     b.depositMoney(b.withdrawMoney()) // Location (D)
21 |   }
22 | }
23 | 
24 | 
25 | At the beginning of putMoneyInBank(), what is the type of m? -------------------------------------------------------------------------------- /evaluation/Tutorials/split-traditional-declarations/Q14.4.html: -------------------------------------------------------------------------------- 1 | The next several questions concern this code: 2 |
 3 | 
 4 | asset class Money {…}
 5 | asset class Bank {
 6 |   owned Money myMoney;
 7 |   
 8 |   void depositMoney(owned Money >> unowned Money deposit) { … }  
 9 |   owned Money withdrawMoney() {…} // Withdraws all money
10 | }
11 | 
12 | class Test {
13 |    Bank b;
14 | 
15 |   void putMoneyInBank(owned Money >> unowned Money m) {     
16 |     // At the beginning of this method, m owns an instance of Money.    
17 |     owned Money q = m; // Location (A)
18 |     b.depositMoney(q); // Location (B)
19 |     // Location (C)
20 |     b.depositMoney(b.withdrawMoney()) // Location (D)
21 |   }
22 | }
23 | 
24 | 
25 | At the beginning of putMoneyInBank(), what is the type of m? -------------------------------------------------------------------------------- /evaluation/Tutorials/fused-type-inference/Q14.4.html: -------------------------------------------------------------------------------- 1 | The next several questions concern this code: 2 |
 3 | 
 4 | asset class Money {…}
 5 | asset class Bank {
 6 |   Money@Owned myMoney;
 7 |   
 8 |   void depositMoney(Money @ Owned >> Unowned deposit) { … }  
 9 |   Money@Owned withdrawMoney() {…} // Withdraws all money
10 | }
11 | 
12 | class Test {
13 |    Bank b;
14 | 
15 |   void putMoneyInBank(Money @ Owned >> Unowned m) {     
16 |     // At the beginning of this method, m owns an instance of Money.    
17 |     Money q = m; [m @ Unowned]; // Location (A)
18 |     b.depositMoney(q); [q @ Unowned]; // Location (B)
19 |     // Location (C)
20 |     b.depositMoney(b.withdrawMoney()) // Location (D)
21 |   }
22 | }
23 | 
24 | 
25 | At the beginning of putMoneyInBank(), what is the type of m? -------------------------------------------------------------------------------- /evaluation/pilot3/tutorial-exercises/code6.obs: -------------------------------------------------------------------------------- 1 | 2 | //Finish the vote transaction by transitioning the state of a Voter to the required state. 3 | 4 | main contract Voter { 5 | string name; 6 | bool citizen; 7 | 8 | state Eligible; 9 | state Ineligible; 10 | state Registered; 11 | state FinishedVoting; 12 | 13 | Voter@Owned(string n, bool citizenship) { 14 | name = n; 15 | citizen = citizenship; 16 | if (!citizen) { 17 | -> Ineligible; 18 | } 19 | else { 20 | -> Eligible; 21 | } 22 | } 23 | 24 | transaction vote(Voter@Registered >> FinishedVoting this) { 25 | // TODO 26 | } 27 | 28 | transaction register(Voter@Eligible >> (Registered | Ineligible) this) { 29 | //... 30 | -> Registered; //Always becomes Registered for now, just to compile 31 | } 32 | } -------------------------------------------------------------------------------- /evaluation/Tutorials/split-type-inference/Q14.4.html: -------------------------------------------------------------------------------- 1 | The next several questions concern this code: 2 |
 3 | 
 4 | asset class Money {…}
 5 | asset class Bank {
 6 |   owned Money myMoney;
 7 |   
 8 |   void depositMoney(owned Money >> unowned Money deposit) { … }  
 9 |   owned Money withdrawMoney() {…} // Withdraws all money
10 | }
11 | 
12 | class Test {
13 |    Bank b;
14 | 
15 |   void putMoneyInBank(owned Money >> unowned Money m) {     
16 |     // At the beginning of this method, m owns an instance of Money.    
17 |     Money q = m; [m unowned]; // Location (A)
18 |     b.depositMoney(q); [q unowned]; // Location (B)
19 |     // Location (C)
20 |     b.depositMoney(b.withdrawMoney()) // Location (D)
21 |   }
22 | }
23 | 
24 | 
25 | At the beginning of putMoneyInBank(), what is the type of m? -------------------------------------------------------------------------------- /evaluation/pilot6/tutorial-exercises/code6.obs: -------------------------------------------------------------------------------- 1 | 2 | //Finish the vote transaction by transitioning the state of a Voter to the required state. 3 | 4 | main contract Voter { 5 | string name; 6 | bool citizen; 7 | 8 | state Eligible; 9 | state Ineligible; 10 | state Registered; 11 | state FinishedVoting; 12 | 13 | Voter@Owned(string n, bool citizenship) { 14 | name = n; 15 | citizen = citizenship; 16 | if (!citizen) { 17 | -> Ineligible; 18 | } 19 | else { 20 | -> Eligible; 21 | } 22 | } 23 | 24 | transaction vote(Voter@Registered >> FinishedVoting this) { 25 | ->FinishedVoting; 26 | } 27 | 28 | transaction register(Voter@Eligible >> (Registered | Ineligible) this) { 29 | //... 30 | -> Registered; //Always becomes Registered for now, just to compile 31 | } 32 | } -------------------------------------------------------------------------------- /evaluation/pilot7/tutorial-exercises/code3.obs: -------------------------------------------------------------------------------- 1 | 2 | //Write a constructor for the Money object shown above so that it accepts an integer as a parameter and sets "amount" to that integer value. 3 | 4 | contract Money { 5 | int amount; 6 | 7 | //TODO: write your constructor here 8 | Money@Owned(int val){ 9 | amount = val; 10 | } 11 | transaction getAmount() returns int { 12 | return amount; 13 | } 14 | } 15 | 16 | main contract Wallet { 17 | Money@Owned m; 18 | 19 | Wallet@Owned() { 20 | m = new Money(10); //TODO: you will have to change this once you make your new constructor 21 | } 22 | 23 | transaction spendMoney() { 24 | //... 25 | } 26 | 27 | transaction receiveMoney(Money@Owned >> Unowned mon) returns Money@Owned { 28 | Money temp = m; 29 | m = mon; 30 | return temp; 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /evaluation/pilot8/tutorial-exercises/code5.obs: -------------------------------------------------------------------------------- 1 | 2 | //A Drink can be hot, cold, or lukewarm. If the Drink is cold, it has an IceCube object. If it is hot, it has a CupSleeve. 3 | //The Drink always has an integer value to keep track of its temperature. 4 | //A Drink always starts out lukewarm. 5 | 6 | //Write the Drink contract below with the necessary states, fields, and constructors for the situation described above. 7 | //The contracts for IceCube and CupSleeve are given below. 8 | 9 | //Note: the Drink contract MUST be main 10 | 11 | 12 | contract IceCube { 13 | //... 14 | } 15 | 16 | contract CupSleeve { 17 | //... 18 | } 19 | 20 | main contract Drink { 21 | state cold { 22 | IceCube@Owned ice_cube; 23 | } 24 | state lukewarm; 25 | state hot { 26 | CupSleeve@Owned cup_sleeve; 27 | } 28 | int temperature available in cold, lukewarm, hot; 29 | } -------------------------------------------------------------------------------- /evaluation/solidity_participant_template/tutorial-exercises/code3.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.5.11; 2 | 3 | //Write a constructor for the Money object shown above so that it accepts an integer as a parameter and sets "amount" to that integer value. 4 | 5 | contract Money { 6 | int public amount; 7 | 8 | //TODO: write your constructor here 9 | } 10 | 11 | contract Wallet { 12 | Money m; // m is owned 13 | 14 | constructor() public { 15 | m = new Money(); //TODO: you will have to change this once you make your new constructor 16 | } 17 | 18 | function spendMoney() public { 19 | //... 20 | } 21 | 22 | // mon is owned at the beginning but unowned at the end 23 | // Returns an owned reference. 24 | function receiveMoney(Money mon) public returns (Money) { 25 | Money temp = m; 26 | m = mon; 27 | return temp; 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/BottomTypeNoError.obs: -------------------------------------------------------------------------------- 1 | /* BottomType is used in the checker code to indicate a type that is unknown 2 | * because of a previous error. This code checks that using a variable or 3 | * expression that has been given the type BottomType does not cause another 4 | * error (this would create potentially many errors when merely one problem, 5 | * like an typo in a type or variable name, is responsible) */ 6 | main contract C { 7 | transaction t1() { 8 | // should fail: [d] will have BottomType because [D] doesn't exist 9 | D d = 5; 10 | // test with arithmetic stuff 11 | int i = d + 3; 12 | // test as an argument 13 | t2(i); 14 | 15 | // test as recipient of a call 16 | d.t(); 17 | int j = d.t(); 18 | } 19 | 20 | transaction t2(int i) returns int { 21 | return i; 22 | } 23 | } -------------------------------------------------------------------------------- /solidity_user_guide/source/index.rst: -------------------------------------------------------------------------------- 1 | .. Obsidian documentation master file, created by 2 | sphinx-quickstart on Fri Aug 23 13:39:43 2019. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | The Solidity Smart Contract Language 7 | ====================================== 8 | 9 | .. toctree:: 10 | :maxdepth: 2 11 | :hidden: 12 | 13 | Getting Started 14 | Solidity Language Tutorial 15 | 16 | 17 | Solidity is an object-oriented language for smart contracts. 18 | 19 | Even if you are highly experienced with OOP, you will find that by using special programming techniques, you can program much more safely, avoiding bugs that would otherwise be common. We recommend that you read the sections of the manual on *ownership* and *states* before you write your first Solidity program. -------------------------------------------------------------------------------- /evaluation/pilot3/tutorial-exercises/code3_R3.obs: -------------------------------------------------------------------------------- 1 | 2 | //Write a constructor for the Money object shown above so that it accepts an integer as a parameter and sets "amount" to that integer value. 3 | 4 | contract Money { 5 | int amount; 6 | 7 | Money@Owned(int amt) { 8 | amount = amt; 9 | } 10 | //TODO: write your constructor here 11 | 12 | transaction getAmount() returns int { 13 | return amount; 14 | } 15 | } 16 | 17 | main contract Wallet { 18 | Money@Owned m; 19 | 20 | Wallet@Owned() { 21 | m = new Money(0); //TODO: you will have to change this once you make your new constructor 22 | } 23 | 24 | transaction spendMoney() { 25 | //... 26 | } 27 | 28 | transaction receiveMoney(Money@Owned >> Unowned mon) returns Money@Owned { 29 | Money temp = m; 30 | m = mon; 31 | return temp; 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /evaluation/pilot5/tutorial-exercises/code6.obs: -------------------------------------------------------------------------------- 1 | 2 | //Finish the vote transaction by transitioning the state of a Voter to the required state. 3 | 4 | main contract Voter { 5 | string name; 6 | bool citizen; 7 | 8 | state Eligible; 9 | state Ineligible; 10 | state Registered; 11 | state FinishedVoting; 12 | 13 | Voter@Owned(string n, bool citizenship) { 14 | name = n; 15 | citizen = citizenship; 16 | if (!citizen) { 17 | -> Ineligible; 18 | } 19 | else { 20 | -> Eligible; 21 | } 22 | } 23 | 24 | transaction vote(Voter@Registered >> FinishedVoting this) { 25 | -> FinishedVoting; 26 | } 27 | 28 | transaction register(Voter@Eligible >> (Registered | Ineligible) this) { 29 | //... 30 | -> Registered; //Always becomes Registered for now, just to compile 31 | } 32 | } -------------------------------------------------------------------------------- /evaluation/pilot7/tutorial-exercises/code6.obs: -------------------------------------------------------------------------------- 1 | 2 | //Finish the vote transaction by transitioning the state of a Voter to the required state. 3 | 4 | main contract Voter { 5 | string name; 6 | bool citizen; 7 | 8 | state Eligible; 9 | state Ineligible; 10 | state Registered; 11 | state FinishedVoting; 12 | 13 | Voter@Owned(string n, bool citizenship) { 14 | name = n; 15 | citizen = citizenship; 16 | if (!citizen) { 17 | -> Ineligible; 18 | } 19 | else { 20 | -> Eligible; 21 | } 22 | } 23 | 24 | transaction vote(Voter@Registered >> FinishedVoting this) { 25 | -> FinishedVoting; 26 | } 27 | 28 | transaction register(Voter@Eligible >> (Registered | Ineligible) this) { 29 | //... 30 | -> Registered; //Always becomes Registered for now, just to compile 31 | } 32 | } -------------------------------------------------------------------------------- /evaluation/pilot8/tutorial-exercises/code3.obs: -------------------------------------------------------------------------------- 1 | 2 | //Write a constructor for the Money object shown above so that it accepts an integer as a parameter and sets "amount" to that integer value. 3 | 4 | contract Money { 5 | int amount; 6 | 7 | //TODO: write your constructor here 8 | 9 | Money@Owned(int a) { 10 | amount = a; 11 | } 12 | 13 | transaction getAmount() returns int { 14 | return amount; 15 | } 16 | } 17 | 18 | main contract Wallet { 19 | Money@Owned m; 20 | 21 | Wallet@Owned() { 22 | m = new Money(1); //TODO: you will have to change this once you make your new constructor 23 | } 24 | 25 | transaction spendMoney() { 26 | //... 27 | } 28 | 29 | transaction receiveMoney(Money@Owned >> Unowned mon) returns Money@Owned { 30 | Money temp = m; 31 | m = mon; 32 | return temp; 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /evaluation/pilot8/tutorial-exercises/code6.obs: -------------------------------------------------------------------------------- 1 | 2 | //Finish the vote transaction by transitioning the state of a Voter to the required state. 3 | 4 | main contract Voter { 5 | string name; 6 | bool citizen; 7 | 8 | state Eligible; 9 | state Ineligible; 10 | state Registered; 11 | state FinishedVoting; 12 | 13 | Voter@Owned(string n, bool citizenship) { 14 | name = n; 15 | citizen = citizenship; 16 | if (!citizen) { 17 | -> Ineligible; 18 | } 19 | else { 20 | -> Eligible; 21 | } 22 | } 23 | 24 | transaction vote(Voter@Registered >> FinishedVoting this) { 25 | -> FinishedVoting; 26 | } 27 | 28 | transaction register(Voter@Eligible >> (Registered | Ineligible) this) { 29 | //... 30 | -> Registered; //Always becomes Registered for now, just to compile 31 | } 32 | } -------------------------------------------------------------------------------- /network-framework/crypto-config/ordererOrganizations/example.com/msp/admincerts/Admin@example.com-cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICCTCCAbCgAwIBAgIQft7fmjKfpA8MIvARR8cbDDAKBggqhkjOPQQDAjBpMQsw 3 | CQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy 4 | YW5jaXNjbzEUMBIGA1UEChMLZXhhbXBsZS5jb20xFzAVBgNVBAMTDmNhLmV4YW1w 5 | bGUuY29tMB4XDTE5MDMwMTIzMDUwMFoXDTI5MDIyNjIzMDUwMFowVjELMAkGA1UE 6 | BhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lz 7 | Y28xGjAYBgNVBAMMEUFkbWluQGV4YW1wbGUuY29tMFkwEwYHKoZIzj0CAQYIKoZI 8 | zj0DAQcDQgAEX2yGNIo21eXgqMcrRCzhRK4W2PX63eOXNH1c6spGlowgKwFV5aBe 9 | FUM8WaZ3B3jhTz/IM6rEGxf5rIwqYUaYiaNNMEswDgYDVR0PAQH/BAQDAgeAMAwG 10 | A1UdEwEB/wQCMAAwKwYDVR0jBCQwIoAg3Wr+aK35yA5q/E2lkmKShVbz47fCEUAI 11 | ikt4WA/q51YwCgYIKoZIzj0EAwIDRwAwRAIgafi/VXz/Z8xYRnRdhbJomuBuYY9z 12 | kXbme2OjaKGMUXACIAY8nelSxVqg8zP0wFCCRqfRukz3KmnOkHr1ibhcOO9y 13 | -----END CERTIFICATE----- 14 | -------------------------------------------------------------------------------- /resources/tests/GanacheTests/SetGetNestedPointerPassThrough.obs: -------------------------------------------------------------------------------- 1 | contract IntContainer{ 2 | int x; 3 | 4 | IntContainer@Owned(int init) { 5 | x = init; 6 | } 7 | 8 | transaction set(int value) { 9 | x = value; 10 | } 11 | 12 | transaction get() returns int{ 13 | return x; 14 | } 15 | } 16 | 17 | contract IntContainerWrapper{ 18 | IntContainer@Owned ic; 19 | 20 | IntContainerWrapper@Owned() { 21 | ic = new IntContainer(0); 22 | } 23 | 24 | transaction set(int value) { 25 | ic.set(value); 26 | } 27 | 28 | transaction get() returns int{ 29 | return (ic.get()); 30 | } 31 | } 32 | 33 | main contract SetGetNestedPointerPassThrough{ 34 | transaction main() returns int{ 35 | IntContainerWrapper iw = new IntContainerWrapper(); 36 | iw.set(5); 37 | return(iw.get()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /evaluation/obsidian_participant_template/tutorial-exercises/code6.obs: -------------------------------------------------------------------------------- 1 | 2 | //Finish the vote transaction by transitioning the state of a Voter to the required state. 3 | 4 | main contract Voter { 5 | string name; 6 | bool citizen; 7 | 8 | state Eligible; 9 | state Ineligible; 10 | state Registered; 11 | state FinishedVoting; 12 | 13 | Voter@Owned(string n, bool citizenship) { 14 | name = n; 15 | citizen = citizenship; 16 | if (!citizen) { 17 | -> Ineligible; 18 | } 19 | else { 20 | -> Eligible; 21 | } 22 | } 23 | 24 | transaction vote(Voter@Registered >> FinishedVoting this) { 25 | // TODO 26 | } 27 | 28 | transaction register(Voter@Eligible >> (Registered | Ineligible) this) { 29 | //... 30 | -> Registered; //Always becomes Registered for now, just to compile 31 | } 32 | } -------------------------------------------------------------------------------- /evaluation/pilot6/tutorial-exercises/code5.obs: -------------------------------------------------------------------------------- 1 | 2 | //A Drink can be hot, cold, or lukewarm. If the Drink is cold, it has an IceCube object. If it is hot, it has a CupSleeve. 3 | //The Drink always has an integer value to keep track of its temperature. 4 | //A Drink always starts out lukewarm. 5 | 6 | //Write the Drink contract below with the necessary states, fields, and constructors for the situation described above. 7 | //The contracts for IceCube and CupSleeve are given below. 8 | 9 | //Note: the Drink contract MUST be main 10 | 11 | main contract Drink { 12 | state lukewarm; 13 | state hot { 14 | CupSleeve@Owned sleeve; 15 | } 16 | state cold { 17 | IceCube@Owned cube; 18 | } 19 | int temp; 20 | Drink@Owned() { 21 | temp = 15; 22 | ->lukewarm; 23 | } 24 | } 25 | 26 | contract IceCube { 27 | //... 28 | } 29 | 30 | contract CupSleeve { 31 | //... 32 | } -------------------------------------------------------------------------------- /resources/tests/type_checker_tests/MultistateTransactions.obs: -------------------------------------------------------------------------------- 1 | main contract MultistateTransactions { 2 | state S1 {} 3 | state S2 {} 4 | state S3 {} 5 | 6 | MultistateTransactions() { 7 | ->S1({}); 8 | } 9 | 10 | transaction foo() available in S1, S2 { 11 | } 12 | 13 | transaction validFooCall() available in S1 { 14 | foo(); 15 | } 16 | 17 | transaction validFooCall2() available in S1, S2 { 18 | foo(); 19 | } 20 | 21 | transaction validFooCall3() available in S2 { 22 | foo(); 23 | } 24 | 25 | transaction invalidFooCall() available in S3 { 26 | // Error: foo() not available in S3 27 | foo(); 28 | } 29 | 30 | transaction invalidFooCall2() available in S2, S3 { 31 | // Error: foo() not available in S3 32 | foo(); 33 | } 34 | 35 | transaction invalidFooCall3() { 36 | // Error: foo() not available in S3 37 | foo(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /evaluation/Tutorials/license-exercises/Licensor.obs: -------------------------------------------------------------------------------- 1 | asset contract Licensor { 2 | Money@Owned balance; 3 | 4 | Licensor@Owned() { 5 | balance = new Money(0); 6 | } 7 | 8 | // TODO: though we would hypothetically need these methods to actually run the program, in practice we do not 9 | transaction getLicense(Licensor@Owned this) returns License@Owned { 10 | return new License(this, 1); 11 | } 12 | 13 | transaction getApproval(Licensor@Owned this, string token) returns Approval@Owned { 14 | return new Approval(this); 15 | } 16 | 17 | transaction getCommission(Licensor@Owned this, string token, int paymentAmount) returns Commission@Owned { 18 | return new Commission(this, balance.split(paymentAmount)); 19 | } 20 | 21 | transaction pay(Licensor@Owned this, Money@Owned >> Unowned money) { 22 | balance.merge(money); 23 | } 24 | } 25 | 26 | --------------------------------------------------------------------------------