From 94c5ca6b83a71addb33d76633f9ef3b16778de07 Mon Sep 17 00:00:00 2001 From: arnaud Date: Thu, 3 Apr 2025 17:32:48 +0200 Subject: [PATCH 1/4] Tezlink/Kernel: Add functions to handle manager in tezlink_account_storage.rs --- etherlink/kernel_latest/Cargo.lock | 1 + .../kernel_latest/tezos_execution/Cargo.toml | 1 + .../tezos_execution/src/account_storage.rs | 68 ++++++++++++++++++- 3 files changed, 67 insertions(+), 3 deletions(-) diff --git a/etherlink/kernel_latest/Cargo.lock b/etherlink/kernel_latest/Cargo.lock index 7cb739459a0c..973b3bb3fc04 100644 --- a/etherlink/kernel_latest/Cargo.lock +++ b/etherlink/kernel_latest/Cargo.lock @@ -2394,6 +2394,7 @@ name = "tezos-execution-latest" version = "0.1.0" dependencies = [ "hex", + "nom", "num-bigint", "primitive-types", "tezos-evm-runtime-latest", diff --git a/etherlink/kernel_latest/tezos_execution/Cargo.toml b/etherlink/kernel_latest/tezos_execution/Cargo.toml index d355990a3dca..d2f77c6b78c5 100644 --- a/etherlink/kernel_latest/tezos_execution/Cargo.toml +++ b/etherlink/kernel_latest/tezos_execution/Cargo.toml @@ -20,6 +20,7 @@ tezos-storage.workspace = true tezos-smart-rollup-host.workspace = true tezos_data_encoding.workspace = true +nom.workspace = true primitive-types.workspace = true tezos-smart-rollup.workspace = true diff --git a/etherlink/kernel_latest/tezos_execution/src/account_storage.rs b/etherlink/kernel_latest/tezos_execution/src/account_storage.rs index bf8233a53343..c13074690f26 100644 --- a/etherlink/kernel_latest/tezos_execution/src/account_storage.rs +++ b/etherlink/kernel_latest/tezos_execution/src/account_storage.rs @@ -6,11 +6,11 @@ //! Tezos account state and storage use crate::context; -use tezos_data_encoding::{enc::BinWriter, types::Narith}; +use tezos_data_encoding::{enc::BinWriter, nom::NomReader, types::Narith}; use tezos_evm_runtime::runtime::Runtime; -use tezos_smart_rollup::types::Contract; +use tezos_smart_rollup::types::{Contract, PublicKey, PublicKeyHash}; use tezos_smart_rollup_host::path::{concat, OwnedPath, RefPath}; -use tezos_storage::{read_optional_nom_value, store_bin}; +use tezos_storage::{read_nom_value, read_optional_nom_value, store_bin}; #[derive(Debug, PartialEq)] pub struct TezlinkImplicitAccount { @@ -23,10 +23,26 @@ impl From for TezlinkImplicitAccount { } } +// This enum is inspired of `src/proto_alpha/lib_protocol/manager_repr.ml` +// A manager can be: +// - a public key, it means that the account is revealed +// - a public key hash, account is not yet revealed but the +// reveal public key will match this public key hash +#[derive(Debug, PartialEq, Eq, BinWriter, NomReader)] +#[encoding(tags = "u8")] +pub enum Manager { + #[encoding(tag = 0)] + NotRevealed(PublicKeyHash), + #[encoding(tag = 1)] + Revealed(PublicKey), +} + const BALANCE_PATH: RefPath = RefPath::assert_from(b"/balance"); const COUNTER_PATH: RefPath = RefPath::assert_from(b"/counter"); +const MANAGER_PATH: RefPath = RefPath::assert_from(b"/manager"); + fn account_path(contract: &Contract) -> Result { // uses the same encoding as in the octez node's representation of the context // see `octez-codec describe alpha.contract binary schema` @@ -92,6 +108,52 @@ impl TezlinkImplicitAccount { let path = concat(&self.path, &BALANCE_PATH)?; store_bin(balance, host, &path) } + + #[allow(dead_code)] + pub fn manager( + &self, + host: &impl Runtime, + ) -> Result { + let path = concat(&self.path, &MANAGER_PATH)?; + let manager: Manager = read_nom_value(host, &path)?; + Ok(manager) + } + + /// This function updates the manager with a public key hash in parameter. + /// Most of the time, we're dealing with references so this function is here to avoid cloning + /// the public key hash to build a [Manager] object + pub fn set_manager_public_key_hash( + &mut self, + host: &mut impl Runtime, + public_key_hash: &PublicKeyHash, + ) -> Result<(), tezos_storage::error::Error> { + let path = concat(&self.path, &MANAGER_PATH)?; + // The tag for public key hash is 0 (see the Manager enum above) + let mut buffer = vec![0_u8]; + public_key_hash + .bin_write(&mut buffer) + .map_err(|_| tezos_smart_rollup::host::RuntimeError::DecodingError)?; + host.store_write_all(&path, &buffer)?; + Ok(()) + } + + /// This function updates the manager with the public key in parameter. + /// Most of the time, we're dealing with references so this function is here to avoid cloning + /// the public key hash to build a [Manager] object + pub fn set_manager_public_key( + &mut self, + host: &mut impl Runtime, + public_key: &PublicKey, + ) -> Result<(), tezos_storage::error::Error> { + let path = concat(&self.path, &MANAGER_PATH)?; + // The tag for public key hash is 1 (see the Manager enum above) + let mut buffer = vec![1_u8]; + public_key + .bin_write(&mut buffer) + .map_err(|_| tezos_smart_rollup::host::RuntimeError::DecodingError)?; + host.store_write_all(&path, &buffer)?; + Ok(()) + } } #[cfg(test)] -- GitLab From 5b30c3012b2d4f103ad74e44ffab4a8fbfcf1c14 Mon Sep 17 00:00:00 2001 From: arnaud Date: Fri, 4 Apr 2025 16:28:48 +0200 Subject: [PATCH 2/4] Tezlink/Kernel: Test that we can set and read an account manager --- .../tezos_execution/src/account_storage.rs | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/etherlink/kernel_latest/tezos_execution/src/account_storage.rs b/etherlink/kernel_latest/tezos_execution/src/account_storage.rs index c13074690f26..b34263902655 100644 --- a/etherlink/kernel_latest/tezos_execution/src/account_storage.rs +++ b/etherlink/kernel_latest/tezos_execution/src/account_storage.rs @@ -159,7 +159,9 @@ impl TezlinkImplicitAccount { #[cfg(test)] mod test { use super::*; + use tezos_crypto_rs::PublicKeyWithHash; use tezos_evm_runtime::runtime::MockKernelHost; + use tezos_smart_rollup::host::Runtime; // Read test use hard coded path on purpose to verify the Tezos compatibility. // These paths comes from the context.json generated by the create mockup command @@ -272,4 +274,108 @@ mod test { assert_eq!(counter, read_counter); } + + #[test] + fn test_read_manager() { + let mut host = MockKernelHost::default(); + + // Set the manager in a hard coded way + // For the public key I used the rust code to have it + // PublicKey::from_b58check( + // "edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav", + // ) + // .unwrap() + // Result: 01004798d2cc98473d7e250c898885718afd2e4efbcb1a1595ab9730761ed830de0f + let path = RefPath::assert_from(b"/tezlink/context/contracts/index/000002298c03ed7d454a101eb7022bc95f7e5f41ac78/manager"); + let public_key_hexa = hex::decode( + "01004798d2cc98473d7e250c898885718afd2e4efbcb1a1595ab9730761ed830de0f", + ) + .unwrap(); + host.store_write_all(&path, &public_key_hexa).unwrap(); + + // Initalize path for Tezlink context at /tezlink/context + let context = context::Context::init_context(); + + // Public key hash in b58 for 0002298c03ed7d454a101eb7022bc95f7e5f41ac78 + let contract = Contract::from_b58check("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx") + .expect("Contract base58 conversion should succeed"); + + let account = TezlinkImplicitAccount::from_contract(&context, &contract) + .expect("Account creation should have succeed"); + + let manager = account.manager(&host).expect("Can't read manager"); + + let pkh = match manager { + Manager::NotRevealed(pkh) => panic!( + "Manager should be revealed (manager key is a pkh: {:?})", + pkh + ), + Manager::Revealed(pk) => pk.pk_hash(), + }; + + assert_eq!(contract, Contract::Implicit(pkh)); + } + + #[test] + fn test_set_read_manager_public_key() { + let mut host = MockKernelHost::default(); + + // Initalize path for Tezlink context at /tezlink/context + let context = context::Context::init_context(); + + // Create an account for tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx + let contract = Contract::from_b58check("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx") + .expect("Contract base58 conversion should succeed"); + + let mut account = TezlinkImplicitAccount::from_contract(&context, &contract) + .expect("Account creation should have succeed"); + + let public_key = PublicKey::from_b58check( + "edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav", + ) + .unwrap(); + + let () = account + .set_manager_public_key(&mut host, &public_key) + .expect("set_manager_public_key shoud have succeed"); + + let manager = Manager::Revealed(public_key); + + let read_manager = account + .manager(&host) + .expect("read_manager should have succeed"); + + assert_eq!(manager, read_manager); + } + + #[test] + fn test_set_read_manager_public_key_hash() { + let mut host = MockKernelHost::default(); + + // Initalize path for Tezlink context at /tezlink/context + let context = context::Context::init_context(); + + // Create an account for tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx + let pkh = PublicKeyHash::from_b58check("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx") + .expect("PublicKeyHash base58 conversion should succeed"); + + let contract = Contract::Implicit(pkh); + let mut account = TezlinkImplicitAccount::from_contract(&context, &contract) + .expect("Account creation should have succeed"); + + let pkh = PublicKeyHash::from_b58check("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx") + .expect("PublicKeyHash base58 conversion should succeed"); + + let () = account + .set_manager_public_key_hash(&mut host, &pkh) + .expect("set_manager_public_key_hash shoud have succeed"); + + let manager = Manager::NotRevealed(pkh); + + let read_manager = account + .manager(&host) + .expect("read_manager should have succeed"); + + assert_eq!(manager, read_manager); + } } -- GitLab From 7e25d835c64cea17d3fdbc74e2ec545e36141e43 Mon Sep 17 00:00:00 2001 From: arnaud Date: Mon, 7 Apr 2025 10:56:59 +0200 Subject: [PATCH 3/4] Tezlink/Kernel: Add a function to verify that an account is allocated and a function to allocate an account Allocated verify the existence of the balance field as KT1 don't have counter nor manager --- .../tezos_execution/src/account_storage.rs | 83 ++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/etherlink/kernel_latest/tezos_execution/src/account_storage.rs b/etherlink/kernel_latest/tezos_execution/src/account_storage.rs index b34263902655..a18fd5cd5631 100644 --- a/etherlink/kernel_latest/tezos_execution/src/account_storage.rs +++ b/etherlink/kernel_latest/tezos_execution/src/account_storage.rs @@ -8,7 +8,10 @@ use crate::context; use tezos_data_encoding::{enc::BinWriter, nom::NomReader, types::Narith}; use tezos_evm_runtime::runtime::Runtime; -use tezos_smart_rollup::types::{Contract, PublicKey, PublicKeyHash}; +use tezos_smart_rollup::{ + host::ValueType, + types::{Contract, PublicKey, PublicKeyHash}, +}; use tezos_smart_rollup_host::path::{concat, OwnedPath, RefPath}; use tezos_storage::{read_nom_value, read_optional_nom_value, store_bin}; @@ -154,6 +157,36 @@ impl TezlinkImplicitAccount { host.store_write_all(&path, &buffer)?; Ok(()) } + + /// Verify if an account is allocated by attempting to read its balance + pub fn allocated( + &self, + host: &impl Runtime, + ) -> Result { + let path = concat(&self.path, &BALANCE_PATH)?; + Ok(Some(ValueType::Value) == host.store_has(&path)?) + } + + /// Allocate an account in the durable storage. Does nothing if account was + /// already allocated. + pub fn allocate( + host: &mut impl Runtime, + context: &context::Context, + contract: &Contract, + ) -> Result<(), tezos_storage::error::Error> { + let mut account = Self::from_contract(context, contract)?; + if account.allocated(host)? { + return Ok(()); + } + account.set_balance(host, &0_u64.into())?; + // Only implicit accounts have counter and manager keys + if let Contract::Implicit(pkh) = contract { + // TODO: use a global counter instead of initializing counter at 0 + account.set_counter(host, &0u64.into())?; + account.set_manager_public_key_hash(host, pkh)?; + } + Ok(()) + } } #[cfg(test)] @@ -378,4 +411,52 @@ mod test { assert_eq!(manager, read_manager); } + + #[test] + fn test_account_initialization() { + let mut host = MockKernelHost::default(); + + // Initalize path for Tezlink context at /tezlink/context + let context = context::Context::init_context(); + + // Create an account for tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx + let pkh = PublicKeyHash::from_b58check("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx") + .expect("PublicKeyHash base58 conversion should succeeded"); + + let contract = Contract::Implicit(pkh); + let mut account = TezlinkImplicitAccount::from_contract(&context, &contract) + .expect("Account creation should have succeeded"); + + let exist = account + .allocated(&host) + .expect("Exist account should have succeeded"); + + assert!(!exist); + + TezlinkImplicitAccount::allocate(&mut host, &context, &contract) + .expect("Account initialization should have succeeded"); + + let exist = account + .allocated(&host) + .expect("Exist account should have succeeded"); + + assert!(exist); + + let test_balance = 1999_u64.into(); + + account + .set_balance(&mut host, &test_balance) + .expect("Set balance should have succeeded"); + + // Calling init on a contract already initialized will do nothing + // So the balance should not change and still be 1999 + TezlinkImplicitAccount::allocate(&mut host, &context, &contract) + .expect("Account initialization should have succeeded"); + + let read_balance = account + .balance(&host) + .expect("Read balance should have succeeded"); + + assert_eq!(test_balance, read_balance); + } } -- GitLab From f579555877c25e89d0e852490d093f42d4f3dfb8 Mon Sep 17 00:00:00 2001 From: arnaud Date: Thu, 17 Apr 2025 13:52:08 +0200 Subject: [PATCH 4/4] Tezlink/Tests: Refacto of the account_storage's test --- .../tezos_execution/src/account_storage.rs | 149 ++++++++++-------- 1 file changed, 84 insertions(+), 65 deletions(-) diff --git a/etherlink/kernel_latest/tezos_execution/src/account_storage.rs b/etherlink/kernel_latest/tezos_execution/src/account_storage.rs index a18fd5cd5631..09d9dfd64f72 100644 --- a/etherlink/kernel_latest/tezos_execution/src/account_storage.rs +++ b/etherlink/kernel_latest/tezos_execution/src/account_storage.rs @@ -195,6 +195,31 @@ mod test { use tezos_crypto_rs::PublicKeyWithHash; use tezos_evm_runtime::runtime::MockKernelHost; use tezos_smart_rollup::host::Runtime; + use tezos_smart_rollup_host::path::Path; + + /// obtained by `octez-client show address bootstrap1` in mockup mode + const BOOTSTRAP1_PKH: &str = "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx"; + const BOOTSTRAP1_PK: &str = "edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav"; + + /// obtained by `octez-codec encode alpha.contract from '"tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx"'` + const BOOTSTRAP1_CONTRACT: RefPath = + RefPath::assert_from(b"/000002298c03ed7d454a101eb7022bc95f7e5f41ac78"); + + /// obtained by `PublicKey::from_b58check("edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav")` + const BOOTSTRAP1_PUBLIC_KEY_HEX: &str = + "01004798d2cc98473d7e250c898885718afd2e4efbcb1a1595ab9730761ed830de0f"; + + /// Set a key of bootstrap1 account according to the structure of a Tezos context + /// We don't use function from [TezlinkImplicitAccount] on purpose to verify that + /// it reads at the right path + fn set_bootstrap1_key(host: &mut impl Runtime, value_path: &impl Path, value: &[u8]) { + let index = RefPath::assert_from(b"/tezlink/context/contracts/index"); + let contract = concat(&index, &BOOTSTRAP1_CONTRACT) + .expect("Concatenation should have succeeded"); + let contract_path = + concat(&contract, value_path).expect("Concatenation should have succeeded"); + host.store_write_all(&contract_path, value).unwrap(); + } // Read test use hard coded path on purpose to verify the Tezos compatibility. // These paths comes from the context.json generated by the create mockup command @@ -207,21 +232,29 @@ mod test { // octez-codec decode alpha.contract from '000002298c03ed7d454a101eb7022bc95f7e5f41ac78' // Result: "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" let path = RefPath::assert_from(b"/tezlink/context/contracts/index/000002298c03ed7d454a101eb7022bc95f7e5f41ac78/balance"); - store_bin(&balance, &mut host, &path).expect("Store balance should have succeed"); + store_bin(&balance, &mut host, &path) + .expect("Store balance should have succeeded"); + + let mut balance_array = vec![]; + balance.bin_write(&mut balance_array).unwrap(); + set_bootstrap1_key( + &mut host, + &RefPath::assert_from(b"/balance"), + &balance_array, + ); // Initalize path for Tezlink context at /tezlink/context let context = context::Context::init_context(); - // Public key hash in b58 for 000002298c03ed7d454a101eb7022bc95f7e5f41ac78 - let contract = Contract::from_b58check("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx") - .expect("Contract base58 conversion should succeed"); + let contract = Contract::from_b58check(BOOTSTRAP1_PKH) + .expect("Contract base58 conversion should succeeded"); let account = TezlinkImplicitAccount::from_contract(&context, &contract) - .expect("Account creation should have succeed"); + .expect("Account creation should have succeeded"); let read_balance = account .balance(&host) - .expect("read_balance should have succeed"); + .expect("read_balance should have succeeded"); assert_eq!(balance, read_balance); } @@ -231,25 +264,23 @@ mod test { let mut host = MockKernelHost::default(); let counter: Narith = 3u64.into(); - // octez-codec decode alpha.contract from '000002298c03ed7d454a101eb7022bc95f7e5f41ac78' - // Result: "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" - let path = RefPath::assert_from(b"/tezlink/context/contracts/index/000002298c03ed7d454a101eb7022bc95f7e5f41ac78/counter"); - store_bin(&counter, &mut host, &path) - .expect("Store counter should have succeeded"); + + let mut bytes = vec![]; + counter.bin_write(&mut bytes).unwrap(); + set_bootstrap1_key(&mut host, &RefPath::assert_from(b"/counter"), &bytes); // Initalize path for Tezlink context at /tezlink/context let context = context::Context::init_context(); - // Public key hash in b58 for 0002298c03ed7d454a101eb7022bc95f7e5f41ac78 - let contract = Contract::from_b58check("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx") - .expect("Contract base58 conversion should succeed"); + let contract = Contract::from_b58check(BOOTSTRAP1_PKH) + .expect("Contract base58 conversion should succeeded"); let account = TezlinkImplicitAccount::from_contract(&context, &contract) - .expect("Account creation should have succeed"); + .expect("Account creation should have succeeded"); let read_counter = account .counter(&host) - .expect("read_counter should have succeed"); + .expect("read_counter should have succeeded"); assert_eq!(counter, read_counter); } @@ -263,20 +294,19 @@ mod test { // Initalize path for Tezlink context at /tezlink/context let context = context::Context::init_context(); - // Public key hash in b58 for 000002298c03ed7d454a101eb7022bc95f7e5f41ac78 - let contract = Contract::from_b58check("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx") - .expect("Contract base58 conversion should succeed"); + let contract = Contract::from_b58check(BOOTSTRAP1_PKH) + .expect("Contract base58 conversion should succeeded"); let mut account = TezlinkImplicitAccount::from_contract(&context, &contract) - .expect("Account creation should have succeed"); + .expect("Account creation should have succeeded"); let () = account .set_balance(&mut host, &balance) - .expect("set_balance should succeed"); + .expect("set_balance should succeeded"); let read_balance = account .balance(&host) - .expect("read_balance should have succeed"); + .expect("read_balance should have succeeded"); assert_eq!(balance, read_balance); } @@ -290,20 +320,19 @@ mod test { // Initalize path for Tezlink context at /tezlink/context let context = context::Context::init_context(); - // Public key hash in b58 for 0002298c03ed7d454a101eb7022bc95f7e5f41ac78 - let contract = Contract::from_b58check("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx") - .expect("Contract base58 conversion should succeed"); + let contract = Contract::from_b58check(BOOTSTRAP1_PKH) + .expect("Contract base58 conversion should succeeded"); let mut account = TezlinkImplicitAccount::from_contract(&context, &contract) - .expect("Account creation should have succeed"); + .expect("Account creation should have succeeded"); let () = account .set_counter(&mut host, &counter) - .expect("set_counter should have succeed"); + .expect("set_counter should have succeeded"); let read_counter = account .counter(&host) - .expect("read_counter should have succeed"); + .expect("read_counter should have succeeded"); assert_eq!(counter, read_counter); } @@ -312,29 +341,22 @@ mod test { fn test_read_manager() { let mut host = MockKernelHost::default(); - // Set the manager in a hard coded way - // For the public key I used the rust code to have it - // PublicKey::from_b58check( - // "edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav", - // ) - // .unwrap() - // Result: 01004798d2cc98473d7e250c898885718afd2e4efbcb1a1595ab9730761ed830de0f - let path = RefPath::assert_from(b"/tezlink/context/contracts/index/000002298c03ed7d454a101eb7022bc95f7e5f41ac78/manager"); - let public_key_hexa = hex::decode( - "01004798d2cc98473d7e250c898885718afd2e4efbcb1a1595ab9730761ed830de0f", - ) - .unwrap(); - host.store_write_all(&path, &public_key_hexa).unwrap(); + let public_key_hexa = hex::decode(BOOTSTRAP1_PUBLIC_KEY_HEX).unwrap(); + + set_bootstrap1_key( + &mut host, + &RefPath::assert_from(b"/manager"), + &public_key_hexa, + ); // Initalize path for Tezlink context at /tezlink/context let context = context::Context::init_context(); - // Public key hash in b58 for 0002298c03ed7d454a101eb7022bc95f7e5f41ac78 - let contract = Contract::from_b58check("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx") - .expect("Contract base58 conversion should succeed"); + let contract = Contract::from_b58check(BOOTSTRAP1_PKH) + .expect("Contract base58 conversion should succeeded"); let account = TezlinkImplicitAccount::from_contract(&context, &contract) - .expect("Account creation should have succeed"); + .expect("Account creation should have succeeded"); let manager = account.manager(&host).expect("Can't read manager"); @@ -356,27 +378,24 @@ mod test { // Initalize path for Tezlink context at /tezlink/context let context = context::Context::init_context(); - // Create an account for tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx - let contract = Contract::from_b58check("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx") - .expect("Contract base58 conversion should succeed"); + // Create an account for bootstrap1 + let contract = Contract::from_b58check(BOOTSTRAP1_PKH) + .expect("Contract base58 conversion should succeeded"); let mut account = TezlinkImplicitAccount::from_contract(&context, &contract) - .expect("Account creation should have succeed"); + .expect("Account creation should have succeeded"); - let public_key = PublicKey::from_b58check( - "edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav", - ) - .unwrap(); + let public_key = PublicKey::from_b58check(BOOTSTRAP1_PK).unwrap(); let () = account .set_manager_public_key(&mut host, &public_key) - .expect("set_manager_public_key shoud have succeed"); + .expect("set_manager_public_key shoud have succeeded"); let manager = Manager::Revealed(public_key); let read_manager = account .manager(&host) - .expect("read_manager should have succeed"); + .expect("read_manager should have succeeded"); assert_eq!(manager, read_manager); } @@ -388,26 +407,26 @@ mod test { // Initalize path for Tezlink context at /tezlink/context let context = context::Context::init_context(); - // Create an account for tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx - let pkh = PublicKeyHash::from_b58check("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx") - .expect("PublicKeyHash base58 conversion should succeed"); + // Create an account for bootstrap1 + let pkh = PublicKeyHash::from_b58check(BOOTSTRAP1_PKH) + .expect("PublicKeyHash base58 conversion should succeeded"); let contract = Contract::Implicit(pkh); let mut account = TezlinkImplicitAccount::from_contract(&context, &contract) - .expect("Account creation should have succeed"); + .expect("Account creation should have succeeded"); - let pkh = PublicKeyHash::from_b58check("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx") - .expect("PublicKeyHash base58 conversion should succeed"); + let pkh = PublicKeyHash::from_b58check(BOOTSTRAP1_PKH) + .expect("PublicKeyHash base58 conversion should succeeded"); let () = account .set_manager_public_key_hash(&mut host, &pkh) - .expect("set_manager_public_key_hash shoud have succeed"); + .expect("set_manager_public_key_hash shoud have succeeded"); let manager = Manager::NotRevealed(pkh); let read_manager = account .manager(&host) - .expect("read_manager should have succeed"); + .expect("read_manager should have succeeded"); assert_eq!(manager, read_manager); } @@ -419,8 +438,8 @@ mod test { // Initalize path for Tezlink context at /tezlink/context let context = context::Context::init_context(); - // Create an account for tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx - let pkh = PublicKeyHash::from_b58check("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx") + // Create an account for bootstrap1 + let pkh = PublicKeyHash::from_b58check(BOOTSTRAP1_PKH) .expect("PublicKeyHash base58 conversion should succeeded"); let contract = Contract::Implicit(pkh); -- GitLab