Skip to content

Commit d16a5da

Browse files
committed
Merged conflicts manually in .gitignore
2 parents 2909ad0 + f7fe252 commit d16a5da

9 files changed

+126
-15
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,7 @@ _opam/
3636
node_modules/
3737

3838
# EVM bytecode
39-
*.bytecode
39+
*.bytecode
40+
41+
# jetbrains
42+
.idea/

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020
3+
Copyright (c) 2020 OpenSC
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 114 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,135 @@ This is final project for COMS W4115 programming language & translator @ Columbi
44

55
## Introduction
66

7-
`OpenSC` is a high-level programming focusing on Smart Contract.
7+
[`OpenSC`](https://github.com/JackSnowWolf/OpenSC)
8+
is a functional programming language which has similar functionality
9+
compared to [`Scilla`](https://scilla.readthedocs.io/en/latest/)
10+
and [`Pact`](https://github.com/kadena-io/pact).
11+
It is statically typed and will support several features.
12+
It is a high-level language that will be primarily used to implement smart contracts,
13+
which are programs that provide protocol for handling account behavior in Ethereum.
814

15+
Compared to other languages, we model contracts as some simple transition systems,
16+
with the transitions being pure functions of the contract state. These functions
17+
are expressed from one state to another state in a list of storage mutations.
918

19+
Inspired by the `MiniC` language, part of the
20+
[`DeepSEA`](https://certik.io/blog/technology/an-introduction-to-deepsea) compiler,
21+
we aim to develop a language which allows interactive formal verification of
22+
smart contracts with security guarantees. From a specific input program, the
23+
compiler generates executable bytecode, as well as a model of the program that
24+
can be loaded into the [`Coq`](https://coq.inria.fr/)
25+
proof assistant. Our eventual goal is that smart contracts like storage,
26+
auction and token can be written by `OpenSC`, and that these contracts
27+
can be compiled via the translator into binary codes that can be executed on `EVM`.
1028

29+
## Structure
1130

12-
## Description
31+
### Translator Architecture
1332

14-
### Reference Manual
33+
<img src="https://github.com/JackSnowWolf/OpenSC/blob/master/pic/architecture.png" width="200" >
34+
35+
### Translate Details
36+
![tranlate into MiniC](pic/tranlate_into_MiniC.png)
37+
38+
### Code Structure
39+
40+
41+
- [src/opensc.ml](src/opensc.ml) is the top-level program of the compiler
42+
- A [src/Makefile](src/Makefile) is included to automate the compilation of the compiler
43+
44+
45+
![Code Structure](pic/code_structure.png)
1546

16-
### Structure
47+
## Usage
1748

18-
### Dependency
49+
### Environment Dependencies
1950

20-
## Deploy
51+
- Install `ocaml`, which is what our translator is written in.
52+
- Install `opam`, the ocaml package manager
53+
- `opam install cryptokit`, which is used in the `Minic` (IR code) generation phase of the compiler front-end for cryptographic hashing
54+
55+
56+
### Synopsis
57+
58+
```bash
59+
# at root directory of OpenSC
60+
cd src && Make
61+
./opensc.native [source.sc] [mode]
62+
```
63+
64+
### Modes
65+
66+
- `ast`
67+
- generate raw AST and print its structure
68+
- `sast`
69+
- generate SAST (semantically checked AST) and print its structure
70+
- `minic`
71+
- generate `Minic` AST (the IR code) and print its structure
72+
- `bytecode`
73+
- generate EVM bytecode and print it
2174

2275
### How to compile
2376

24-
### How to test
77+
```bash
78+
# at root directory of OpenSC
79+
cd src
80+
# compile opensc
81+
ocamlbuild -pkg cryptokit -I backend opensc.native
82+
./opensc.native [source.sc] [mode]
83+
# compile test.ml for printing ast
84+
ocamlbuild test.native
85+
./test.native < [source.sc]
86+
# compile test2.ml for printing sast
87+
ocamlbuild test2.native
88+
./test2.native < [source.sc]
89+
# compile test3.ml for printing Minic ast
90+
ocamlbuild test3.native
91+
./test3.native < [source.sc]
92+
# compile test4.ml for printing bytecode
93+
ocamlbuild test4.native
94+
./test4.native < [source.sc]
95+
```
96+
97+
98+
### Reference Manual
99+
100+
Check our [Language Reference Manual](doc/OpenSC_Reference_Manual.pdf) for
101+
detailed usage
102+
103+
104+
105+
25106

26107
## Presentation
27108

28109
* Proposal: [proposal pdf](doc/PLT_Project_Proposal.pdf)
110+
* Report: [report pdf](doc/PLT_Project_Report_OpenSC_A_Smart_Contract_Language.pdf)
111+
* Language Reference Manual: [LRM](doc/OpenSC_Reference_Manual.pdf)
112+
113+
114+
## Contribution
115+
116+
* __scanner:__ Linghan Kong, Chong Hu
117+
* __parser:__ Linghan Kong, Chong Hu, Jun Sha
118+
* __AST design:__ Linghan Kong, Ruibin Ma, Chong Hu
119+
* __SAST design:__: Linghan Kong, Ruibin Ma, Chong Hu
120+
* __semantic analysis:__ Chong Hu, Linghan Kong, Ruibin Ma, Jun Sha
121+
* __translate MiniC:__ Ruibin Ma, Linghan Kong, Chong Hu, Jun sha
122+
123+
124+
## Acknowledgements
125+
126+
Thanks to Professor Ronghui Gu, the instructor of our course, who brought us to the PLT world and let us realize the charm of functional programming and formal verification, both of which are what our project is based on.
127+
128+
Thanks to River Dillon Keefer and Amanda Liu, TAs of our course, who introduced the DeepSEA project to us and provided very inspiring and helpful ideas on the OpenSC language syntax among other project details.
129+
130+
Thanks to Vilhelm Sjöberg, our project advisor, researcher at Yale and the primary creator of the DeepSEA project, who provided us with great information on everything about the DeepSEA project, and answered our many questions, which has been super helpful.
29131

30132
## Contact
31133

32-
- Jun Sha `js5506`: [email]([email protected])
33-
- Linghan Kong `lk2811`: [email]([email protected])
34-
- Ruibin Ma `rm3708`: [email]([email protected])
35-
- Rahul Sehrawat `rs3688`: [email]([email protected])
36-
- Chong Hu `ch3467`: [email]([email protected])
134+
- Jun Sha `js5506`: [email](mailto:[email protected].com)
135+
- Linghan Kong `lk2811`: [email](mailto:[email protected])
136+
- Ruibin Ma `rm3708`: [email](mailto:[email protected])
137+
- Rahul Sehrawat `rs3688`: [email](mailto:[email protected])
138+
- Chong Hu `ch3467`: [email](mailto:[email protected])

doc/OpenSC_Reference_Manual.pdf

289 KB
Binary file not shown.
Binary file not shown.

pic/architecture.png

37.9 KB
Loading

pic/code_structure.png

62.6 KB
Loading

pic/tranlate_into_MiniC.png

14 KB
Loading

src/Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
.PHONY: opensc
2+
3+
all: opensc
4+
25
opensc:
3-
ocamlbuild -pkg cryptokit -I backend opensc.native
6+
ocamlbuild -pkg cryptokit -I backend opensc.native
7+
8+
clean:
9+
rm -f *.cmo *.cmi *.native

0 commit comments

Comments
 (0)