Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions console/network/src/canary_v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ lazy_static! {
map
};

pub static ref CANARY_CREDITS_V1_PROVING_KEYS: IndexMap<String, Arc<VarunaProvingKey<Console>>> = {
let mut map = IndexMap::new();
snarkvm_parameters::insert_canary_credit_v1_keys!(map, VarunaProvingKey<Console>, Prover);
map
};
pub static ref CANARY_CREDITS_V1_VERIFYING_KEYS: IndexMap<String, Arc<VarunaVerifyingKey<Console>>> = {
let mut map = IndexMap::new();
snarkvm_parameters::insert_canary_credit_v1_keys!(map, VarunaVerifyingKey<Console>, Verifier);
map
};

pub static ref CANARY_CREDITS_PROVING_KEYS: IndexMap<String, Arc<VarunaProvingKey<Console>>> = {
let mut map = IndexMap::new();
snarkvm_parameters::insert_canary_credit_keys!(map, VarunaProvingKey<Console>, Prover);
Expand Down Expand Up @@ -225,6 +236,20 @@ impl Network for CanaryV0 {
.ok_or_else(|| anyhow!("Verifying key (v0) for credits_v0.aleo/{function_name}' not found"))
}

/// Returns the proving key for the given function name in the v1 version of `credits.aleo`.
fn get_credits_v1_proving_key(function_name: String) -> Result<&'static Arc<VarunaProvingKey<Self>>> {
CANARY_CREDITS_V1_PROVING_KEYS
.get(&function_name)
.ok_or_else(|| anyhow!("Proving key (v0) for credits.aleo/{function_name}' not found"))
}

/// Returns the verifying key for the given function name in the v1 version of `credits.aleo`.
fn get_credits_v1_verifying_key(function_name: String) -> Result<&'static Arc<VarunaVerifyingKey<Self>>> {
CANARY_CREDITS_V1_VERIFYING_KEYS
.get(&function_name)
.ok_or_else(|| anyhow!("Verifying key (v0) for credits_v0.aleo/{function_name}' not found"))
Comment on lines +243 to +250
}

/// Returns the proving key for the given function name in `credits.aleo`.
fn get_credits_proving_key(function_name: String) -> Result<&'static Arc<VarunaProvingKey<Self>>> {
CANARY_CREDITS_PROVING_KEYS
Expand Down
5 changes: 3 additions & 2 deletions console/network/src/consensus_heights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ pub enum ConsensusVersion {
/// Introduces `aleo::GENERATOR`, `aleo::GENERATOR_POWERS`, `snark.verify` opcodes,
/// and dynamic dispatch, and identifier literal types.
V14 = 14,
/// V15: Introduces the record-existence check and `commit.*.raw` instruction variants.
/// Increase the anchor time to 35.
/// V15: Introduces the record-existence check, `commit.*.raw` instruction variants,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: depending on when this gets merged, likely needs to be updated

/// and `redelegate` to `credits.aleo`
/// Increase the anchor time to 35 and updates the unbonding period.
V15 = 15,
}

Expand Down
7 changes: 6 additions & 1 deletion console/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ mod mainnet_v0;
pub use mainnet_v0::*;

mod testnet_v0;

pub use testnet_v0::*;

