Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kariy committed Feb 7, 2025
1 parent 2d84e9e commit 743413d
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions bin/katana/src/cli/init/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::sync::Arc;
use anyhow::{anyhow, Result};
use cainome::cairo_serde;
use dojo_utils::{TransactionWaiter, TransactionWaitingError};
use katana_primitives::block::BlockHash;
use katana_primitives::class::{
CompiledClassHash, ComputeClassHashError, ContractClass, ContractClassCompilationError,
ContractClassFromStrError,
Expand Down Expand Up @@ -111,17 +112,29 @@ pub async fn deploy_settlement_contract(
let salt = Felt::from(rand::random::<u64>());
let factory = ContractFactory::new(class_hash, &account);

// appchain::constructor() https://github.com/cartridge-gg/piltover/blob/d373a844c3428383a48518adf468bf83249dec3a/src/appchain.cairo#L119-L125
const INITIAL_STATE_ROOT: Felt = Felt::ZERO;
/// When updating the piltover contract with the genesis block (ie block number 0), in the
/// attached StarknetOsOutput, the [previous block number] is expected to be
/// `0x800000000000011000000000000000000000000000000000000000000000000`. Which is the
/// maximum value of a [`Felt`].
///
/// It is a value generated by StarknetOs.
///
/// [previous block number]: https://github.com/keep-starknet-strange/piltover/blob/a7d6b17f855f2295a843bfd0ab0dcd696c6229a8/src/snos_output.cairo#L34
const INITIAL_BLOCK_NUMBER: Felt = Felt::MAX;
const INITIAL_BLOCK_HASH: BlockHash = Felt::ZERO;

// appchain::constructor() https://github.com/keep-starknet-strange/piltover/blob/a7d6b17f855f2295a843bfd0ab0dcd696c6229a8/src/appchain.cairo#L122-L128
let request = factory.deploy_v1(
vec![
// owner.
account.address(),
// state root.
Felt::ZERO,
INITIAL_STATE_ROOT,
// block_number must be magic value for genesis block.
Felt::MAX,
INITIAL_BLOCK_NUMBER,
// block_hash.
Felt::ZERO,
INITIAL_BLOCK_HASH,
],
salt,
false,
Expand All @@ -148,6 +161,11 @@ pub async fn deploy_settlement_contract(
// Compute the chain's config hash
let config_hash = compute_config_hash(
chain_id,
// NOTE:
//
// This is the default fee token contract address of chains generated using `katana
// init`. We shouldn't hardcode this and need to handle this more
// elegantly.
felt!("0x2e7442625bab778683501c0eadbc1ea17b3535da040a12ac7d281066e915eea"),
);

Expand All @@ -156,9 +174,9 @@ pub async fn deploy_settlement_contract(
sp.update_text("Setting program info...");

let program_info = ProgramInfo {
program_hash: LAYOUT_BRIDGE_PROGRAM_HASH,
config_hash,
snos_program_hash: SNOS_PROGRAM_HASH,
program_hash: LAYOUT_BRIDGE_PROGRAM_HASH,
};

let res = appchain
Expand Down Expand Up @@ -222,10 +240,10 @@ pub async fn check_program_info(
// Compute the chain's config hash
let config_hash = compute_config_hash(
chain_id,
// TODO:
// NOTE:
//
// This is the default fee token contract address. We shouldn't hardcode
// this and need to handle this more elegantly.
// This is the default fee token contract address of chains generated using `katana init`.
// We shouldn't hardcode this and need to handle this more elegantly.
felt!("0x2e7442625bab778683501c0eadbc1ea17b3535da040a12ac7d281066e915eea"),
);

Expand Down

0 comments on commit 743413d

Please sign in to comment.