mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-24 10:41:57 +03:00
merge testnet3
This commit is contained in:
commit
4dc0df0084
@ -46,7 +46,7 @@ commands:
|
||||
jobs:
|
||||
check-style:
|
||||
docker:
|
||||
- image: cimg/rust:1.61
|
||||
- image: cimg/rust:1.62
|
||||
resource_class: xlarge
|
||||
steps:
|
||||
- checkout
|
||||
@ -61,7 +61,7 @@ jobs:
|
||||
|
||||
clippy:
|
||||
docker:
|
||||
- image: cimg/rust:1.61
|
||||
- image: cimg/rust:1.62
|
||||
resource_class: xlarge
|
||||
steps:
|
||||
- checkout
|
||||
@ -79,7 +79,7 @@ jobs:
|
||||
|
||||
# code-cov:
|
||||
# docker:
|
||||
# - image: cimg/rust:1.61
|
||||
# - image: cimg/rust:1.62
|
||||
# resource_class: xlarge
|
||||
# environment:
|
||||
# RUSTC_BOOTSTRAP: 1
|
||||
@ -121,7 +121,7 @@ jobs:
|
||||
|
||||
leo-executable:
|
||||
docker:
|
||||
- image: cimg/rust:1.61
|
||||
- image: cimg/rust:1.62
|
||||
resource_class: xlarge
|
||||
steps:
|
||||
- checkout
|
||||
@ -139,7 +139,7 @@ jobs:
|
||||
#
|
||||
# leo-new:
|
||||
# docker:
|
||||
# - image: cimg/rust:1.61
|
||||
# - image: cimg/rust:1.62
|
||||
# resource_class: xlarge
|
||||
# steps:
|
||||
# - attach_workspace:
|
||||
@ -152,7 +152,7 @@ jobs:
|
||||
#
|
||||
# leo-init:
|
||||
# docker:
|
||||
# - image: cimg/rust:1.61
|
||||
# - image: cimg/rust:1.62
|
||||
# resource_class: xlarge
|
||||
# steps:
|
||||
# - attach_workspace:
|
||||
@ -165,7 +165,7 @@ jobs:
|
||||
#
|
||||
# leo-clean:
|
||||
# docker:
|
||||
# - image: cimg/rust:1.61
|
||||
# - image: cimg/rust:1.62
|
||||
# resource_class: xlarge
|
||||
# steps:
|
||||
# - attach_workspace:
|
||||
@ -178,7 +178,7 @@ jobs:
|
||||
#
|
||||
# leo-setup:
|
||||
# docker:
|
||||
# - image: cimg/rust:1.61
|
||||
# - image: cimg/rust:1.62
|
||||
# resource_class: xlarge
|
||||
# steps:
|
||||
# - attach_workspace:
|
||||
@ -191,7 +191,7 @@ jobs:
|
||||
|
||||
# leo-add-remove:
|
||||
# docker:
|
||||
# - image: cimg/rust:1.61
|
||||
# - image: cimg/rust:1.62
|
||||
# resource_class: xlarge
|
||||
# steps:
|
||||
# - attach_workspace:
|
||||
@ -205,7 +205,7 @@ jobs:
|
||||
# todo (collin): uncomment after compiler refactor
|
||||
# leo-check-constraints:
|
||||
# docker:
|
||||
# - image: cimg/rust:1.61
|
||||
# - image: cimg/rust:1.62
|
||||
# resource_class: xlarge
|
||||
# steps:
|
||||
# - attach_workspace:
|
||||
@ -218,7 +218,7 @@ jobs:
|
||||
#
|
||||
# leo-login-logout:
|
||||
# docker:
|
||||
# - image: cimg/rust:1.61
|
||||
# - image: cimg/rust:1.62
|
||||
# resource_class: xlarge
|
||||
# steps:
|
||||
# - attach_workspace:
|
||||
@ -231,7 +231,7 @@ jobs:
|
||||
#
|
||||
# leo-clone:
|
||||
# docker:
|
||||
# - image: cimg/rust:1.61
|
||||
# - image: cimg/rust:1.62
|
||||
# resource_class: xlarge
|
||||
# steps:
|
||||
# - attach_workspace:
|
||||
@ -244,7 +244,7 @@ jobs:
|
||||
#
|
||||
# leo-publish:
|
||||
# docker:
|
||||
# - image: cimg/rust:1.61
|
||||
# - image: cimg/rust:1.62
|
||||
# resource_class: xlarge
|
||||
# steps:
|
||||
# - attach_workspace:
|
||||
|
@ -41,9 +41,10 @@ pub struct InputAst {
|
||||
|
||||
impl InputAst {
|
||||
/// Returns all values of the input AST for execution with `leo run`.
|
||||
pub fn values(&self) -> Vec<String> {
|
||||
pub fn program_inputs(&self, program_name: &str) -> Vec<String> {
|
||||
self.sections
|
||||
.iter()
|
||||
.filter(|section| section.name() == program_name)
|
||||
.flat_map(|section| {
|
||||
section
|
||||
.definitions
|
||||
|
@ -24,3 +24,9 @@ pub struct Section {
|
||||
pub definitions: Vec<Definition>,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl Section {
|
||||
pub fn name(&self) -> String {
|
||||
self.name.to_string()
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ impl<'a> ProgramVisitor<'a> for TypeChecker<'a> {
|
||||
});
|
||||
}
|
||||
|
||||
// For records, enforce presence of `owner: Address` and `balance: u64` members.
|
||||
// For records, enforce presence of `owner: Address` and `gates: u64` members.
|
||||
if input.is_record {
|
||||
let check_has_field = |need, expected_ty: Type| match input
|
||||
.members
|
||||
@ -95,7 +95,7 @@ impl<'a> ProgramVisitor<'a> for TypeChecker<'a> {
|
||||
}
|
||||
};
|
||||
check_has_field(sym::owner, Type::Address);
|
||||
check_has_field(sym::balance, Type::U64);
|
||||
check_has_field(sym::gates, Type::U64);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,10 +26,10 @@ use crate::symbol::with_session_globals;
|
||||
/// This is used in many spots throughout the rest of the Leo crates.
|
||||
#[derive(Copy, Clone, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)]
|
||||
pub struct Span {
|
||||
/// The start position of the span.
|
||||
/// The start (low) position of the span, inclusive.
|
||||
pub lo: BytePos,
|
||||
/// The end position of the span.
|
||||
/// The length is simply `end - start`.
|
||||
/// The end (high) position of the span, exclusive.
|
||||
/// The length is simply `hi - lo`.
|
||||
pub hi: BytePos,
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ symbols! {
|
||||
public,
|
||||
private,
|
||||
owner,
|
||||
balance,
|
||||
gates,
|
||||
|
||||
// todo: remove these.
|
||||
CONTAINER_PSEUDO_CIRCUIT: "$InputContainer",
|
||||
|
@ -1,3 +0,0 @@
|
||||
circuit Other {
|
||||
a: u64,
|
||||
}
|
@ -3,3 +3,5 @@
|
||||
public a: u32 = 1u32;
|
||||
b: u32 = 2u32; // Input variable `b` is private by default.
|
||||
|
||||
[foo]
|
||||
x: u64 = 5u64;
|
@ -1,8 +1,8 @@
|
||||
import other.leo;
|
||||
|
||||
// The 'helloworld' main function.
|
||||
function main(public a: u32, b: u32) -> u32 {
|
||||
let o: Other = Other { a: 1u64 };
|
||||
|
||||
return a + b;
|
||||
}
|
||||
|
||||
function foo(x: u64) -> u64 {
|
||||
return x - x;
|
||||
}
|
10
examples/sorting/bubblesort_tuple/build/program.json
Normal file
10
examples/sorting/bubblesort_tuple/build/program.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"program": "bubblesort_tuple.aleo",
|
||||
"version": "0.0.0",
|
||||
"description": "",
|
||||
"development": {
|
||||
"private_key": "APrivateKey1zkpHpeRwqVHKu4WiHkqvoWqJCV5gRekk1VR1dCG5uNvDnFu",
|
||||
"address": "aleo1dxptr6ecfml0lst7lu0l20ydyk7u09ewh82z9jezkuqdtkf6jqqslydvjv"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
1
examples/sorting/bubblesort_tuple/outputs/main.sum
Normal file
1
examples/sorting/bubblesort_tuple/outputs/main.sum
Normal file
@ -0,0 +1 @@
|
||||
718c0ec884bc6135c5f054bcac068f13c4bdf49c6c046caa683723b8e28e5fa2
|
@ -2,6 +2,6 @@
|
||||
[main]
|
||||
a: Record = Record {
|
||||
owner: aleo1d5hg2z3ma00382pngntdp68e74zv54jdxy249qhaujhks9c72yrs33ddah,
|
||||
balance: 5u64,
|
||||
gates: 5u64,
|
||||
token_amount: 100u64
|
||||
};
|
||||
|
@ -1,9 +1,12 @@
|
||||
record Token {
|
||||
// The token owner.
|
||||
owner: address,
|
||||
balance: u64,
|
||||
token_amount: u64,
|
||||
// The Aleo balance (in gates).
|
||||
gates: u64,
|
||||
// The token amount.
|
||||
amount: u64,
|
||||
}
|
||||
|
||||
function main(t: Token) -> u64 {
|
||||
return t.token_amount + t.token_amount;
|
||||
return t.amount + t.amount;
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
// The program input for transfer/src/main.leo
|
||||
[main]
|
||||
owner: address = aleo12aw0kcnzyn5xj46z9u6mzpa67tzuqnvmwe0q2ejfjm8c2ue4pgys3877fr;
|
||||
gates: u64 = 5u64;
|
||||
amount: u64 = 100u64;
|
||||
|
@ -1,13 +1,13 @@
|
||||
record Token {
|
||||
owner: address,
|
||||
balance: u64,
|
||||
gates: u64,
|
||||
amount: u64,
|
||||
}
|
||||
|
||||
function main(owner: address, amount: u64) -> Token {
|
||||
return Token {
|
||||
owner: owner,
|
||||
balance: 0u64,
|
||||
gates: 0u64,
|
||||
amount: amount,
|
||||
};
|
||||
}
|
||||
@ -21,13 +21,13 @@ function transfer(
|
||||
|
||||
let t1: Token = Token {
|
||||
owner: r,
|
||||
balance: 0u64,
|
||||
gates: 0u64,
|
||||
amount: a,
|
||||
};
|
||||
|
||||
let t2: Token = Token {
|
||||
owner: t.owner,
|
||||
balance: t.balance,
|
||||
gates: t.gates,
|
||||
amount: change
|
||||
};
|
||||
|
||||
|
@ -31,6 +31,9 @@ use tracing::span::Span;
|
||||
/// Build, Prove and Run Leo program with inputs
|
||||
#[derive(StructOpt, Debug)]
|
||||
pub struct Run {
|
||||
#[structopt(name = "NAME", help = "The name of the program to run.", default_value = "main")]
|
||||
name: String,
|
||||
|
||||
#[structopt(long = "skip-key-check", help = "Skip key verification on Setup stage")]
|
||||
pub(crate) skip_key_check: bool,
|
||||
|
||||
@ -54,17 +57,15 @@ impl Command for Run {
|
||||
}
|
||||
|
||||
fn apply(self, context: Context, input: Self::Input) -> Result<Self::Output> {
|
||||
// Compose the `aleo run` command.
|
||||
let mut arguments = vec![ALEO_CLI_COMMAND.to_string(), "main".to_string()];
|
||||
|
||||
// Get the input values.
|
||||
let mut values = match input {
|
||||
Some(input_ast) => input_ast.values(),
|
||||
let mut inputs = match input {
|
||||
Some(input_ast) => input_ast.program_inputs(&self.name),
|
||||
None => Vec::new(),
|
||||
};
|
||||
arguments.append(&mut values);
|
||||
|
||||
tracing::info!("Starting...");
|
||||
// Compose the `aleo run` command.
|
||||
let mut arguments = vec![ALEO_CLI_COMMAND.to_string(), self.name];
|
||||
arguments.append(&mut inputs);
|
||||
|
||||
// Open the Leo build/ directory
|
||||
let path = context.dir()?;
|
||||
|
@ -3,9 +3,9 @@ namespace: Compile
|
||||
expectation: Fail
|
||||
*/
|
||||
|
||||
// This record does define the `balance` variable but with the wrong type.
|
||||
// This record does define the `gates` variable but with the wrong type.
|
||||
record Token {
|
||||
balance: address,
|
||||
gates: address,
|
||||
owner: address,
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ record Token {
|
||||
// The token owner.
|
||||
owner: address,
|
||||
// The Aleo balance (in gates).
|
||||
balance: u64,
|
||||
gates: u64,
|
||||
// The token amount.
|
||||
amount: u64,
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ record Token {
|
||||
// The token owner.
|
||||
owner: address,
|
||||
// The Aleo balance (in gates).
|
||||
balance: u64,
|
||||
gates: u64,
|
||||
// The token amount.
|
||||
amount: u64,
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ record Token {
|
||||
// The token owner.
|
||||
owner: address, // Cannot define two record variables with the same name.
|
||||
// The Aleo balance (in gates).
|
||||
balance: u64,
|
||||
gates: u64,
|
||||
// The token amount.
|
||||
amount: u64,
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ record Token {
|
||||
// The token owner.
|
||||
owner: address,
|
||||
// The Aleo balance (in gates).
|
||||
balance: u64,
|
||||
gates: u64,
|
||||
// The token amount.
|
||||
amount: u64,
|
||||
}
|
||||
@ -15,7 +15,7 @@ record Token {
|
||||
function mint(r0: address, r1: u64) -> Token {
|
||||
return Token {
|
||||
owner: r0,
|
||||
balance: 0u64,
|
||||
gates: 0u64,
|
||||
amount: r1,
|
||||
};
|
||||
}
|
||||
@ -24,5 +24,5 @@ function main(x: address) -> u64 {
|
||||
const c: u64 = 1u64;
|
||||
let t: Token = mint(x, c);
|
||||
|
||||
return t.balance;
|
||||
return t.gates;
|
||||
}
|
@ -7,7 +7,7 @@ record Token {
|
||||
// The token owner.
|
||||
owner: address,
|
||||
// The Aleo balance (in gates).
|
||||
balance: u64,
|
||||
gates: u64,
|
||||
// The token amount.
|
||||
amount: u64,
|
||||
}
|
||||
@ -15,7 +15,7 @@ record Token {
|
||||
function mint(owner: address, amount: u64) -> Token {
|
||||
return Token {
|
||||
owner,
|
||||
balance: 0u64,
|
||||
gates: 0u64,
|
||||
amount,
|
||||
};
|
||||
}
|
||||
@ -24,5 +24,5 @@ function main(x: address) -> u64 {
|
||||
const c: u64 = 1u64;
|
||||
let t: Token = mint(x, c);
|
||||
|
||||
return t.balance;
|
||||
return t.gates;
|
||||
}
|
@ -7,7 +7,7 @@ record Token {
|
||||
// The token owner.
|
||||
owner: address,
|
||||
// The Aleo balance (in gates).
|
||||
balance: u64,
|
||||
gates: u64,
|
||||
// The token amount.
|
||||
amount: u64,
|
||||
}
|
||||
@ -15,7 +15,7 @@ record Token {
|
||||
function mint(r0: address, r1: u64) -> Token {
|
||||
return Token {
|
||||
owner: r1, // This variable should be type address.
|
||||
balance: 0u64,
|
||||
gates: 0u64,
|
||||
amount: r0, // This variable should be type u64.
|
||||
};
|
||||
}
|
||||
@ -24,5 +24,5 @@ function main(x: address) -> u64 {
|
||||
const c: u64 = 1u64;
|
||||
let t: Token = mint(x, c);
|
||||
|
||||
return t.balance;
|
||||
return t.gates;
|
||||
}
|
@ -7,7 +7,7 @@ record Token {
|
||||
// The token owner.
|
||||
owner: address,
|
||||
// The Aleo balance (in gates).
|
||||
balance: u64,
|
||||
gates: u64,
|
||||
// The token amount.
|
||||
amount: u64,
|
||||
}
|
||||
@ -15,7 +15,7 @@ record Token {
|
||||
function mint(r0: address, r1: u64) -> Token {
|
||||
return Token {
|
||||
sender: r0, // This variable should be named `owner`.
|
||||
balance: 0u64,
|
||||
gates: 0u64,
|
||||
amount: r1,
|
||||
};
|
||||
}
|
||||
@ -24,5 +24,5 @@ function main(x: address) -> u64 {
|
||||
const c: u64 = 1u64;
|
||||
let t: Token = mint(x, c);
|
||||
|
||||
return t.balance;
|
||||
return t.gates;
|
||||
}
|
@ -6,7 +6,7 @@ expectation: Fail
|
||||
// This record does not define the `owner` variable required for a record type.
|
||||
record Token {
|
||||
// The Aleo balance (in gates).
|
||||
balance: u64,
|
||||
gates: u64,
|
||||
// The token amount.
|
||||
amount: u64,
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ expectation: Fail
|
||||
|
||||
// This record does define the `owner` variable but with the wrong type.
|
||||
record Token {
|
||||
balance: u64,
|
||||
gates: u64,
|
||||
owner: bool,
|
||||
}
|
||||
|
||||
|
@ -2,4 +2,4 @@
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372026]: The field `balance` in a `record` must have type `u64`.\n --> compiler-test:4:1\n |\n 4 | record Token {\n 5 | balance: address,\n 6 | owner: address,\n 7 | }\n | ^\n"
|
||||
- "Error [ETYC0372026]: The field `gates` in a `record` must have type `u64`.\n --> compiler-test:4:1\n |\n 4 | record Token {\n 5 | gates: address,\n 6 | owner: address,\n 7 | }\n | ^\n"
|
||||
|
@ -4,5 +4,5 @@ expectation: Pass
|
||||
outputs:
|
||||
- output:
|
||||
- initial_input_ast: no input
|
||||
initial_ast: 8851e3fca7aba773d056c8e621039899149e063b97ddcdb72f0d6edf6e478cec
|
||||
unrolled_ast: 8851e3fca7aba773d056c8e621039899149e063b97ddcdb72f0d6edf6e478cec
|
||||
initial_ast: d3fc93bb31bfa401b46f11f94b62c0e93ac0562b3481714f8007c4212c38d962
|
||||
unrolled_ast: d3fc93bb31bfa401b46f11f94b62c0e93ac0562b3481714f8007c4212c38d962
|
||||
|
@ -2,4 +2,4 @@
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372022]: Record Token defined with more than one variable with the same name.\n --> compiler-test:3:1\n |\n 3 | record Token {\n 4 | // The token owner.\n 5 | owner: address,\n 6 | // The token owner.\n 7 | owner: address, // Cannot define two record variables with the same name.\n 8 | // The Aleo balance (in gates).\n 9 | balance: u64,\n 10 | // The token amount.\n 11 | amount: u64,\n 12 | }\n | ^\n"
|
||||
- "Error [ETYC0372022]: Record Token defined with more than one variable with the same name.\n --> compiler-test:3:1\n |\n 3 | record Token {\n 4 | // The token owner.\n 5 | owner: address,\n 6 | // The token owner.\n 7 | owner: address, // Cannot define two record variables with the same name.\n 8 | // The Aleo balance (in gates).\n 9 | gates: u64,\n 10 | // The token amount.\n 11 | amount: u64,\n 12 | }\n | ^\n"
|
||||
|
@ -4,5 +4,5 @@ expectation: Pass
|
||||
outputs:
|
||||
- output:
|
||||
- initial_input_ast: no input
|
||||
initial_ast: a23dff220a2f3c10f4da7d7d82a6f89d6b08f891fcf855be57fc94f2e1bcd0d2
|
||||
unrolled_ast: a23dff220a2f3c10f4da7d7d82a6f89d6b08f891fcf855be57fc94f2e1bcd0d2
|
||||
initial_ast: b5bbd52e5b0b8df7da11ce894f6a886c0c8f496b4e2867a83d928ccf1a364559
|
||||
unrolled_ast: b5bbd52e5b0b8df7da11ce894f6a886c0c8f496b4e2867a83d928ccf1a364559
|
||||
|
@ -4,5 +4,5 @@ expectation: Pass
|
||||
outputs:
|
||||
- output:
|
||||
- initial_input_ast: no input
|
||||
initial_ast: 061045ddf1f31f10fca9dfadaf053debdd8ff013326bbbab7d1d812f135cb6ad
|
||||
unrolled_ast: 061045ddf1f31f10fca9dfadaf053debdd8ff013326bbbab7d1d812f135cb6ad
|
||||
initial_ast: 77be1e189be61ee77a278ccca5082e94e12d75eb2fbf4bda6c34ff8940a2656c
|
||||
unrolled_ast: 77be1e189be61ee77a278ccca5082e94e12d75eb2fbf4bda6c34ff8940a2656c
|
||||
|
@ -2,4 +2,4 @@
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372019]: Circuit initialization expression for `Token` is missing member `owner`.\n --> compiler-test:13:12\n |\n 13 | return Token {\n 14 | sender: r0, // This variable should be named `owner`.\n 15 | balance: 0u64,\n 16 | amount: r1,\n 17 | };\n | ^^^^^^\n"
|
||||
- "Error [ETYC0372019]: Circuit initialization expression for `Token` is missing member `owner`.\n --> compiler-test:13:12\n |\n 13 | return Token {\n 14 | sender: r0, // This variable should be named `owner`.\n 15 | gates: 0u64,\n 16 | amount: r1,\n 17 | };\n | ^^^^^^\n"
|
||||
|
@ -2,4 +2,4 @@
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372025]: The `record` type requires the variable `owner: address`.\n --> compiler-test:4:1\n |\n 4 | record Token {\n 5 | // The Aleo balance (in gates).\n 6 | balance: u64,\n 7 | // The token amount.\n 8 | amount: u64,\n 9 | }\n | ^\n"
|
||||
- "Error [ETYC0372025]: The `record` type requires the variable `owner: address`.\n --> compiler-test:4:1\n |\n 4 | record Token {\n 5 | // The Aleo balance (in gates).\n 6 | gates: u64,\n 7 | // The token amount.\n 8 | amount: u64,\n 9 | }\n | ^\n"
|
||||
|
@ -2,4 +2,4 @@
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372026]: The field `owner` in a `record` must have type `address`.\n --> compiler-test:4:1\n |\n 4 | record Token {\n 5 | balance: u64,\n 6 | owner: bool,\n 7 | }\n | ^\n"
|
||||
- "Error [ETYC0372026]: The field `owner` in a `record` must have type `address`.\n --> compiler-test:4:1\n |\n 4 | record Token {\n 5 | gates: u64,\n 6 | owner: bool,\n 7 | }\n | ^\n"
|
||||
|
Loading…
Reference in New Issue
Block a user