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

fix(sui): be consistent about sui config directory #20474

Merged
merged 1 commit into from
Nov 29, 2024
Merged

Conversation

amnn
Copy link
Member

@amnn amnn commented Nov 29, 2024

Description

When a --config is supplied and it is a directory, we treat it as the sui config directory in some but not all cases. This changes makes it so that if --config does not look like a YAML file, then it is treated like it should be the config directory, and that location is used everywhere the config directory is expected.

Test plan

Manually tested running sui start, sui start --network.config ...:

$ sui start
$ sui start --force-regenesis
$ sui start --network.config ~/.sui/sui_config
$ sui start --network.config ~/.sui/sui_config/network.yaml
$ sui start --network.config "$CUSTOM_CONFIG"
$ sui start --network.config "$CUSTOM_CONFIG/network.yaml"

A custom config directory can be generated by taking a copy of the current config directory and tweaking it:

$ cp -r ~/.sui/sui_config $CUSTOM_CONFIG
$ rm "$CUSTOM_CONFIG/sui.keystore" "$CUSTOM_CONFIG/sui.aliases"
$ sed -i '' "s:$HOME/.sui/sui_config:$CUSTOM_CONFIG:" "$CUSTOM_CONFIG/network.yaml"

You can test that the local network is up and running by querying for its chain identifier:

$ curl -LX POST  "http://localhost:9000" \
    --header 'Content-Type: application/json' \
    --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "sui_getChainIdentifier",
  "params": []
}' | jq .

Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • Indexer:
  • JSON-RPC:
  • GraphQL:
  • CLI: Support fully overriding the config directory during sui start.
  • Rust SDK:
  • REST API:

## Description
When a `--config` is supplied and it is a directory, we treat it as the
sui config directory in some but not all cases. This changes makes it so
that if `--config` does not look like a YAML file, then it is treated
like it should be the config directory, and that location is used
everywhere the config directory is expected.

## Test plan

Manually tested running `sui start`, `sui start --config ...`.
@amnn amnn requested review from stefan-mysten and a team November 29, 2024 19:33
@amnn amnn self-assigned this Nov 29, 2024
Copy link

vercel bot commented Nov 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Nov 29, 2024 7:33pm
sui-kiosk ⬜️ Ignored (Inspect) Nov 29, 2024 7:33pm
sui-typescript-docs ⬜️ Ignored (Inspect) Nov 29, 2024 7:33pm

@amnn amnn temporarily deployed to sui-typescript-aws-kms-test-env November 29, 2024 19:33 — with GitHub Actions Inactive
Copy link
Contributor

@stefan-mysten stefan-mysten left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this, though I am a scared of this change. The existing logic there is a mess :p.

Comment on lines +672 to +673
if !network_config.exists() {
genesis(None, None, None, false, epoch_duration_ms, None, false)
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't this potentially override other settings in the sui_config dir?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, genesis will fail if the folder is not empty, so we're probably safe.

Copy link
Member Author

Choose a reason for hiding this comment

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

This logic is pre-existing, but judging by the error message, genesis will not run if the directory is non-empty.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I did that messy logic 😅 trying to preserve compatibility between sui-test-validator and sui start. :D

@amnn
Copy link
Member Author

amnn commented Nov 29, 2024

I'm a little scared as well -- this change actually started as a pretty benign formatting change for the extra long-line containing the error message, but then I couldn't resist pulling the thread that I noticed with the config directories being set in various places...

@amnn amnn enabled auto-merge (squash) November 29, 2024 19:44
@amnn amnn merged commit 387b0f0 into main Nov 29, 2024
52 checks passed
@amnn amnn deleted the amnn/clean-start branch November 29, 2024 20:01
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