Skip to content

Commit e88a530

Browse files
authored
feat: localnet improvements (#632)
This PR contains script modifications that allow the testnet scripts to reuse the same scripts as the localnet deployment.
1 parent d04bb80 commit e88a530

5 files changed

Lines changed: 44 additions & 10 deletions

File tree

deployment/lib/local-files.nu

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ export def write-subnet-config [dest: string, --bootstrap] {
5555
$cfg | save -f $dest
5656
}
5757

58+
const docker_dir = path self ../docker
5859
export def build-setup-docker-image [] {
59-
cd docker
60+
cd $docker_dir
6061
docker build ...[
6162
--build-arg $"fendermint_image=($env.state.config.fendermint_image)"
6263
-t $env.state.config.setup_image
@@ -123,3 +124,9 @@ export def write-recall-cli-config [] {
123124

124125
$cfg | save -f ($env.state.config.workdir | path join "networks.toml")
125126
}
127+
128+
export def update-git-submodules [] {
129+
const ipc_dir = path self ../..
130+
cd $ipc_dir
131+
git submodule update --init --recursive
132+
}

deployment/lib/steps.nu

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use ./subnet.nu
66

77
export def get-create-subnet-steps [get_funds_fn: closure] {
88
[
9+
{ name: "update_submodules" fn: { local-files update-git-submodules }}
10+
911
{ name: "build_setup_image" fn: { local-files build-setup-docker-image} }
1012
{ name: "create_ipc_config" fn: { parent-chain write-ipc-cli-config }}
1113

deployment/lib/subnet.nu

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,23 @@ export def send-funds [src: record, dest:record, amount: float] {
6868
]
6969
}
7070

71+
def --env set-up-recall-cli [private_key: string] {
72+
let cfg = ($env.state.config.workdir | path join "networks.toml")
73+
$env.RECALL_NETWORK_CONFIG_FILE = $cfg
74+
$env.RECALL_NETWORK = $env.state.config.network
75+
$env.RECALL_PRIVATE_KEY = $private_key
76+
}
77+
7178
# WARNING: this command invokes `recall` CLI on your PATH!!!
7279
export def set-network-admin [] {
73-
let cfg = ($env.state.config.workdir | path join "networks.toml")
74-
recall -c $cfg -n $env.state.config.network subnet config set-admin --private-key $env.state.validator0.private_key $env.state.network_admin.address
80+
set-up-recall-cli $env.state.validator0.private_key
81+
recall subnet config set-admin $env.state.network_admin.address
7582
}
7683

7784
# WARNING: this command invokes `recall` CLI on your PATH!!!
7885
export def set-network-config [] {
79-
let cfg = ($env.state.config.workdir | path join "networks.toml")
80-
recall -c $cfg -n $env.state.config.network subnet config set --private-key $env.state.network_admin.private_key ...[
86+
set-up-recall-cli $env.state.validator0.private_key
87+
recall subnet config set ...[
8188
--blob-capacity (10 * 2 ** 40)
8289
--token-credit-rate (1e36)
8390
--blob-credit-debit-interval 600
@@ -87,3 +94,14 @@ export def set-network-config [] {
8794
--account-debit-batch-size 1000
8895
]
8996
}
97+
98+
export def run-recall-cli-test [] {
99+
set-up-recall-cli $env.state.faucet_owner.private_key
100+
recall account info
101+
recall account credit stats
102+
recall account credit buy 2
103+
recall account credit stats
104+
let addr = recall bucket create --alias test1 | tee {print} | from json | get address | inspect
105+
recall bucket add -a $addr --key a1 ./set-up-nu.sh
106+
recall bucket get -a $addr a1
107+
}

deployment/lib/util.nu

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

2-
export def log [str: string, --color: string = "yellow"] {
3-
print $"(ansi cyan)== [create-subnet] (ansi $color)($str)(ansi reset)"
2+
export def log [str: string,
3+
--prefix: string = "create-subnet",
4+
--color: string = "yellow"] {
5+
print $"(ansi cyan)== [($prefix)] (ansi $color)($str)(ansi reset)"
46
}
57

68
# Run command in setup docker image
@@ -129,7 +131,8 @@ export def get-base-config [
129131
let fendermint_commit = $fendermint_image | str replace -r ".*sha-" ""
130132
if $local_commit != $fendermint_commit {
131133
if ($env.SKIP_COMMIT_MATCH_CHECK? | is-empty) {
132-
print $"ERROR: local commit ($local_commit) does not match fendermint image ($fendermint_image)"
134+
print $"ERROR: local ipc commit ($local_commit) does not match fendermint image ($fendermint_image)"
135+
print "You can disable this check by setting SKIP_COMMIT_MATCH_CHECK=true"
133136
exit 1
134137
}
135138
}

deployment/localnet.nu

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ def "main run" [
6161

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

97+
let image = $"textile/recall-localnet:($tag)"
98+
if $tag == "latest" {
99+
docker pull $image
100+
}
101+
98102
docker run ...[
99103
--rm -d --name localnet
100104
-p 127.0.0.1:8545:8545
101105
-p 127.0.0.1:8645:8645
102106
-p 127.0.0.1:8001:8001
103107
-p 127.0.0.1:26657:26657
104108
--privileged
105-
$"textile/recall-localnet:($tag)"
109+
$image
106110
]
107111
print "Container localnet is running."
108112

0 commit comments

Comments
 (0)