Skip to content

Commit

Permalink
Fixing demo-rollup
Browse files Browse the repository at this point in the history
  • Loading branch information
citizen-stig committed Aug 10, 2023
1 parent f140032 commit e124d4c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
11 changes: 11 additions & 0 deletions adapters/celestia/src/verifier/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,17 @@ mod tests {
assert_eq!(raw_address_str, output);
}

#[test]
fn test_from_str_and_from_slice_same() {
let raw_address_str = "celestia1w7wcupk5gswj25c0khnkey5fwmlndx6t5aarmk";
let raw_address_array = *b"celestia1w7wcupk5gswj25c0khnkey5fwmlndx6t5aarmk";

let address_from_str = CelestiaAddress::from_str(raw_address_str).unwrap();
let address_from_slice = CelestiaAddress::try_from(&raw_address_array[..]).unwrap();

assert_eq!(address_from_str, address_from_slice);
}

// 20 u8 -> 32 u5
fn check_from_bytes_as_ascii(input: [u8; 20]) {
let encoded = bech32::encode("celestia", input.to_base32(), VARIANT).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion examples/const-rollup-config/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// The rollup stores its data in the namespace b"sov-test" on Celestia.
pub const ROLLUP_NAMESPACE_RAW: [u8; 8] = [115, 111, 118, 45, 116, 101, 115, 116];
pub const SEQUENCER_DA_ADDRESS: [u8; 47] = *b"celestia1w7wcupk5gswj25c0khnkey5fwmlndx6t5aarmk";
pub const SEQUENCER_DA_ADDRESS: &str = "celestia1w7wcupk5gswj25c0khnkey5fwmlndx6t5aarmk";
5 changes: 4 additions & 1 deletion examples/demo-prover/host/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use std::env;
use std::str::FromStr;

use anyhow::Context;
use const_rollup_config::{ROLLUP_NAMESPACE_RAW, SEQUENCER_DA_ADDRESS};
use demo_stf::app::{App, DefaultPrivateKey};
use demo_stf::genesis_config::create_demo_genesis_config;
use jupiter::da_service::{CelestiaService, DaServiceConfig};
use jupiter::types::NamespaceId;
use jupiter::verifier::address::CelestiaAddress;
use jupiter::verifier::RollupParams;
use methods::{ROLLUP_ELF, ROLLUP_ID};
use risc0_adapter::host::{Risc0Host, Risc0Verifier};
Expand Down Expand Up @@ -61,10 +63,11 @@ async fn main() -> Result<(), anyhow::Error> {
let mut demo = app.stf;

if is_storage_empty {
let sequencer_da_address = CelestiaAddress::from_str(SEQUENCER_DA_ADDRESS).unwrap();
let genesis_config = create_demo_genesis_config(
100000000,
sequencer_private_key.default_address(),
SEQUENCER_DA_ADDRESS.to_vec(),
sequencer_da_address.as_ref().to_vec(),
&sequencer_private_key,
&sequencer_private_key,
);
Expand Down
5 changes: 4 additions & 1 deletion examples/demo-rollup/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::env;
use std::str::FromStr;
use std::sync::Arc;

use anyhow::Context;
Expand All @@ -10,6 +11,7 @@ use jupiter::da_service::CelestiaService;
#[cfg(feature = "experimental")]
use jupiter::da_service::DaServiceConfig;
use jupiter::types::NamespaceId;
use jupiter::verifier::address::CelestiaAddress;
use jupiter::verifier::RollupParams;
use risc0_adapter::host::Risc0Verifier;
use sov_db::ledger_db::LedgerDB;
Expand Down Expand Up @@ -64,10 +66,11 @@ pub fn get_genesis_config() -> GenesisConfig<DefaultContext> {
hex_key.address,
"Inconsistent key data",
);
let sequencer_da_address = CelestiaAddress::from_str(SEQUENCER_DA_ADDRESS).unwrap();
create_demo_genesis_config(
100000000,
sequencer_private_key.default_address(),
SEQUENCER_DA_ADDRESS.to_vec(),
sequencer_da_address.as_ref().to_vec(),
&sequencer_private_key,
&sequencer_private_key,
)
Expand Down
3 changes: 2 additions & 1 deletion examples/demo-rollup/src/rng_xfers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::env;
use std::str::FromStr;

use async_trait::async_trait;
use borsh::ser::BorshSerialize;
Expand Down Expand Up @@ -146,7 +147,7 @@ impl DaService for RngDaService {
generate_transfers(num_txns, (block.height - 1) * (num_txns as u64))
};

let address = CelestiaAddress::try_from(&SEQUENCER_DA_ADDRESS[..]).unwrap();
let address = CelestiaAddress::from_str(SEQUENCER_DA_ADDRESS).unwrap();
let blob = TestBlob::new(data, address, [0u8; 32]);

vec![blob]
Expand Down

0 comments on commit e124d4c

Please sign in to comment.