Merge branch 'mainnet' into testnet-beta

This commit is contained in:
Pranav Gaddamadugu 2024-06-23 10:42:00 -07:00
commit 1bb337300b
8 changed files with 149 additions and 82 deletions

76
Cargo.lock generated
View File

@ -686,16 +686,15 @@ dependencies = [
[[package]]
name = "curve25519-dalek"
version = "4.1.2"
version = "4.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348"
checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be"
dependencies = [
"cfg-if",
"cpufeatures",
"curve25519-dalek-derive",
"digest",
"fiat-crypto",
"platforms",
"rustc_version",
"subtle",
"zeroize",
@ -1283,6 +1282,23 @@ dependencies = [
"want",
]
[[package]]
name = "hyper-rustls"
version = "0.27.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155"
dependencies = [
"futures-util",
"http 1.1.0",
"hyper 1.3.1",
"hyper-util",
"rustls 0.23.10",
"rustls-pki-types",
"tokio",
"tokio-rustls",
"tower-service",
]
[[package]]
name = "hyper-tls"
version = "0.5.0"
@ -1526,7 +1542,7 @@ dependencies = [
"colored",
"derivative",
"leo-span",
"reqwest 0.12.4",
"reqwest 0.12.5",
"serde",
"thiserror",
]
@ -1559,7 +1575,7 @@ dependencies = [
"rand",
"rand_chacha",
"rand_core",
"reqwest 0.12.4",
"reqwest 0.12.5",
"rpassword",
"rusty-hook",
"self_update 0.40.0",
@ -2069,12 +2085,6 @@ version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
[[package]]
name = "platforms"
version = "3.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7"
[[package]]
name = "plotters"
version = "0.3.6"
@ -2317,7 +2327,7 @@ dependencies = [
"serde",
"serde_json",
"serde_urlencoded",
"sync_wrapper",
"sync_wrapper 0.1.2",
"system-configuration",
"tokio",
"tokio-native-tls",
@ -2331,9 +2341,9 @@ dependencies = [
[[package]]
name = "reqwest"
version = "0.12.4"
version = "0.12.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10"
checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37"
dependencies = [
"base64 0.22.1",
"bytes",
@ -2346,6 +2356,7 @@ dependencies = [
"http-body 1.0.0",
"http-body-util",
"hyper 1.3.1",
"hyper-rustls",
"hyper-tls 0.6.0",
"hyper-util",
"ipnet",
@ -2361,7 +2372,7 @@ dependencies = [
"serde",
"serde_json",
"serde_urlencoded",
"sync_wrapper",
"sync_wrapper 1.0.1",
"system-configuration",
"tokio",
"tokio-native-tls",
@ -2451,6 +2462,19 @@ dependencies = [
"zeroize",
]
[[package]]
name = "rustls"
version = "0.23.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05cff451f60db80f490f3c182b77c35260baace73209e9cdbbe526bfe3a4d402"
dependencies = [
"once_cell",
"rustls-pki-types",
"rustls-webpki",
"subtle",
"zeroize",
]
[[package]]
name = "rustls-pemfile"
version = "1.0.4"
@ -2614,7 +2638,7 @@ dependencies = [
"log",
"quick-xml",
"regex",
"reqwest 0.12.4",
"reqwest 0.12.5",
"self-replace",
"semver",
"serde_json",
@ -3719,6 +3743,12 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
[[package]]
name = "sync_wrapper"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394"
[[package]]
name = "synom"
version = "0.11.3"
@ -3894,7 +3924,6 @@ dependencies = [
"bytes",
"libc",
"mio",
"num_cpus",
"pin-project-lite",
"socket2",
"windows-sys 0.48.0",
@ -3910,6 +3939,17 @@ dependencies = [
"tokio",
]
[[package]]
name = "tokio-rustls"
version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4"
dependencies = [
"rustls 0.23.10",
"rustls-pki-types",
"tokio",
]
[[package]]
name = "tokio-util"
version = "0.7.11"
@ -4120,7 +4160,7 @@ dependencies = [
"flate2",
"log",
"once_cell",
"rustls",
"rustls 0.22.4",
"rustls-pki-types",
"rustls-webpki",
"serde",

View File

@ -137,7 +137,7 @@ default-features = false
version = "0.6.4"
[dependencies.reqwest]
version = "0.12.4"
version = "0.12.5"
features = [ "blocking", "json", "multipart" ]
[dependencies.self_update]

View File

@ -16,7 +16,7 @@
//! The tokenizer to convert Leo code text into tokens.
//!
//! This module contains the [`tokenize()`] method which breaks down string text into tokens,
//! This module contains the [`tokenize()`] function, which breaks down string text into tokens,
//! optionally separated by whitespace.
pub(crate) mod token;

View File

@ -14,25 +14,38 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use leo_span::{sym, Symbol};
use serde::{Deserialize, Serialize};
use std::fmt;
use serde::{Deserialize, Serialize};
use leo_span::{sym, Symbol};
/// Represents all valid Leo syntax tokens.
///
/// The notion of 'token' here is a bit more general than in the ABNF grammar:
/// since it includes comments and whitespace,
/// it corresponds to the notion of 'lexeme' in the ABNF grammar.
/// There are also a few other differences, noted in comments below.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum Token {
// Lexical Grammar
// Literals
// Comments
CommentLine(String),
CommentBlock(String),
StaticString(String),
Identifier(Symbol),
Integer(String),
// Whitespace (we do not distinguish among different kinds here)
WhiteSpace,
// Literals (= atomic literals and numerals in the ABNF grammar)
// The string in Integer(String) consists of digits optionally followed by a type
// The string in AddressLit(String) has the form `aleo1...`
True,
False,
Integer(String), // = numeric literal or numeral in the ABNF grammar
AddressLit(String),
WhiteSpace,
StaticString(String),
// Identifiers
Identifier(Symbol),
// Symbols
Not,
@ -44,6 +57,8 @@ pub enum Token {
BitAndAssign,
BitOr,
BitOrAssign,
BitXor,
BitXorAssign,
Eq,
NotEq,
Lt,
@ -62,6 +77,10 @@ pub enum Token {
PowAssign,
Rem,
RemAssign,
Shl,
ShlAssign,
Shr,
ShrAssign,
Assign,
LeftParen,
RightParen,
@ -78,42 +97,39 @@ pub enum Token {
Question,
Arrow,
BigArrow,
Shl,
ShlAssign,
Shr,
ShrAssign,
Underscore,
BitXor,
BitXorAssign,
At,
// There is no symbol for `)group` here (unlike the ABNF grammar),
// because we handle that differently in the lexer.
// Syntactic Grammar
// Types
// Type keywords
Address,
Bool,
Field,
Group,
Scalar,
Signature,
String,
I8,
I16,
I32,
I64,
I128,
Record,
Scalar,
Signature,
String,
Struct,
U8,
U16,
U32,
U64,
U128,
Record,
// Regular Keywords
// Other keywords
As,
Assert,
AssertEq,
AssertNeq,
Async,
Block,
Console,
Const,
Constant,
@ -130,26 +146,23 @@ pub enum Token {
Mapping,
Private,
Program,
// Public inputs.
Public,
Return,
SelfLower,
Struct,
Transition,
// Meta Tokens
// Meta tokens
Aleo,
Block,
Eof,
Leo,
Network,
}
/// Represents all valid Leo keyword tokens.
/// This differs from the ABNF grammar for the following reasons:
/// Adding true and false to the keywords of the ABNF grammar makes the lexical grammar ambiguous,
/// because true and false are also boolean literals, which are different tokens from keywords.
/// This also includes the boolean literals `true` and `false`,
/// unlike the ABNF grammar, which classifies them as literals and not keywords.
/// But for the purposes of our lexer implementation,
/// it is fine to include the boolean literals in this list.
pub const KEYWORD_TOKENS: &[Token] = &[
Token::Address,
Token::Aleo,
@ -187,9 +200,9 @@ pub const KEYWORD_TOKENS: &[Token] = &[
Token::Public,
Token::Record,
Token::Return,
Token::Scalar,
Token::SelfLower,
Token::Signature,
Token::Scalar,
Token::String,
Token::Struct,
Token::Transition,
@ -268,13 +281,16 @@ impl fmt::Display for Token {
match self {
CommentLine(s) => write!(f, "{s}"),
CommentBlock(s) => write!(f, "{s}"),
StaticString(s) => write!(f, "\"{s}\""),
Identifier(s) => write!(f, "{s}"),
Integer(s) => write!(f, "{s}"),
WhiteSpace => write!(f, "whitespace"),
True => write!(f, "true"),
False => write!(f, "false"),
Integer(s) => write!(f, "{s}"),
AddressLit(s) => write!(f, "{s}"),
WhiteSpace => write!(f, "whitespace"),
StaticString(s) => write!(f, "\"{s}\""),
Identifier(s) => write!(f, "{s}"),
Not => write!(f, "!"),
And => write!(f, "&&"),
@ -285,6 +301,8 @@ impl fmt::Display for Token {
BitAndAssign => write!(f, "&="),
BitOr => write!(f, "|"),
BitOrAssign => write!(f, "|="),
BitXor => write!(f, "^"),
BitXorAssign => write!(f, "^="),
Eq => write!(f, "=="),
NotEq => write!(f, "!="),
Lt => write!(f, "<"),
@ -303,6 +321,10 @@ impl fmt::Display for Token {
PowAssign => write!(f, "**="),
Rem => write!(f, "%"),
RemAssign => write!(f, "%="),
Shl => write!(f, "<<"),
ShlAssign => write!(f, "<<="),
Shr => write!(f, ">>"),
ShrAssign => write!(f, ">>="),
Assign => write!(f, "="),
LeftParen => write!(f, "("),
RightParen => write!(f, ")"),
@ -319,40 +341,35 @@ impl fmt::Display for Token {
Question => write!(f, "?"),
Arrow => write!(f, "->"),
BigArrow => write!(f, "=>"),
Shl => write!(f, "<<"),
ShlAssign => write!(f, "<<="),
Shr => write!(f, ">>"),
ShrAssign => write!(f, ">>="),
Underscore => write!(f, "_"),
BitXor => write!(f, "^"),
BitXorAssign => write!(f, "^="),
At => write!(f, "@"),
Address => write!(f, "address"),
Bool => write!(f, "bool"),
Field => write!(f, "field"),
Group => write!(f, "group"),
Scalar => write!(f, "scalar"),
Signature => write!(f, "signature"),
String => write!(f, "string"),
I8 => write!(f, "i8"),
I16 => write!(f, "i16"),
I32 => write!(f, "i32"),
I64 => write!(f, "i64"),
I128 => write!(f, "i128"),
Record => write!(f, "record"),
Scalar => write!(f, "scalar"),
Signature => write!(f, "signature"),
String => write!(f, "string"),
Struct => write!(f, "struct"),
U8 => write!(f, "u8"),
U16 => write!(f, "u16"),
U32 => write!(f, "u32"),
U64 => write!(f, "u64"),
U128 => write!(f, "u128"),
Record => write!(f, "record"),
Aleo => write!(f, "aleo"),
As => write!(f, "as"),
Assert => write!(f, "assert"),
AssertEq => write!(f, "assert_eq"),
AssertNeq => write!(f, "assert_neq"),
Async => write!(f, "async"),
Block => write!(f, "block"),
Console => write!(f, "console"),
Const => write!(f, "const"),
Constant => write!(f, "constant"),
@ -372,11 +389,11 @@ impl fmt::Display for Token {
Public => write!(f, "public"),
Return => write!(f, "return"),
SelfLower => write!(f, "self"),
Struct => write!(f, "struct"),
Transition => write!(f, "transition"),
Block => write!(f, "block"),
Leo => write!(f, "leo"),
Aleo => write!(f, "aleo"),
Eof => write!(f, "<eof>"),
Leo => write!(f, "leo"),
Network => write!(f, "network"),
}
}

View File

@ -14,6 +14,16 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
//! The source map provides an address space for positions in spans
//! that is global across the source files that are compiled together.
//! The source files are organized in a sequence,
//! with the positions of each source following the ones of the previous source
//! in the address space of positions
//! (except for the first source, which starts at the beginning of the address space).
//! This way, any place in any source is identified by a single position
//! within the address space covered by the sequence of sources;
//! the source file is determined from the position.
use crate::span::{BytePos, CharPos, Pos, Span};
use std::{
cell::RefCell,
@ -84,7 +94,7 @@ impl SourceMap {
Some(LineCol { source_file, line, col })
}
/// Retrieves the location (source file, line, col) on the given span.
/// Retrieves the location (source file, lines, columns) on the given span.
pub fn span_to_location(&self, sp: Span) -> Option<SpanLocation> {
let lo = self.find_line_col(sp.lo)?;
let hi = self.find_line_col(sp.hi)?;
@ -156,8 +166,8 @@ impl SourceMapInner {
/// A file name.
///
/// For now it's simply a wrapper around `PathBuf`,
/// but may become more complicated in the future.
/// This is either a wrapper around `PathBuf`,
/// or a custom string description.
#[derive(Clone)]
pub enum FileName {
/// A real file.
@ -198,7 +208,7 @@ pub struct SourceFile {
}
impl SourceFile {
/// Creates a new `SourceMap` given the file `name`,
/// Creates a new `SourceFile` given the file `name`,
/// source contents, and the `start_pos`ition.
///
/// This position is used for analysis purposes.
@ -233,7 +243,7 @@ impl SourceFile {
/// Finds the line containing the given position. The return value is the
/// index into the `lines` array of this `SourceFile`, not the 1-based line
/// number. If the source_file is empty or the position is located before the
/// number. If the source file is empty or the position is located before the
/// first line, `None` is returned.
fn lookup_line(&self, pos: BytePos) -> Option<usize> {
match self.lines.binary_search(&pos) {
@ -324,7 +334,7 @@ fn remove_bom(src: &mut String) {
/// Replaces `\r\n` with `\n` in-place in `src`.
///
/// Returns error if there's a lone `\r` in the string.
/// Isolated carriage returns are left alone.
fn normalize_newlines(src: &mut String) {
if !src.as_bytes().contains(&b'\r') {
return;

View File

@ -50,7 +50,7 @@ impl<'de> Visitor<'de> for SpanMapVisitor {
type Value = Span;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str("Mapping from `span` keyword to span information")
formatter.write_str("mapping from `span` keyword to span information")
}
fn visit_map<M: MapAccess<'de>>(self, mut access: M) -> Result<Self::Value, M::Error> {

View File

@ -31,7 +31,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::cell::RefCell;
/// A helper for `symbols` defined below.
/// The macro's job is to bind conveniently usable `const` items to the symbol names provided.
/// The macro's job is to bind conveniently usable `const` items to the symbol names provided.
/// For example, with `symbol { a, b }` you'd have `sym::a` and `sym::b`.
macro_rules! consts {
($val: expr, $sym:ident $(,)?) => {
@ -52,7 +52,7 @@ macro_rules! consts {
}
/// A helper for `symbols` defined below.
/// The macro's job is to merge all the hard coded strings into a single array of strings.
/// The macro's job is to merge all the hard-coded strings into a single array of strings.
/// The strategy applied is [push-down accumulation](https://danielkeep.github.io/tlborm/book/pat-push-down-accumulation.html).
macro_rules! strings {
// Final step 0) in the push-down accumulation.
@ -83,12 +83,12 @@ macro_rules! strings {
}
/// Creates predefined symbols used throughout the Leo compiler and language.
/// Broadly speaking, any hard coded string in the compiler should be defined here.
/// Broadly speaking, any hard-coded string in the compiler should be defined here.
///
/// The macro accepts symbols separated by commas,
/// and a symbol is either specified as a Rust identifier, in which case it is `stringify!`ed,
/// or as `ident: "string"` where `"string"` is the actual hard coded string.
/// The latter case can be used when the hard coded string is not a valid identifier.
/// or as `ident: "string"` where `"string"` is the actual hard-coded string.
/// The latter case can be used when the hard-coded string is not a valid identifier.
/// In either case, a `const $ident: Symbol` will be created that you can access as `sym::$ident`.
macro_rules! symbols {
($($symbols:tt)*) => {

View File

@ -38,7 +38,7 @@ version = "0.6.1"
version = "2.2.0"
[dependencies.reqwest]
version = "0.12.4"
version = "0.12.5"
[dependencies.serde]
version = "1.0.203"