Skip to content

Commit

Permalink
Merge pull request #4 from ProvableHQ/feat/canary
Browse files Browse the repository at this point in the history
[Feature] Add `Canary` network
  • Loading branch information
d0cd authored Jul 9, 2024
2 parents 9743d56 + fb059e8 commit fb71e1c
Show file tree
Hide file tree
Showing 34 changed files with 22,221 additions and 91 deletions.
37 changes: 37 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[workspace]
resolver = "2"

members = [
"authorize-service",
"execute-service",
"client",
"block-parser",
]

[workspace.dependencies]
snarkvm = { git = "https://github.com/AleoNet/snarkVM.git", rev = "d170a9f" }

[profile.release]
opt-level = 3
lto = "thin"
incremental = true

[profile.bench]
opt-level = 3
debug = false
rpath = false
lto = "thin"
incremental = true
debug-assertions = false

[profile.dev]
opt-level = 3
lto = "thin"
incremental = true

[profile.test]
opt-level = 3
lto = "thin"
incremental = true
debug = true
debug-assertions = true
28 changes: 1 addition & 27 deletions authorize-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ version = "1.0.190"
version = "1.0.117"

[dependencies.snarkvm]
git = "https://github.com/AleoHQ/snarkVM.git"
rev = "140ff26"
workspace = true

[dependencies.structopt]
version = "0.3.26"
Expand All @@ -56,28 +55,3 @@ version = "0.3.6"

[dev-dependencies.criterion]
version = "0.5.1"

[profile.release]
opt-level = 3
lto = "thin"
incremental = true

[profile.bench]
opt-level = 3
debug = false
rpath = false
lto = "thin"
incremental = true
debug-assertions = false

[profile.dev]
opt-level = 3
lto = "thin"
incremental = true

[profile.test]
opt-level = 3
lto = "thin"
incremental = true
debug = true
debug-assertions = true
14 changes: 7 additions & 7 deletions authorize-service/src/authorize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use super::*;

// Initialize a thread-local `ProcessVariant`.
thread_local! {
pub static PROCESS: RefCell<Option<ProcessVariant>> = RefCell::new(None);
pub static PROCESS: RefCell<Option<ProcessVariant>> = const { RefCell::new(None) };
}

pub fn authorize<N: Network>(bytes: Bytes) -> Result<Value> {
Expand All @@ -28,15 +28,15 @@ pub fn authorize<N: Network>(bytes: Bytes) -> Result<Value> {
*process.borrow_mut() = match N::ID {
MainnetV0::ID => {
println!("Loading mainnet process...");
Some(ProcessVariant::MainnetV0(
Process::load().expect("Failed to load mainnet process"),
))
Some(ProcessVariant::MainnetV0(Process::load()?))
}
TestnetV0::ID => {
println!("Loading testnet process...");
Some(ProcessVariant::TestnetV0(
Process::load().expect("Failed to load testnet process"),
))
Some(ProcessVariant::TestnetV0(Process::load()?))
}
CanaryV0::ID => {
println!("Loading canary process...");
Some(ProcessVariant::CanaryV0(Process::load()?))
}
_ => panic!("Invalid network"),
};
Expand Down
6 changes: 3 additions & 3 deletions authorize-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ pub use routes::*;
pub mod signature;
pub use signature::*;

use snarkvm::circuit::{Aleo, AleoTestnetV0, AleoV0};
use snarkvm::circuit::{Aleo, AleoCanaryV0, AleoTestnetV0, AleoV0};
use snarkvm::prelude::{
Address, Authorization, Deserialize, Environment, Field, MainnetV0, Network, PrivateKey,
Process, Serialize, Signature, TestnetV0, ToBytes,
Address, Authorization, CanaryV0, Deserialize, Environment, Field, MainnetV0, Network,
PrivateKey, Process, Serialize, Signature, TestnetV0, ToBytes,
};

use anyhow::Result;
Expand Down
3 changes: 2 additions & 1 deletion authorize-service/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with the Aleo SDK library. If not, see <https://www.gnu.org/licenses/>.

use authorize_service::*;
use snarkvm::prelude::{MainnetV0, Network, TestnetV0};
use snarkvm::prelude::{CanaryV0, MainnetV0, Network, TestnetV0};

use structopt::StructOpt;
use warp::Filter;
Expand Down Expand Up @@ -49,6 +49,7 @@ async fn main() {
match opt.network.as_str() {
"mainnet" => run::<MainnetV0>(opt.port).await,
"testnet" => run::<TestnetV0>(opt.port).await,
"canary" => run::<CanaryV0>(opt.port).await,
_ => panic!("Invalid network"),
}
}
4 changes: 4 additions & 0 deletions authorize-service/src/process_variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use super::*;
pub enum ProcessVariant {
MainnetV0(Process<MainnetV0>),
TestnetV0(Process<TestnetV0>),
CanaryV0(Process<CanaryV0>),
}

impl ProcessVariant {
Expand All @@ -30,6 +31,9 @@ impl ProcessVariant {
ProcessVariant::TestnetV0(process) => {
Self::handle_authorize::<AleoTestnetV0, TestnetV0>(process, bytes)
}
ProcessVariant::CanaryV0(process) => {
Self::handle_authorize::<AleoCanaryV0, CanaryV0>(process, bytes)
}
}
}

Expand Down
157 changes: 157 additions & 0 deletions block-parser/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# Created by https://www.toptal.com/developers/gitignore/api/git,rust,intellij+all,macos
# Edit at https://www.toptal.com/developers/gitignore?templates=git,rust,intellij+all,macos

### Git ###
# Created by git for backups. To disable backups in Git:
# $ git config --global mergetool.keepBackup false
*.orig

# Created by git when using merge tools for conflicts
*.BACKUP.*
*.BASE.*
*.LOCAL.*
*.REMOTE.*
*_BACKUP_*.txt
*_BASE_*.txt
*_LOCAL_*.txt
*_REMOTE_*.txt

### Intellij+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf


# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Intellij+all Patch ###
# Ignore everything but code style settings and run configurations
# that are supposed to be shared within teams.

.idea/*

!.idea/codeStyles
!.idea/runConfigurations

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

### Rust ###
# Generated by Cargo
# will have compiled files and executables
debug/
target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# End of https://www.toptal.com/developers/gitignore/api/git,rust,intellij+all,macos
17 changes: 17 additions & 0 deletions block-parser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "block-parser"
version = "0.1.0"
edition = "2021"

[lib]
name = "block_parser"
path = "src/lib.rs"

[dependencies.serde_json]
version = "1.0.117"

[dependencies.snarkvm]
workspace = true
[dependencies]
anyhow = "1.0.86"
serde = { version = "1.0.203", features = ["derive"] }
Loading

0 comments on commit fb71e1c

Please sign in to comment.