Skip to content

Commit

Permalink
fixup! fix everything that was depending on rm'd namada crate
Browse files Browse the repository at this point in the history
  • Loading branch information
tzemanovic committed Jul 1, 2024
1 parent c0d04cb commit 9695d7b
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 110 deletions.
85 changes: 54 additions & 31 deletions crates/ethereum_bridge/src/vp/bridge_pool_vp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ where
{
/// Context to interact with the host structures.
pub ctx: Ctx<'ctx, S, CA, EVAL>,
/// Token keys type
pub token_keys: PhantomData<TokenKeys>,
/// Generic types for DI
pub _marker: PhantomData<TokenKeys>,
}

impl<'ctx, S, CA, EVAL, TokenKeys> BridgePool<'ctx, S, CA, EVAL, TokenKeys>
Expand All @@ -86,7 +86,7 @@ where
pub fn new(ctx: Ctx<'ctx, S, CA, EVAL>) -> Self {
Self {
ctx,
token_keys: PhantomData,
_marker: PhantomData,
}
}

Expand Down Expand Up @@ -715,6 +715,8 @@ mod test_bridge_pool_vp {
CA,
>;
type TokenKeys = namada_token::Store<()>;
type BridgePool<'a, S> =
super::BridgePool<'a, S, VpCache<CA>, Eval, TokenKeys>;

/// The amount of NAM Bertha has
const ASSET: EthAddress = EthAddress([0; 20]);
Expand Down Expand Up @@ -1061,10 +1063,13 @@ mod test_bridge_pool_vp {
let gas_meter = RefCell::new(VpGasMeter::new_from_tx_meter(
&TxGasMeter::new_from_sub_limit(u64::MAX.into()),
));
let vp = BridgePool {
ctx: setup_ctx(&tx, &state, &gas_meter, &keys_changed, &verifiers),
token_keys: PhantomData::<TokenKeys>,
};
let vp = BridgePool::new(setup_ctx(
&tx,
&state,
&gas_meter,
&keys_changed,
&verifiers,
));

let mut tx = Tx::new(state.in_mem().chain_id.clone(), None);
tx.add_data(transfer);
Expand Down Expand Up @@ -1409,10 +1414,13 @@ mod test_bridge_pool_vp {
let gas_meter = RefCell::new(VpGasMeter::new_from_tx_meter(
&TxGasMeter::new_from_sub_limit(u64::MAX.into()),
));
let vp = BridgePool {
ctx: setup_ctx(&tx, &state, &gas_meter, &keys_changed, &verifiers),
token_keys: PhantomData::<TokenKeys>,
};
let vp = BridgePool::new(setup_ctx(
&tx,
&state,
&gas_meter,
&keys_changed,
&verifiers,
));

let mut tx = Tx::new(state.in_mem().chain_id.clone(), None);
tx.add_data(transfer);
Expand Down Expand Up @@ -1470,10 +1478,13 @@ mod test_bridge_pool_vp {
let gas_meter = RefCell::new(VpGasMeter::new_from_tx_meter(
&TxGasMeter::new_from_sub_limit(u64::MAX.into()),
));
let vp = BridgePool {
ctx: setup_ctx(&tx, &state, &gas_meter, &keys_changed, &verifiers),
token_keys: PhantomData::<TokenKeys>,
};
let vp = BridgePool::new(setup_ctx(
&tx,
&state,
&gas_meter,
&keys_changed,
&verifiers,
));

let mut tx = Tx::new(state.in_mem().chain_id.clone(), None);
tx.add_data(transfer);
Expand Down Expand Up @@ -1552,10 +1563,13 @@ mod test_bridge_pool_vp {
let gas_meter = RefCell::new(VpGasMeter::new_from_tx_meter(
&TxGasMeter::new_from_sub_limit(u64::MAX.into()),
));
let vp = BridgePool {
ctx: setup_ctx(&tx, &state, &gas_meter, &keys_changed, &verifiers),
token_keys: PhantomData::<TokenKeys>,
};
let vp = BridgePool::new(setup_ctx(
&tx,
&state,
&gas_meter,
&keys_changed,
&verifiers,
));

let mut tx = Tx::new(state.in_mem().chain_id.clone(), None);
tx.add_data(transfer);
Expand Down Expand Up @@ -1629,10 +1643,13 @@ mod test_bridge_pool_vp {
let gas_meter = RefCell::new(VpGasMeter::new_from_tx_meter(
&TxGasMeter::new_from_sub_limit(u64::MAX.into()),
));
let vp = BridgePool {
ctx: setup_ctx(&tx, &state, &gas_meter, &keys_changed, &verifiers),
token_keys: PhantomData::<TokenKeys>,
};
let vp = BridgePool::new(setup_ctx(
&tx,
&state,
&gas_meter,
&keys_changed,
&verifiers,
));

let mut tx = Tx::new(state.in_mem().chain_id.clone(), None);
tx.add_data(transfer);
Expand Down Expand Up @@ -1723,10 +1740,13 @@ mod test_bridge_pool_vp {
let gas_meter = RefCell::new(VpGasMeter::new_from_tx_meter(
&TxGasMeter::new_from_sub_limit(u64::MAX.into()),
));
let vp = BridgePool {
ctx: setup_ctx(&tx, &state, &gas_meter, &keys_changed, &verifiers),
token_keys: PhantomData::<TokenKeys>,
};
let vp = BridgePool::new(setup_ctx(
&tx,
&state,
&gas_meter,
&keys_changed,
&verifiers,
));

let mut tx = Tx::new(state.in_mem().chain_id.clone(), None);
tx.add_data(transfer);
Expand Down Expand Up @@ -1803,10 +1823,13 @@ mod test_bridge_pool_vp {
let gas_meter = RefCell::new(VpGasMeter::new_from_tx_meter(
&TxGasMeter::new_from_sub_limit(u64::MAX.into()),
));
let vp = BridgePool {
ctx: setup_ctx(&tx, &state, &gas_meter, &keys_changed, &verifiers),
token_keys: PhantomData::<TokenKeys>,
};
let vp = BridgePool::new(setup_ctx(
&tx,
&state,
&gas_meter,
&keys_changed,
&verifiers,
));

let mut tx = Tx::from_type(TxType::Raw);
tx.push_default_inner_tx();
Expand Down
65 changes: 29 additions & 36 deletions crates/ethereum_bridge/src/vp/eth_bridge_vp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ where
{
/// Context to interact with the host structures.
pub ctx: Ctx<'ctx, S, CA, EVAL>,
/// Token keys type
pub token_keys: PhantomData<TokenKeys>,
/// Generic types for DI
pub _marker: PhantomData<TokenKeys>,
}

impl<'ctx, S, CA, EVAL, TokenKeys> EthBridge<'ctx, S, CA, EVAL, TokenKeys>
Expand All @@ -43,7 +43,7 @@ where
pub fn new(ctx: Ctx<'ctx, S, CA, EVAL>) -> Self {
Self {
ctx,
token_keys: PhantomData,
_marker: PhantomData,
}
}

Expand Down Expand Up @@ -224,6 +224,8 @@ mod tests {
CA,
>;
type TokenKeys = namada_token::Store<()>;
type EthBridge<'a, S> =
super::EthBridge<'a, S, VpCache<CA>, Eval, TokenKeys>;

/// Return some arbitrary random key belonging to this account
fn arbitrary_key() -> Key {
Expand Down Expand Up @@ -421,17 +423,14 @@ mod tests {
&TxGasMeter::new_from_sub_limit(u64::MAX.into()),
));
let batched_tx = tx.batch_ref_first_tx();
let vp = EthBridge {
ctx: setup_ctx(
batched_tx.tx,
batched_tx.cmt,
&state,
&gas_meter,
&keys_changed,
&verifiers,
),
token_keys: PhantomData::<TokenKeys>,
};
let vp = EthBridge::new(setup_ctx(
batched_tx.tx,
batched_tx.cmt,
&state,
&gas_meter,
&keys_changed,
&verifiers,
));

let res = vp.validate_tx(&batched_tx, &keys_changed, &verifiers);
assert!(res.is_ok());
Expand Down Expand Up @@ -476,17 +475,14 @@ mod tests {
&TxGasMeter::new_from_sub_limit(u64::MAX.into()),
));
let batched_tx = tx.batch_ref_first_tx();
let vp = EthBridge {
ctx: setup_ctx(
batched_tx.tx,
batched_tx.cmt,
&state,
&gas_meter,
&keys_changed,
&verifiers,
),
token_keys: PhantomData::<TokenKeys>,
};
let vp = EthBridge::new(setup_ctx(
batched_tx.tx,
batched_tx.cmt,
&state,
&gas_meter,
&keys_changed,
&verifiers,
));

let res = vp.validate_tx(&batched_tx, &keys_changed, &verifiers);
assert!(res.is_err());
Expand Down Expand Up @@ -534,17 +530,14 @@ mod tests {
&TxGasMeter::new_from_sub_limit(u64::MAX.into()),
));
let batched_tx = tx.batch_ref_first_tx();
let vp = EthBridge {
ctx: setup_ctx(
batched_tx.tx,
batched_tx.cmt,
&state,
&gas_meter,
&keys_changed,
&verifiers,
),
token_keys: PhantomData::<TokenKeys>,
};
let vp = EthBridge::new(setup_ctx(
batched_tx.tx,
batched_tx.cmt,
&state,
&gas_meter,
&keys_changed,
&verifiers,
));

let res = vp.validate_tx(&batched_tx, &keys_changed, &verifiers);
assert!(res.is_err());
Expand Down
13 changes: 6 additions & 7 deletions crates/ethereum_bridge/src/vp/nut_vp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ where
{
/// Context to interact with the host structures.
pub ctx: Ctx<'ctx, S, CA, EVAL>,
/// Token keys type
pub token_keys: PhantomData<TokenKeys>,
/// Generic types for DI
pub _marker: PhantomData<TokenKeys>,
}

impl<'view, 'ctx: 'view, S, CA, EVAL, TokenKeys> NativeVp<'view>
Expand Down Expand Up @@ -138,7 +138,7 @@ where
pub fn new(ctx: Ctx<'ctx, S, CA, EVAL>) -> Self {
Self {
ctx,
token_keys: PhantomData,
_marker: PhantomData,
}
}
}
Expand Down Expand Up @@ -173,6 +173,8 @@ mod test_nuts {
CA,
>;
type TokenKeys = namada_token::Store<()>;
type NonUsableTokens<'a, S> =
super::NonUsableTokens<'a, S, VpCache<CA>, Eval, TokenKeys>;

/// Run a VP check on a NUT transfer between the two provided addresses.
fn check_nut_transfer(src: Address, dst: Address) -> bool {
Expand Down Expand Up @@ -241,10 +243,7 @@ mod test_nuts {
&verifiers,
VpCache::new(temp_dir(), 100usize),
);
let vp = NonUsableTokens {
ctx,
token_keys: PhantomData::<TokenKeys>,
};
let vp = NonUsableTokens::new(ctx);

// print debug info in case we run into failures
for key in &keys_changed {
Expand Down
9 changes: 3 additions & 6 deletions crates/governance/src/vp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ where
{
/// Context to interact with the host structures.
pub ctx: Ctx<'ctx, S, CA, EVAL>,
/// Read PoS storage
pub pos: PhantomData<PoS>,
/// Token keys
pub token_keys: PhantomData<TokenKeys>,
/// Generic types for DI
pub _marker: PhantomData<(PoS, TokenKeys)>,
}

impl<'view, 'ctx: 'view, S, CA, EVAL, PoS, TokenKeys> NativeVp<'view>
Expand Down Expand Up @@ -231,8 +229,7 @@ where
pub fn new(ctx: Ctx<'ctx, S, CA, EVAL>) -> Self {
Self {
ctx,
pos: PhantomData,
token_keys: PhantomData,
_marker: PhantomData,
}
}

Expand Down
15 changes: 3 additions & 12 deletions crates/ibc/src/vp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,8 @@ where
{
/// Context to interact with the host structures.
pub ctx: Ctx<'ctx, S, CA, EVAL>,
/// Parameters type
pub params: PhantomData<Params>,
/// Governance type
pub gov: PhantomData<Gov>,
/// Token type
pub token: PhantomData<Token>,
/// PoS type
pub pos: PhantomData<PoS>,
/// Generic types for DI
pub _marker: PhantomData<(Params, Gov, Token, PoS)>,
}

impl<'view, 'ctx: 'view, S, CA, EVAL, Params, Gov, Token, PoS> NativeVp<'view>
Expand Down Expand Up @@ -174,10 +168,7 @@ where
pub fn new(ctx: Ctx<'ctx, S, CA, EVAL>) -> Self {
Self {
ctx,
params: PhantomData,
gov: PhantomData,
token: PhantomData,
pos: PhantomData,
_marker: PhantomData,
}
}

Expand Down
6 changes: 3 additions & 3 deletions crates/parameters/src/vp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ where
{
/// Context to interact with the host structures.
pub ctx: Ctx<'ctx, S, CA, EVAL>,
/// Governance type
pub gov: PhantomData<Gov>,
/// Generic types for DI
pub _marker: PhantomData<Gov>,
}

impl<'view, 'ctx: 'view, S, CA, EVAL, Gov> NativeVp<'view>
Expand Down Expand Up @@ -101,7 +101,7 @@ where
pub fn new(ctx: Ctx<'ctx, S, CA, EVAL>) -> Self {
Self {
ctx,
gov: PhantomData,
_marker: PhantomData,
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/proof_of_stake/src/vp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ where
{
/// Context to interact with the host structures.
pub ctx: Ctx<'ctx, S, CA, EVAL>,
/// Governance type
pub gov: PhantomData<Gov>,
/// Generic types for DI
pub _marker: PhantomData<Gov>,
}

impl<'view, 'ctx: 'view, S, CA, EVAL, Gov> NativeVp<'view>
Expand Down Expand Up @@ -327,7 +327,7 @@ where
pub fn new(ctx: Ctx<'ctx, S, CA, EVAL>) -> Self {
Self {
ctx,
gov: PhantomData,
_marker: PhantomData,
}
}

Expand Down
Loading

0 comments on commit 9695d7b

Please sign in to comment.