Skip to content

Commit

Permalink
commit execute and transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
collinc97 committed Nov 21, 2023
1 parent 2df34d6 commit 66bb46b
Show file tree
Hide file tree
Showing 15 changed files with 1,644 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

596 changes: 596 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

157 changes: 157 additions & 0 deletions execute-service/.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
80 changes: 80 additions & 0 deletions execute-service/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
[package]
name = "execute-service"
version = "0.1.0"
edition = "2021"

[[bin]]
name = "execute-service"
path = "src/main.rs"
bench = false

[dependencies.anyhow]
version = "1.0.75"

[dependencies.async-trait]
version = "0.1.74"

[dependencies.log]
version = "0.4.20"

[dependencies.pretty_env_logger]
version = "0.5.0"

[dependencies.rand]
version = "0.8.5"

[dependencies.rayon]
version = "1.8.0"

[dependencies.serde]
version = "1.0.190"

[dependencies.snarkvm]
version = "0.16.6"

[dependencies.structopt]
version = "0.3.26"

[dependencies.thread_local]
version = "1.1.7"

[dependencies.tokio]
version = "1.33.0"
features = [ "full" ]

[dependencies.tokio-rayon]
version = "2.1.0"

[dependencies.tracing]
version = "0.1.40"

[dependencies.warp]
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
85 changes: 85 additions & 0 deletions execute-service/benches/benchmarks.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// Copyright (C) 2019-2023 Aleo Systems Inc.
// This file is part of the Aleo SDK library.

// The Aleo SDK library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// The Aleo SDK library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with the Aleo SDK library. If not, see <https://www.gnu.org/licenses/>.

#[macro_use]
extern crate criterion;

use criterion::{BatchSize, Criterion};
use snarkvm::circuit::AleoV0;
use snarkvm::prelude::{
Address, FromBytes, Identifier, Literal, PrivateKey, Process, ProgramID, Signature, Value, U64,
};
use std::str::FromStr;

use execute_service::{CurrentNetwork, execute, ExecuteRequest};

fn bench_execute_transfer_public(c: &mut Criterion) {
let process = Process::<CurrentNetwork>::load().unwrap();
let private_key =
PrivateKey::from_str("APrivateKey1zkpCE9rCw9SixY82xaDrW2Hwxc2f3VjeuR2oZHR81zcuUDV")
.unwrap();
let program_id = "credits.aleo";
let function_name = "transfer_public";
let inputs = vec![
Value::<CurrentNetwork>::from(Literal::Address(
Address::from_str("aleo1zcsyu7wfrdp4n6gq752p3np45sat9d6zun2uhjer2h4skccsgsgq7ndrnj")
.unwrap(),
)),
Value::from(Literal::U64(U64::new(100))),
];
let rng = &mut rand::thread_rng();

let function_authorization = process
.authorize::<AleoV0, _>(
&private_key,
program_id,
function_name,
inputs.iter(),
rng,
)
.unwrap();

// Retrieve the execution ID.
let execution_id = execute_authorization.to_execution_id().unwrap();

let fee_authorization = process.authorize_fee_public(
&private_key,
100000,
1000,
execution_id,
rng,
).unwrap();

let request = ExecuteRequest {
function_authorization: (),
fee_authorization: (),
state_root: None,
state_path: None,
};
c.bench_function("authorize_transfer_public", |b| {
b.iter_batched(
|| request.clone(),
|request| authorize(request).unwrap(),
BatchSize::SmallInput,
)
});
}
criterion_group! {
name = routes;
config = Criterion::default();
targets = bench_execute_transfer_public,
}
criterion_main!(routes);
Loading

0 comments on commit 66bb46b

Please sign in to comment.