Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Commit

Permalink
Getting started end-to-end IPC tutorial (#130)
Browse files Browse the repository at this point in the history
* README for subnet lifecycle

* Apply suggestions from code review

Co-authored-by: Jorge Soares <[email protected]>

* Apply suggestions from code review

Co-authored-by: Jorge Soares <[email protected]>

* address comments and set validator net addr

* wip: checkpoints

* update checkpoint section

* rename ipc_agent to ipc-agent

* pretty print list-subnets. Address comments

* update README. Minor fix in list-subnets

* add instructions for send-value

* Update README.md

* Update README.md

* Apply suggestions from code review

Co-authored-by: Jorge Soares <[email protected]>

---------

Co-authored-by: Jorge Soares <[email protected]>
  • Loading branch information
adlrocha and jsoares authored Mar 31, 2023
1 parent 507c009 commit 795487b
Show file tree
Hide file tree
Showing 9 changed files with 454 additions and 53 deletions.
82 changes: 41 additions & 41 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
license-file = "LICENSE"

[package]
name = "ipc_agent"
name = "ipc-agent"
version = "0.1.0"
edition.workspace = true
license-file.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ RUN --mount=type=cache,target=$RUSTUP_HOME,from=rust,source=$RUSTUP_HOME \
# Main stage
FROM debian:bullseye-slim

COPY --from=builder /app/output/bin/ipc_agent /usr/local/bin/ipc_agent
COPY --from=builder /app/output/bin/ipc-agent /usr/local/bin/ipc-agent

ENTRYPOINT ["ipc_agent"]
ENTRYPOINT ["ipc-agent"]

EXPOSE 3030
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all build test lint license check-fmt check-clippy diagrams
.PHONY: all build test lint license check-fmt check-clippy diagrams install_infra

all: test build

Expand All @@ -19,6 +19,9 @@ lint: \
license:
./scripts/add_license.sh

install-infra:
./scripts/install_infra.sh

check-fmt:
cargo fmt --all --check

Expand Down
376 changes: 372 additions & 4 deletions README.md

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions scripts/install_infra.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
#
# Builds docker image and install the ipc-scripts required to conveniently
# deploy the infrastructure for IPC subnets.
rm -rf ./lotus
git clone https://github.com/consensus-shipyard/lotus.git
cd ./lotus
docker build -t eudico .
cd ..
mkdir -p ./bin
cp -r ./lotus/scripts/ipc ./bin/ipc-infra
rm -rf ./lotus
17 changes: 16 additions & 1 deletion src/cli/commands/manager/list_subnets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
use async_trait::async_trait;
use clap::Args;
use fvm_shared::bigint::BigInt;
use fvm_shared::econ::TokenAmount;
use std::collections::HashMap;
use std::fmt::Debug;
use std::str::FromStr;

use crate::cli::commands::get_ipc_agent_url;
use crate::cli::{CommandLineHandler, GlobalArguments};
Expand Down Expand Up @@ -39,7 +42,19 @@ impl CommandLineHandler for ListSubnets {
)
.await?;

log::info!("found child subnets: {subnets:?}");
for (_, s) in subnets.iter() {
let u = BigInt::from_str(&s.stake).unwrap();
let stake = TokenAmount::from_atto(u);
let u = BigInt::from_str(&s.circ_supply).unwrap();
let supply = TokenAmount::from_atto(u);
log::info!(
"{} - status: {}, collateral: {} FIL, circ.supply: {} FIL",
s.id,
s.status,
stake,
supply,
);
}

Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod commands;
use crate::config::Config;
pub use commands::cli;

const DEFAULT_CONFIG_PATH: &str = ".ipc_agent/config.toml";
const DEFAULT_CONFIG_PATH: &str = ".ipc-agent/config.toml";

/// The trait that represents the abstraction of a command line handler. To implement a new command
/// line operation, implement this trait and register it.
Expand All @@ -35,7 +35,7 @@ pub struct GlobalArguments {
#[arg(
short,
long,
help = "The toml config file path for IPC Agent, default to ${HOME}/.ipc_agent/config.toml"
help = "The toml config file path for IPC Agent, default to ${HOME}/.ipc-agent/config.toml"
)]
config_path: Option<String>,
}
Expand Down
5 changes: 4 additions & 1 deletion src/lotus/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ mod methods {
/// The default gateway actor address
const GATEWAY_ACTOR_ADDRESS: &str = "t064";
/// The default state wait confidence value
const STATE_WAIT_CONFIDENCE: u8 = 5;
/// TODO: we can afford 2 epochs confidence (and even one)
/// with Mir, but with Filecoin mainnet this should be increased
/// in case there are reorgs.
const STATE_WAIT_CONFIDENCE: u8 = 2;
/// We dont set a limit on the look back epoch, i.e. check against latest block
const STATE_WAIT_LOOK_BACK_NO_LIMIT: i8 = -1;
/// We are not replacing any previous messages.
Expand Down

0 comments on commit 795487b

Please sign in to comment.