Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Incorrect bridge_address encoding #62

Merged
Merged
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
112 changes: 108 additions & 4 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions jstz_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ tezos-smart-rollup = "0.2.1"
tezos-smart-rollup-mock = "0.2.1"
tezos-smart-rollup-installer-config = "0.2.1"
serde_yaml = "0.8"
tezos_crypto_rs = "0.5.1"

[[bin]]
name = "jstz"
Expand Down
66 changes: 37 additions & 29 deletions jstz_cli/src/sandbox/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ use std::{
use anyhow::Result;
use fs_extra::dir::CopyOptions;
use jstz_core::kv::value::serialize;
use jstz_crypto::public_key_hash::PublicKeyHash;
use nix::libc::{SIGINT, SIGTERM};
use signal_hook::iterator::Signals;
use tempfile::TempDir;
use tezos_crypto_rs::hash::ContractKt1Hash;
use tezos_smart_rollup_installer_config::yaml::{Instr, SetArgs, YamlConfig};

use crate::{
Expand Down Expand Up @@ -179,13 +179,11 @@ fn start_rollup_node(cfg: &Config) -> Result<Child> {

fn smart_rollup_installer(cfg: &Config, bridge_address: &str) -> Result<()> {
//Convert address
let address_encoding =
serialize(&PublicKeyHash::from_base58(&bridge_address).unwrap());
let hex_address = hex::encode(address_encoding.clone());
let bridge_address = ContractKt1Hash::from_base58_check(bridge_address)?;

let instructions = YamlConfig {
instructions: vec![Instr::Set(SetArgs {
value: hex_address.clone(),
value: hex::encode(serialize(&bridge_address)),
to: "/ticketer".to_owned(),
})],
};
Expand All @@ -199,29 +197,39 @@ fn smart_rollup_installer(cfg: &Config, bridge_address: &str) -> Result<()> {
let setup_file_path = temp_file.path().to_owned();

// Create an installer kernel
let _output = Command::new("smart-rollup-installer")
.args(&[
"get-reveal-installer",
"--setup-file",
&setup_file_path.to_str().expect("Invalid path"),
"--output",
cfg.jstz_path
.join("target/kernel/jstz_kernel_installer.hex")
.to_str()
.expect("Invalid path"),
"--preimages-dir",
&cfg.jstz_path
.join("target/kernel")
.join("preimages/")
.to_str()
.expect("Invalid path"),
"--upgrade-to",
&cfg.jstz_path
.join("target/wasm32-unknown-unknown/release/jstz_kernel.wasm")
.to_str()
.expect("Invalid path"),
])
.output();
let mut installer_command = Command::new("smart-rollup-installer");

installer_command.args(&[
"get-reveal-installer",
"--setup-file",
&setup_file_path.to_str().expect("Invalid path"),
"--output",
cfg.jstz_path
.join("target/kernel/jstz_kernel_installer.hex")
.to_str()
.expect("Invalid path"),
"--preimages-dir",
&cfg.jstz_path
.join("target/kernel")
.join("preimages/")
.to_str()
.expect("Invalid path"),
"--upgrade-to",
&cfg.jstz_path
.join("target/wasm32-unknown-unknown/release/jstz_kernel.wasm")
.to_str()
.expect("Invalid path"),
]);

let installer_output = installer_command.output()?;

if !installer_output.status.success() {
return Err(anyhow::anyhow!(
"Command {:?} failed:\n {}",
installer_command,
String::from_utf8_lossy(&installer_output.stderr)
));
}

Ok(())
}
Expand Down Expand Up @@ -409,7 +417,7 @@ pub fn main(cfg: &mut Config) -> Result<()> {
cfg.save()?;

// 4. Wait for the sandbox to shutdown (either by the user or by an error)
OctezThread::join(vec![rollup_node, baker, node])?;
OctezThread::join(vec![baker, rollup_node, node])?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this change needed?


cfg.sandbox = None;
cfg.save()?;
Expand Down
Loading