Crates.io | ola-lang |
lib.rs | ola-lang |
version | 0.1.1 |
source | src |
created_at | 2023-11-06 04:41:55.485103 |
updated_at | 2024-01-31 02:18:56.355555 |
description | Ola Language Compiler |
homepage | https://github.com/Sin7Y/ola-lang |
repository | |
max_upload_size | |
id | 1026396 |
size | 2,053,820 |
Ola is a high-level programming language for developing OlaVM smart contracts. It is Turing complete and can be used to write arithmetic programs. The computing process is proven by the OlaVM back-end proof system, which verifies that the OlaVM processing is accurate. Most of the existing programming languages in the ZKP field require fundamental knowledge of the circuit field, which is not universal, or the execution process is difficult to be proven and verified by ZKP.
The following shows a simple contract for calculating the Fibonacci function
contract Fibonacci {
fn fib_recursive(u32 n) -> (u32) {
if (n <= 2) {
return 1;
}
return fib_recursive(n -1) + fib_recursive(n -2);
}
fn fib_non_recursive(u32 n) -> (u32) {
u32 first = 0;
u32 second = 1;
u32 third = 1;
for (u32 i = 2; i <= n; i++) {
third = first + second;
first = second;
second = third;
}
return third;
}
}
u32
, field
, bool
, enum
, address
, and hash
types. In Ola, all data types are internally represented as combinations of the field
type. The maximum value for the field
type is 0xFFFFFFFF00000001
. The address
and hash
types are internally represented as arrays of four field
elements.string
, fields
, structures, and mappings. The fields
type is a dynamic array of field
elements.u32
type supports the most operators, such as: +
, -
, *
, /
, %
, **
, ==
, !=
, etc.fn
used to declare functions.if
statements, if-else
statements, while
statements, do-while
statements, for
loops, continue
, and break
.prophet
functions in Ola language are used for non-deterministic computations in specific scenarios, such as u32_sqrt
, u32_quick_sort
, etc.assert
,print
fileds_conct
, encode
decode
, and so on.The LLVM IR subset generated by the Olac compiler front-end is downgraded to OlaVM bytecode for execution by the OlaVM virtual machine.
void
typei64
, i1
, ptr
typeslabel
and token
typesret
, br
, switch
neg
add
, sub
, mul
and
, or
, xor
insertvalue
, extractvalue
alloca
, store
, load
, getelementptr
trunc
icmp
, phi
, call
assert
, rangecheck
, u32_sqrt
, div
, mod
, vec_new
, poseidon_hash
set_storage
, get_storage
get_context_data
, get_tape_data
, set_tape_data
printf
contract_call
program
and prophet
parts, executed directly by the VM and interpreted by the embedded interpreter, respectively.program
part: Defines the assembly output format, supporting the entire OlaVM custom instruction set.prophet
part: Refers to the prophets
set described in the IR libs extension.If you are having trouble installing and using Ola, please open an issue.