Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion deployment/lib/local-files.nu
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ export def write-subnet-config [dest: string, --bootstrap] {
$cfg | save -f $dest
}

const docker_dir = path self ../docker
export def build-setup-docker-image [] {
cd docker
cd $docker_dir
docker build ...[
--build-arg $"fendermint_image=($env.state.config.fendermint_image)"
-t $env.state.config.setup_image
Expand Down Expand Up @@ -123,3 +124,9 @@ export def write-recall-cli-config [] {

$cfg | save -f ($env.state.config.workdir | path join "networks.toml")
}

export def update-git-submodules [] {
const ipc_dir = path self ../..
cd $ipc_dir
git submodule update --init --recursive
}
2 changes: 2 additions & 0 deletions deployment/lib/steps.nu
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use ./subnet.nu

export def get-create-subnet-steps [get_funds_fn: closure] {
[
{ name: "update_submodules" fn: { local-files update-git-submodules }}

{ name: "build_setup_image" fn: { local-files build-setup-docker-image} }
{ name: "create_ipc_config" fn: { parent-chain write-ipc-cli-config }}

Expand Down
26 changes: 22 additions & 4 deletions deployment/lib/subnet.nu
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,23 @@ export def send-funds [src: record, dest:record, amount: float] {
]
}

def --env set-up-recall-cli [private_key: string] {
let cfg = ($env.state.config.workdir | path join "networks.toml")
$env.RECALL_NETWORK_CONFIG_FILE = $cfg
$env.RECALL_NETWORK = $env.state.config.network
$env.RECALL_PRIVATE_KEY = $private_key
}

# WARNING: this command invokes `recall` CLI on your PATH!!!
export def set-network-admin [] {
let cfg = ($env.state.config.workdir | path join "networks.toml")
recall -c $cfg -n $env.state.config.network subnet config set-admin --private-key $env.state.validator0.private_key $env.state.network_admin.address
set-up-recall-cli $env.state.validator0.private_key
recall subnet config set-admin $env.state.network_admin.address
}

# WARNING: this command invokes `recall` CLI on your PATH!!!
export def set-network-config [] {
let cfg = ($env.state.config.workdir | path join "networks.toml")
recall -c $cfg -n $env.state.config.network subnet config set --private-key $env.state.network_admin.private_key ...[
set-up-recall-cli $env.state.validator0.private_key
recall subnet config set ...[
--blob-capacity (10 * 2 ** 40)
--token-credit-rate (1e36)
--blob-credit-debit-interval 600
Expand All @@ -87,3 +94,14 @@ export def set-network-config [] {
--account-debit-batch-size 1000
]
}

export def run-recall-cli-test [] {
set-up-recall-cli $env.state.faucet_owner.private_key
recall account info
recall account credit stats
recall account credit buy 2
recall account credit stats
let addr = recall bucket create --alias test1 | tee {print} | from json | get address | inspect
recall bucket add -a $addr --key a1 ./set-up-nu.sh
recall bucket get -a $addr a1
}
9 changes: 6 additions & 3 deletions deployment/lib/util.nu
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

export def log [str: string, --color: string = "yellow"] {
print $"(ansi cyan)== [create-subnet] (ansi $color)($str)(ansi reset)"
export def log [str: string,
--prefix: string = "create-subnet",
--color: string = "yellow"] {
print $"(ansi cyan)== [($prefix)] (ansi $color)($str)(ansi reset)"
}

# Run command in setup docker image
Expand Down Expand Up @@ -129,7 +131,8 @@ export def get-base-config [
let fendermint_commit = $fendermint_image | str replace -r ".*sha-" ""
if $local_commit != $fendermint_commit {
if ($env.SKIP_COMMIT_MATCH_CHECK? | is-empty) {
print $"ERROR: local commit ($local_commit) does not match fendermint image ($fendermint_image)"
print $"ERROR: local ipc commit ($local_commit) does not match fendermint image ($fendermint_image)"
print "You can disable this check by setting SKIP_COMMIT_MATCH_CHECK=true"
exit 1
}
}
Expand Down
8 changes: 6 additions & 2 deletions deployment/localnet.nu
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def "main run" [

let steps = [
{ name: "localnet_init" fn: { localnet init-state $workdir $fendermint_image}}
{ name: "update_submodules" fn: { git submodule update --init --recursive }}
...$build_fendermint_image
{ name: "localnet_start_anvil" fn: {localnet run-anvil $workdir}}
...(steps get-create-subnet-steps $get_funds_step)
Expand Down Expand Up @@ -95,14 +94,19 @@ def "main run-dind" [
--workdir: string = "./localnet-data", # where to store networks.toml and state.yml
] {

let image = $"textile/recall-localnet:($tag)"
if $tag == "latest" {
docker pull $image
}

docker run ...[
--rm -d --name localnet
-p 127.0.0.1:8545:8545
-p 127.0.0.1:8645:8645
-p 127.0.0.1:8001:8001
-p 127.0.0.1:26657:26657
--privileged
$"textile/recall-localnet:($tag)"
$image
]
print "Container localnet is running."

Expand Down
Loading