pub mod prelude {
Expand Down Expand Up @@ -371,6 +370,12 @@ pub trait Network:
/// Returns the verifying key for the given function name in the v0 version of `credits.aleo`.
fn get_credits_v0_verifying_key(function_name: String) -> Result<&'static Arc<VarunaVerifyingKey<Self>>>;

/// Returns the proving key for the given function name in the V1 version of `credits.aleo`.
fn get_credits_v1_proving_key(function_name: String) -> Result<&'static Arc<VarunaProvingKey<Self>>>;

/// Returns the verifying key for the given function name in the V1 version of `credits.aleo`.
fn get_credits_v1_verifying_key(function_name: String) -> Result<&'static Arc<VarunaVerifyingKey<Self>>>;

/// Returns the proving key for the given function name in `credits.aleo`.
fn get_credits_proving_key(function_name: String) -> Result<&'static Arc<VarunaProvingKey<Self>>>;

Expand Down
26 changes: 26 additions & 0 deletions console/network/src/mainnet_v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ lazy_static! {
/// The Poseidon path hasher for dynamic records, using a rate of 2.
pub static ref DYNAMIC_RECORD_PATH_HASHER: Poseidon2<MainnetV0> = Poseidon2::<MainnetV0>::setup("DynamicRecordPathHasher").expect("Failed to setup DynamicRecordPathHasher");

// TODO (raychu86): Determine if we can optimize by clearing from lazy_static after they are no longer necessary.
pub static ref CREDITS_V0_PROVING_KEYS: IndexMap<String, Arc<VarunaProvingKey<Console>>> = {
let mut map = IndexMap::new();
snarkvm_parameters::insert_credit_v0_keys!(map, VarunaProvingKey<Console>, Prover);
Expand All @@ -86,6 +87,17 @@ lazy_static! {
map
};

pub static ref CREDITS_V1_PROVING_KEYS: IndexMap<String, Arc<VarunaProvingKey<Console>>> = {
let mut map = IndexMap::new();
snarkvm_parameters::insert_credit_v1_keys!(map, VarunaProvingKey<Console>, Prover);
map
};
pub static ref CREDITS_V1_VERIFYING_KEYS: IndexMap<String, Arc<VarunaVerifyingKey<Console>>> = {
let mut map = IndexMap::new();
snarkvm_parameters::insert_credit_v1_keys!(map, VarunaVerifyingKey<Console>, Verifier);
map
};

pub static ref CREDITS_PROVING_KEYS: IndexMap<String, Arc<VarunaProvingKey<Console>>> = {
let mut map = IndexMap::new();
snarkvm_parameters::insert_credit_keys!(map, VarunaProvingKey<Console>, Prover);
Expand Down Expand Up @@ -230,6 +242,20 @@ impl Network for MainnetV0 {
.ok_or_else(|| anyhow!("Verifying key (v0) for credits_v0.aleo/{function_name}' not found"))
}

/// Returns the proving key for the given function name in the v1 version of `credits.aleo`.
fn get_credits_v1_proving_key(function_name: String) -> Result<&'static Arc<VarunaProvingKey<Self>>> {
CREDITS_V1_PROVING_KEYS
.get(&function_name)
.ok_or_else(|| anyhow!("Proving key for credits.aleo/{function_name}' not found"))
}

/// Returns the verifying key for the given function name in the v1 version of `credits.aleo`.
fn get_credits_v1_verifying_key(function_name: String) -> Result<&'static Arc<VarunaVerifyingKey<Self>>> {
CREDITS_V1_VERIFYING_KEYS
.get(&function_name)
.ok_or_else(|| anyhow!("Verifying key for credits.aleo/{function_name}' not found"))
Comment on lines +249 to +256
}

/// Returns the proving key for the given function name in `credits.aleo`.
fn get_credits_proving_key(function_name: String) -> Result<&'static Arc<VarunaProvingKey<Self>>> {
CREDITS_PROVING_KEYS
Expand Down
25 changes: 25 additions & 0 deletions console/network/src/testnet_v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ lazy_static! {
map
};

pub static ref TESTNET_CREDITS_V1_PROVING_KEYS: IndexMap<String, Arc<VarunaProvingKey<Console>>> = {
let mut map = IndexMap::new();
snarkvm_parameters::insert_testnet_credit_v1_keys!(map, VarunaProvingKey<Console>, Prover);
map
};
pub static ref TESTNET_CREDITS_V1_VERIFYING_KEYS: IndexMap<String, Arc<VarunaVerifyingKey<Console>>> = {
let mut map = IndexMap::new();
snarkvm_parameters::insert_testnet_credit_v1_keys!(map, VarunaVerifyingKey<Console>, Verifier);
map
};

pub static ref TESTNET_CREDITS_PROVING_KEYS: IndexMap<String, Arc<VarunaProvingKey<Console>>> = {
let mut map = IndexMap::new();
snarkvm_parameters::insert_testnet_credit_keys!(map, VarunaProvingKey<Console>, Prover);
Expand Down Expand Up @@ -225,6 +236,20 @@ impl Network for TestnetV0 {
.ok_or_else(|| anyhow!("Verifying key (v0) for credits_v0.aleo/{function_name}' not found"))
}

/// Returns the proving key for the given function name in the v1 version of `credits.aleo`.
fn get_credits_v1_proving_key(function_name: String) -> Result<&'static Arc<VarunaProvingKey<Self>>> {
TESTNET_CREDITS_V1_PROVING_KEYS
.get(&function_name)
.ok_or_else(|| anyhow!("Proving key (v0) for credits.aleo/{function_name}' not found"))
}

/// Returns the verifying key for the given function name in the v1 version of `credits.aleo`.
fn get_credits_v1_verifying_key(function_name: String) -> Result<&'static Arc<VarunaVerifyingKey<Self>>> {
TESTNET_CREDITS_V1_VERIFYING_KEYS
.get(&function_name)
.ok_or_else(|| anyhow!("Verifying key (v0) for credits_v0.aleo/{function_name}' not found"))
Comment on lines +243 to +250
}

/// Returns the proving key for the given function name in `credits.aleo`.
fn get_credits_proving_key(function_name: String) -> Result<&'static Arc<VarunaProvingKey<Self>>> {
TESTNET_CREDITS_PROVING_KEYS
Expand Down
9 changes: 9 additions & 0 deletions ledger/block/src/transition/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,15 @@ impl<N: Network> Transition<N> {
&& self.program_id.to_string() == "credits.aleo"
&& self.function_name.to_string() == "upgrade"
}

/// Returns `true` if this is a `redelegate` transition.
#[inline]
pub fn is_redelegate(&self) -> bool {
self.inputs.len() == 1
&& self.outputs.len() == 1
&& self.program_id.to_string() == "credits.aleo"
&& self.function_name.to_string() == "redelegate"
}
}

