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

fea(cli): bridge fa deploy cli command #778

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

zcabter
Copy link
Collaborator

@zcabter zcabter commented Jan 20, 2025

Context

Convenience command to deploy an FA bridge given an L1 fa contract and Jstz token contract that implements the deposit endpoint.

Description

  1. Introduces the bridge fa-deploy command and all the necessary contracts with it
  2. Adds a int test but needs to be disabled in CI
  3. Requires upgrade to 1.81, which causes clippy issues that are fixed here

Unfortunately, test coverage is poor due to the disabled CI test

Manually testing the PR

Integration tests: cargo test -p jstz_cli fa_deploy_test
Manual test

# Remember to replace client data dir and octez node endpoint correctly
# curl localhost:54321/config | jq <-- to get jstzd config
cargo run --bin jstzd run
export USE_JSTZD=1
octez-client \
    -d <octez client data dir>
    --endpoint <octez node endpoint>
    originate contract fa-token transferring 0 from bootstrap1 running crates/jstz_cli/tests/resources/fa2.1/fa_token.tz \
    --burn-cap 999 \
    --init 'Pair 1000000000 { Elt "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" 1000000000 } {}'

cargo run -- deploy crates/jstz_cli/tests/resources/fa2.1/fa_jstz_token.minjs --name fa-token -n dev

cargo run -- bridge fa-deploy tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx 1 1000000000  fa-token fa-token --token-id 1 -n dev

octez-client \
    -d <octez client data dir>
    --endpoint <octez node endpoint>
    call fa-token-bridge from tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx \
    --entrypoint "deposit" \
    --arg 'Pair "sr1PuFMgaRUN12rKQ3J2ae5psNtwCxPNmGNK" "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" 1000' \
    --burn-cap 999

@zcabter zcabter force-pushed the ryan-jstz-173/bridge-fa-deploy-cli-command branch from 3fa7edc to 708b929 Compare January 20, 2025 18:29
@zcabter zcabter self-assigned this Jan 20, 2025
@zcabter zcabter force-pushed the ryan-jstz-173/bridge-fa-deploy-cli-command branch from 708b929 to a052ca1 Compare January 21, 2025 09:28
Copy link

codecov bot commented Jan 21, 2025

Codecov Report

Attention: Patch coverage is 17.09402% with 194 lines in your changes missing coverage. Please review.

Project coverage is 48.69%. Comparing base (dc46668) to head (a052ca1).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
crates/jstz_cli/src/bridge/deploy.rs 0.00% 80 Missing ⚠️
crates/jstz_cli/src/lib.rs 0.00% 37 Missing ⚠️
crates/jstz_cli/src/utils.rs 44.23% 27 Missing and 2 partials ⚠️
crates/jstz_cli/src/config.rs 0.00% 19 Missing ⚠️
crates/octez/src/client.rs 0.00% 15 Missing ⚠️
crates/jstzd/src/task/jstzd.rs 0.00% 9 Missing ⚠️
crates/jstzd/src/config.rs 84.21% 3 Missing ⚠️
crates/jstz_cli/src/bridge/mod.rs 0.00% 1 Missing ⚠️
crates/jstz_cli/src/jstz.rs 0.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
crates/jstz_cli/src/bridge/withdraw.rs 0.00% <ø> (ø)
crates/jstz_cli/src/main.rs 0.00% <ø> (ø)
crates/jstz_engine/src/lib.rs 100.00% <ø> (ø)
crates/jstzd/src/lib.rs 52.17% <100.00%> (-3.93%) ⬇️
crates/jstz_cli/src/bridge/mod.rs 0.00% <0.00%> (ø)
crates/jstz_cli/src/jstz.rs 0.00% <0.00%> (ø)
crates/jstzd/src/config.rs 97.13% <84.21%> (-0.46%) ⬇️
crates/jstzd/src/task/jstzd.rs 39.13% <0.00%> (-0.16%) ⬇️
crates/octez/src/client.rs 5.21% <0.00%> (-0.18%) ⬇️
crates/jstz_cli/src/config.rs 30.12% <0.00%> (-0.71%) ⬇️
... and 3 more

... and 58 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dc46668...a052ca1. Read the comment docs.

@zcabter zcabter assigned ryutamago and unassigned zcabter Jan 21, 2025
"Pair {{}} ({}) ({}) {}",
fa_token_object.to_micheline(),
format_ticket_content(ticket_id, ticket_content)?,
total_ticket_supply
Copy link
Collaborator

Choose a reason for hiding this comment

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

does thistoatal_ticket_supply have to do with the the total supply of the fa token?
maybe leave a comment that this ticket represents the number of tokens that can be bridged to L2?

@@ -427,6 +427,17 @@ impl JstzdServer {

Ok(jstzd)
}

pub async fn get_config(&self) -> JstzdConfig {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can reuse this in run

&source.to_base58(),
JSTZ_FA_BRIDGE,
&bridge_storage,
)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit
add error message for bridge deployment failed but ticket suceeds

@@ -42,6 +42,8 @@ pub enum Command {
#[arg(short, long, default_value = None)]
network: Option<NetworkName>,
},
/// Deploys an FA token bridge with minimal functionality.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit:
i found it hard to understand the bridge mechanism at the start, could briefly mention in jstz, bridge consists of the birdge contract and the ticketer etc

@ryutamago ryutamago assigned zcabter and unassigned ryutamago Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants