Skip to content

Commit

Permalink
Validators with dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
kubaplas committed Dec 16, 2024
1 parent 16598d1 commit e77c8d6
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ odra-casper-rpc-client = { path = "odra-casper/rpc-client", version = "2.0.0" }
odra-vm = { path = "odra-vm", version = "2.0.0" }
odra-casper-wasm-env = { path = "odra-casper/wasm-env", version = "2.0.0"}
odra-schema = { path = "odra-schema", version = "2.0.0" }
casper-contract = { git = "https://github.com/igor-casper/casper-node.git", branch = "impl-cltype-for-bidkind", default-features = false }
casper-contract = { git = "https://github.com/casper-network/casper-node.git", branch = "feat-2.0", default-features = false }
casper-contract-schema = { git = "https://github.com/odradev/casper-contract-schema.git", branch = "feature/casper-2.0" }
casper-types = "5.0.0"
casper-execution-engine = { git = "https://github.com/igor-casper/casper-node.git", branch = "impl-cltype-for-bidkind" }
casper-engine-test-support = { git = "https://github.com/igor-casper/casper-node.git", branch = "impl-cltype-for-bidkind" }
casper-storage = { git = "https://github.com/igor-casper/casper-node.git", branch = "impl-cltype-for-bidkind" }
casper-execution-engine = { git = "https://github.com/casper-network/casper-node.git", branch = "feat-2.0" }
casper-engine-test-support = { git = "https://github.com/casper-network/casper-node.git", branch = "feat-2.0" }
casper-storage = { git = "https://github.com/casper-network/casper-node.git", branch = "feat-2.0" }
casper-event-standard = { git = "https://github.com/odradev/casper-event-standard.git", branch = "feat-2.0" }
casper-client = { git = "https://github.com/casper-ecosystem/casper-client-rs.git", branch = "feat-track-node-2.0", default-features = false}
blake2 = "0.10.6"
Expand All @@ -61,7 +61,7 @@ convert_case = "0.6.0"
lazy_static = "1.5.0"

[patch.crates-io]
casper-types = { version = "5.0.0", git = "https://github.com/igor-casper/casper-node.git", branch = "impl-cltype-for-bidkind" }
casper-types = { version = "5.0.0", git = "https://github.com/casper-network/casper-node.git", branch = "feat-2.0" }

[profile.release]
codegen-units = 1
Expand Down
16 changes: 9 additions & 7 deletions examples/src/features/validators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,18 @@ pub enum ValError {

#[cfg(test)]
mod tests {
use crate::features::validators::{ValidatorsContract, ValidatorsContractInitArgs};
use odra::casper_types::U512;
use odra::host::Deployer;
use odra::host::HostRef;

/// Time in milliseconds for one era. On livenet it's 120 minutes. On local, by default it's 41 seconds.
pub const ERA_DURATION: u64 = 41 * 1000;

// Validators are now supported only on casper target
#[cfg(target_arch = "wasm32")]
#[test]
fn test_validators() {
use crate::features::validators::{ValidatorsContract, ValidatorsContractInitArgs};
use odra::casper_types::U512;
use odra::host::Deployer;
use odra::host::HostRef;

/// Time in milliseconds for one era. On livenet it's 120 minutes. On local, by default it's 41 seconds.
pub const ERA_DURATION: u64 = 41 * 1000;
let test_env = odra_test::env();
test_env.set_caller(test_env.get_account(0));
let mut staking = ValidatorsContract::deploy(
Expand Down
12 changes: 6 additions & 6 deletions odra-casper/livenet-env/src/livenet_contract_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,16 @@ impl ContractContext for LivenetContractEnv {
result
}

fn delegate(&self, validator: PublicKey, amount: U512) {
todo!()
fn delegate(&self, _validator: PublicKey, _amount: U512) {
panic!("delegate is not supported for LivenetContractEnv")
}

fn undelegate(&self, validator: PublicKey, amount: U512) {
todo!()
fn undelegate(&self, _validator: PublicKey, _amount: U512) {
panic!("undelegate is not supported for LivenetContractEnv")
}

fn delegated_amount(&self, validator: PublicKey) -> U512 {
todo!()
fn delegated_amount(&self, _validator: PublicKey) -> U512 {
panic!("delegated_amount is not supported for LivenetContractEnv")
}
}

Expand Down
8 changes: 8 additions & 0 deletions odra-casper/livenet-env/src/livenet_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,14 @@ impl HostContext for LivenetHost {
)
})
}

fn get_validator(&self) -> PublicKey {
panic!("get_validator not supported for LivenetHost")
}

fn advance_with_auctions(&self, _: u64) {
panic!("advance_with_auctions not supported for LivenetHost")
}
}

impl LivenetHost {
Expand Down
4 changes: 2 additions & 2 deletions odra-casper/rpc-client/src/casper_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ impl CasperClient {
)
});

Address::from(key.into_contract_package_hash().unwrap_or_else(|| {
Address::from(key.into_package_hash().unwrap_or_else(|| {
panic!(
"Couldn't get package hash from key {:?} for account: {:?}",
key_name,
Expand Down Expand Up @@ -743,7 +743,7 @@ impl CasperClient {
}
};

Deploy::new(
Deploy::new_signed(
timestamp,
ttl,
gas_price,
Expand Down

0 comments on commit e77c8d6

Please sign in to comment.