Skip to content

feat: add localnet scripts#620

Merged
sam701 merged 43 commits intomainfrom
alexei/localnet-scripts
May 21, 2025
Merged

feat: add localnet scripts#620
sam701 merged 43 commits intomainfrom
alexei/localnet-scripts

Conversation

@sam701
Copy link
Contributor

@sam701 sam701 commented May 19, 2025

This PR contains scripts (a copy from recall-deploy) to deploy localnet on local docker and to create a single docker image with the entire localnet inside.

This is intended to replace deploy.sh, ref: #603

$cfg = ($cfg | merge deep {
subnet: {
addresses: {
credit_manager: $env.state.creditManager_contract_address
Copy link
Contributor

Choose a reason for hiding this comment

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

@sam701 we no longer need to deploy the wrapper / "manager" contracts. i just merged ad096f2 in the contracts repo, which removes them entirely.

i created issues in https://github.com/recallnet/recall-docker-compose/issues/60 and https://github.com/recallnet/recall-deploy/issues/308 to account for this elsewhere. (i should have gave you a heads up wrt the IaC...sorry about that.)

Copy link
Contributor

@dtbuchholz dtbuchholz May 19, 2025

Choose a reason for hiding this comment

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

or, i suppose we could keep your existing logic in this PR. then, create a follow up PR that updates ipc's recall-contracts submodule to ad096f2, and align that with the two issues mentioned in the comment above.

if that makes sense to you, i created this ticket as a follow up: #621

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dtbuchholz cool, thank you! The scripts in recall-deploy will be removed once this PR is merged. I'll move your issue from recall-deploy to this repo.

Copy link
Contributor

@dtbuchholz dtbuchholz left a comment

Choose a reason for hiding this comment

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

@sam701 works great. two small pieces of feedback:

  • it'd be nice to have a "stop" script, too, just to make it easy to shut down the network. not a blocker tho.
  • i noticed this creates a localnet-data/ dir root—should we .gitignore this?

per your README, is it correct in stating: the only dependency a user needs is nu? for docs site purposes, i'm just double checking there's no longer a need for all of these build deps (which is a great DX improvement).

@sam701
Copy link
Contributor Author

sam701 commented May 20, 2025

  • it'd be nice to have a "stop" script, too, just to make it easy to shut down the network. not a blocker tho.

It's already there: ./localnet.nu stop. You can see all available commands with ./localnet.nu -h

  • i noticed this creates a localnet-data/ dir root—should we .gitignore this?

Yes in deployment/.gitignore

per your README, is it correct in stating: the only dependency a user needs is nu? for docs site purposes, i'm just double checking there's no longer a need for all of these build deps (which is a great DX improvement).

That is correct, there is no need for any additional tools (only docker). All the tools (cast, ipc-cli, etc.), that are actually required by the setup process, are called from docker containers.

@dtbuchholz
Copy link
Contributor

It's already there: ./localnet.nu stop. You can see all available commands with ./localnet.nu -h

duh, totally missed that. perfect.

Yes in deployment/.gitignore

ah so i tried running it from root like ./deployment/localnet.nu run, and that was my problem. all good.

@dtbuchholz
Copy link
Contributor

@sam701 but, i just came across a weird issue. after stopping the localnet manually with docker, i tried running ./localnet.nu run again. oddly, it just logs this one line, and then doesn't do anything. any ideas?

== [step localnet] == done ==

i then try to rebuild the image manually via the ./localnet.nu build-docker-image command. this exits with the following:

== [step build-docker-image] docker_image_start_localnet
== [step localnet] == done ==
== [step build-docker-image] docker_image_stop_localnet_1
== [step build-docker-image] docker_image_stop_localnet_0
== [step build-docker-image] docker_image_stop_anvil
Error response from daemon: No such container: localnet-anvil
Error: nu::shell::eval_block_with_input

  × Eval block failed with pipeline input
     ╭─[/Users/dtb/rcl/ipc/deployment/localnet.nu:129:5]
 128 │     ...$shutdown_steps
 129 │     { name: "docker_image_stop_anvil" fn: {localnet stop-anvil}}
     ·     ──────────────────────────────┬─────────────────────────────
     ·                                   ╰── source value
 130 │     { name: "docker_image_build" fn: {localnet build-dind-image $local_image_tag $push_multi_arch_tags }}
     ╰────

Error: nu::shell::non_zero_exit_code

  × External command had a non-zero exit code
     ╭─[/Users/dtb/rcl/ipc/deployment/lib/localnet.nu:153:3]
 152 │   sleep 1sec
 153 │   docker stop localnet-anvil
     ·   ───┬──
     ·      ╰── exited with code 1
 154 │ 
     ╰────

@sam701
Copy link
Contributor Author

sam701 commented May 21, 2025

@sam701 but, i just came across a weird issue. after stopping the localnet manually with docker, i tried running ./localnet.nu run again. oddly, it just logs this one line, and then doesn't do anything. any ideas?

== [step localnet] == done ==

It's a good point! It is built to be retryable because any step can fail, especially on testnet. That means when you run ./localnet.nun run it continues where it stopped using its workdir (default ./localnet-data). So if you do want to start from scratch, you have to pass an additional flag --reset that deletes localnet-data first. But that absolutely makes sense to be able to stop and start the network. I'll add this functionality.

i then try to rebuild the image manually via the ./localnet.nu build-docker-image command. this exits with the following:

== [step build-docker-image] docker_image_start_localnet
== [step localnet] == done ==
== [step build-docker-image] docker_image_stop_localnet_1
== [step build-docker-image] docker_image_stop_localnet_0
.....

This has the same nature as above because ./localnet.nu build-docker-image uses the same workdir localnet-data. I'll check this too.

@sam701 sam701 merged commit 4df4ba1 into main May 21, 2025
15 checks passed
@sam701 sam701 deleted the alexei/localnet-scripts branch May 21, 2025 14:24
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