Skip to content

Commit

Permalink
remove op_codes of ZkLinkTxType, fix params
Browse files Browse the repository at this point in the history
  • Loading branch information
Fred0327 committed Nov 2, 2023
1 parent d22308c commit 8efc7d6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
1 change: 1 addition & 0 deletions signers/src/zklink_signer/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ fn get_bits_le_fixed(fr: &Fr, size: usize) -> Vec<bool> {
}

pub fn rescue_hash_orders(msg: &[u8]) -> Vec<u8> {
assert_eq!(msg.len(), 178);
let msg_bits = bytes_into_be_bits(msg);
let hash_fr = rescue_hash_fr(msg_bits);
let hash_bits = get_bits_le_fixed(&hash_fr, 248);
Expand Down
6 changes: 4 additions & 2 deletions types/src/basic_types/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub const CHAIN_SUB_TREE_DEPTH: usize = SUB_ACCOUNT_TREE_DEPTH;
pub const USED_ACCOUNT_SUBTREE_DEPTH: usize = 24;
/// Depth of the position subtree that used for the current circuit construct available position subtree
pub const USED_POSITION_SUBTREE_DEPTH: usize = 2;
pub const USED_BALANCE_SUBTREE_DEPTH: usize = 8;
pub const USED_BALANCE_SUBTREE_DEPTH: usize = 16;
/// The total account number and maximum account id allowed for the current zklink layer2(if not enough, modify this parameter and update circuit).
pub const TOTAL_ACCOUNT_NUMBER: usize = usize::pow(2, USED_ACCOUNT_SUBTREE_DEPTH as u32);
pub const MAX_ACCOUNT_ID: AccountId = AccountId(TOTAL_ACCOUNT_NUMBER as u32 - 1);
Expand All @@ -42,7 +42,7 @@ pub const MIN_PRICE: u128 = 1;
/// deciamls of price in order will be improved with TOKEN_MAX_PRECISION(18)
/// the bit width of price in pubdata is PRICE_BIT_WIDTH(120)
/// so the max price of price that order can submit is
/// 2 ** 120 - 1 / 10 ^18 = 1329227995784915872
/// (2 ** 120 - 1) / 10 ^18 = 1329227995784915872
pub const MAX_PRICE: u128 = 1329227995784915872000000000000000000;

pub const TOKEN_BIT_WIDTH: usize = 16;
Expand Down Expand Up @@ -210,6 +210,8 @@ pub const SIGNED_BATCH_FUNDING_BIT_WIDTH: usize = TX_TYPE_BIT_WIDTH
+ TOKEN_BIT_WIDTH
+ FEE_BIT_WIDTH;

/// 0 can not be used as token id
pub const TOKEN_ID_ZERO: u32 = 0;
pub const CONTRACT_PRICE_BIT_WIDTH: usize = PRICE_BIT_WIDTH + PAIR_BIT_WIDTH;
pub const CONTRACT_PRICE_BYTES: usize = CONTRACT_PRICE_BIT_WIDTH / 8;
pub const MARGIN_PRICE_BIT_WIDTH: usize = PRICE_BIT_WIDTH + TOKEN_BIT_WIDTH;
Expand Down
19 changes: 0 additions & 19 deletions types/src/tx_type/zklink_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,6 @@ pub enum ZkLinkTxType {
UpdateGlobalVar,
}

impl ZkLinkTxType {
pub fn op_codes(&self) -> Vec<u8> {
match self {
ZkLinkTxType::Deposit => vec![Deposit::TX_TYPE],
ZkLinkTxType::Transfer => vec![Transfer::TX_TYPE],
ZkLinkTxType::Withdraw => vec![Withdraw::TX_TYPE],
ZkLinkTxType::FullExit => vec![FullExit::TX_TYPE],
ZkLinkTxType::ChangePubKey => vec![ChangePubKey::TX_TYPE],
ZkLinkTxType::ForcedExit => vec![ForcedExit::TX_TYPE],
ZkLinkTxType::OrderMatching => vec![OrderMatching::TX_TYPE],
ZkLinkTxType::ContractMatching => vec![ContractMatching::TX_TYPE],
ZkLinkTxType::Liquidation => vec![Liquidation::TX_TYPE],
ZkLinkTxType::AutoDeleveraging => vec![AutoDeleveraging::TX_TYPE],
ZkLinkTxType::UpdateGlobalVar => vec![UpdateGlobalVar::TX_TYPE],
ZkLinkTxType::Funding => vec![Funding::TX_TYPE],
}
}
}

/// A set of L2 transaction supported by the zklink network.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
Expand Down

0 comments on commit 8efc7d6

Please sign in to comment.