impl<N: Network> Transition<N> {
Expand Down
6 changes: 5 additions & 1 deletion ledger/store/src/transaction/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,11 @@ impl<N: Network, D: DeploymentStorage<N>> DeploymentStore<N, D> {
// Insert `credits.aleo`, which is the default program.
let credits_id = ProgramID::from_str("credits.aleo")?;
storage.edition_map().insert(credits_id, 0)?;
storage.program_map().insert((credits_id, 0), Program::credits()?)?;
storage.program_map().insert((credits_id, 0), Program::credits_v0()?)?;
storage.edition_map().insert(credits_id, 1)?;
storage.program_map().insert((credits_id, 1), Program::credits_v1()?)?;
storage.edition_map().insert(credits_id, 2)?;
storage.program_map().insert((credits_id, 2), Program::credits()?)?;

// Return the deployment store.
Ok(Self { storage, _phantom: PhantomData })
Expand Down
85 changes: 53 additions & 32 deletions parameters/src/canary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,51 +21,59 @@ pub const RESTRICTIONS_LIST: &str = include_str!("./resources/restrictions.json"

const REMOTE_URLS: [&str; 2] = ["https://parameters.provable.com/canary", "https://s3.us-west-1.amazonaws.com/canary.parameters"];

// V2 Credits Keys

// Redelegate
impl_remote!(RedelegateProver, REMOTE_URLS, "resources/", "redelegate", "prover", "credits");
impl_local!(RedelegateVerifier, "resources/", "redelegate", "verifier", "credits");

// V1 and V2 Credits Keys

// BondPublic
impl_remote!(BondPublicProver, REMOTE_URLS, "resources/", "bond_public", "prover", "credits");
impl_local!(BondPublicVerifier, "resources/", "bond_public", "verifier", "credits");
impl_remote!(BondPublicProver, REMOTE_URLS, "resources/", "bond_public", "prover", "credits_v1");
impl_local!(BondPublicVerifier, "resources/", "bond_public", "verifier", "credits_v1");
// BondValidator
impl_remote!(BondValidatorProver, REMOTE_URLS, "resources/", "bond_validator", "prover", "credits");
impl_local!(BondValidatorVerifier, "resources/", "bond_validator", "verifier", "credits");
impl_remote!(BondValidatorProver, REMOTE_URLS, "resources/", "bond_validator", "prover", "credits_v1");
impl_local!(BondValidatorVerifier, "resources/", "bond_validator", "verifier", "credits_v1");
// UnbondPublic
impl_remote!(UnbondPublicProver, REMOTE_URLS, "resources/", "unbond_public", "prover", "credits");
impl_local!(UnbondPublicVerifier, "resources/", "unbond_public", "verifier", "credits");
impl_remote!(UnbondPublicProver, REMOTE_URLS, "resources/", "unbond_public", "prover", "credits_v1");
impl_local!(UnbondPublicVerifier, "resources/", "unbond_public", "verifier", "credits_v1");
// ClaimUnbondPublic
impl_remote!(ClaimUnbondPublicProver, REMOTE_URLS, "resources/", "claim_unbond_public", "prover", "credits");
impl_local!(ClaimUnbondPublicVerifier, "resources/", "claim_unbond_public", "verifier", "credits");
impl_remote!(ClaimUnbondPublicProver, REMOTE_URLS, "resources/", "claim_unbond_public", "prover", "credits_v1");
impl_local!(ClaimUnbondPublicVerifier, "resources/", "claim_unbond_public", "verifier", "credits_v1");
// SetValidatorState
impl_remote!(SetValidatorStateProver, REMOTE_URLS, "resources/", "set_validator_state", "prover", "credits");
impl_local!(SetValidatorStateVerifier, "resources/", "set_validator_state", "verifier", "credits");
impl_remote!(SetValidatorStateProver, REMOTE_URLS, "resources/", "set_validator_state", "prover", "credits_v1");
impl_local!(SetValidatorStateVerifier, "resources/", "set_validator_state", "verifier", "credits_v1");
// TransferPrivate
impl_remote!(TransferPrivateProver, REMOTE_URLS, "resources/", "transfer_private", "prover", "credits");
impl_local!(TransferPrivateVerifier, "resources/", "transfer_private", "verifier", "credits");
impl_remote!(TransferPrivateProver, REMOTE_URLS, "resources/", "transfer_private", "prover", "credits_v1");
impl_local!(TransferPrivateVerifier, "resources/", "transfer_private", "verifier", "credits_v1");
// TransferPublic
impl_remote!(TransferPublicProver, REMOTE_URLS, "resources/", "transfer_public", "prover", "credits");
impl_local!(TransferPublicVerifier, "resources/", "transfer_public", "verifier", "credits");
impl_remote!(TransferPublicProver, REMOTE_URLS, "resources/", "transfer_public", "prover", "credits_v1");
impl_local!(TransferPublicVerifier, "resources/", "transfer_public", "verifier", "credits_v1");
// TransferPublicAsSigner
impl_remote!(TransferPublicAsSignerProver, REMOTE_URLS, "resources/", "transfer_public_as_signer", "prover", "credits");
impl_local!(TransferPublicAsSignerVerifier, "resources/", "transfer_public_as_signer", "verifier", "credits");
impl_remote!(TransferPublicAsSignerProver, REMOTE_URLS, "resources/", "transfer_public_as_signer", "prover", "credits_v1");
impl_local!(TransferPublicAsSignerVerifier, "resources/", "transfer_public_as_signer", "verifier", "credits_v1");
// TransferPrivateToPublic
impl_remote!(TransferPrivateToPublicProver, REMOTE_URLS, "resources/", "transfer_private_to_public", "prover", "credits");
impl_local!(TransferPrivateToPublicVerifier, "resources/", "transfer_private_to_public", "verifier", "credits");
impl_remote!(TransferPrivateToPublicProver, REMOTE_URLS, "resources/", "transfer_private_to_public", "prover", "credits_v1");
impl_local!(TransferPrivateToPublicVerifier, "resources/", "transfer_private_to_public", "verifier", "credits_v1");
// TransferPublicToPrivate
impl_remote!(TransferPublicToPrivateProver, REMOTE_URLS, "resources/", "transfer_public_to_private", "prover", "credits");
impl_local!(TransferPublicToPrivateVerifier, "resources/", "transfer_public_to_private", "verifier", "credits");
impl_remote!(TransferPublicToPrivateProver, REMOTE_URLS, "resources/", "transfer_public_to_private", "prover", "credits_v1");
impl_local!(TransferPublicToPrivateVerifier, "resources/", "transfer_public_to_private", "verifier", "credits_v1");
// Join
impl_remote!(JoinProver, REMOTE_URLS, "resources/", "join", "prover", "credits");
impl_local!(JoinVerifier, "resources/", "join", "verifier", "credits");
impl_remote!(JoinProver, REMOTE_URLS, "resources/", "join", "prover", "credits_v1");
impl_local!(JoinVerifier, "resources/", "join", "verifier", "credits_v1");
// Split
impl_remote!(SplitProver, REMOTE_URLS, "resources/", "split", "prover", "credits");
impl_local!(SplitVerifier, "resources/", "split", "verifier", "credits");
impl_remote!(SplitProver, REMOTE_URLS, "resources/", "split", "prover", "credits_v1");
impl_local!(SplitVerifier, "resources/", "split", "verifier", "credits_v1");
// FeePrivate
impl_remote!(FeePrivateProver, REMOTE_URLS, "resources/", "fee_private", "prover", "credits");
impl_local!(FeePrivateVerifier, "resources/", "fee_private", "verifier", "credits");
impl_remote!(FeePrivateProver, REMOTE_URLS, "resources/", "fee_private", "prover", "credits_v1");
impl_local!(FeePrivateVerifier, "resources/", "fee_private", "verifier", "credits_v1");
// FeePublic
impl_remote!(FeePublicProver, REMOTE_URLS, "resources/", "fee_public", "prover", "credits");
impl_local!(FeePublicVerifier, "resources/", "fee_public", "verifier", "credits");
impl_remote!(FeePublicProver, REMOTE_URLS, "resources/", "fee_public", "prover", "credits_v1");
impl_local!(FeePublicVerifier, "resources/", "fee_public", "verifier", "credits_v1");
// Upgrade
impl_remote!(UpgradeProver, REMOTE_URLS, "resources/", "upgrade", "prover", "credits");
impl_local!(UpgradeVerifier, "resources/", "upgrade", "verifier", "credits");
impl_remote!(UpgradeProver, REMOTE_URLS, "resources/", "upgrade", "prover", "credits_v1");
impl_local!(UpgradeVerifier, "resources/", "upgrade", "verifier", "credits_v1");

// V0 Credits Keys

Expand Down Expand Up @@ -117,6 +125,17 @@ impl_local!(UpgradeV0Verifier, "resources/", "upgrade", "verifier", "credits_v0"

#[macro_export]
macro_rules! insert_canary_credit_keys {
($map:ident, $type:ident<$network:ident>, $variant:ident) => {{
paste::paste! {
let string = stringify!([<$variant:lower>]);
$crate::insert_canary_credit_v1_keys!($map, $type<$network>, $variant);
$crate::insert_canary_key!($map, string, $type<$network>, ("redelegate", $crate::canary::[<Redelegate $variant>]::load_bytes()));
}
}};
}

#[macro_export]
macro_rules! insert_canary_credit_v1_keys {
($map:ident, $type:ident<$network:ident>, $variant:ident) => {{
paste::paste! {
let string = stringify!([<$variant:lower>]);
Expand Down Expand Up @@ -178,8 +197,8 @@ macro_rules! insert_canary_key {
// Inclusion
impl_remote!(InclusionV0Prover, REMOTE_URLS, "resources/", "inclusion", "prover", "credits_v0");
impl_local!(InclusionV0Verifier, "resources/", "inclusion", "verifier", "credits_v0");
impl_remote!(InclusionProver, REMOTE_URLS, "resources/", "inclusion", "prover", "credits");
impl_local!(InclusionVerifier, "resources/", "inclusion", "verifier", "credits");
impl_remote!(InclusionProver, REMOTE_URLS, "resources/", "inclusion", "prover", "credits_v1");
impl_local!(InclusionVerifier, "resources/", "inclusion", "verifier", "credits_v1");

/// The function name for the inclusion circuit.
pub const NETWORK_INCLUSION_FUNCTION_NAME: &str = "inclusion";
Expand Down Expand Up @@ -230,6 +249,8 @@ mod tests {
FeePublicVerifier::load_bytes().expect("Failed to load fee_public verifier");
UpgradeProver::load_bytes().expect("Failed to load upgrade prover");
UpgradeVerifier::load_bytes().expect("Failed to load upgrade verifier");
RedelegateProver::load_bytes().expect("Failed to load redelegate prover");
RedelegateVerifier::load_bytes().expect("Failed to load redelegate verifier");
InclusionProver::load_bytes().expect("Failed to load inclusion prover");
InclusionVerifier::load_bytes().expect("Failed to load inclusion verifier");
}
Expand Down
6 changes: 6 additions & 0 deletions parameters/src/canary/resources/credits/redelegate.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"prover_checksum": "7a21a24a098f9e7da0152dcf3ae6b1ad927567a03709ea000042664b6f95835e",
"prover_size": 27065194,
"verifier_checksum": "0cc82122d771b717ac33e31af2d86f56169d87c6e8a69ffe3d588de41b80bc8b",
"verifier_size": 673
}
Binary file not shown.
Loading