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

feat: add (local|testnet|mainnet) default networks #1408

Merged
merged 1 commit into from
Jul 2, 2024

Conversation

chadoh
Copy link
Contributor

@chadoh chadoh commented Jun 26, 2024

Similar to how we support --network futurenet before you even set it.

No need to make people go look it up on https://developers.stellar.org/docs/reference/networks

This adds a dependency on phf to construct a compile-time Map of named networks to named network settings.

It also lists default networks with the network ls [-l] commands, and slightly updates (fixes, really) the behavior of network ls. Previously, if you had a local and global network named the same thing, network ls would show that name twice. Now it will only show them once. When you network ls -l, it will show all name collisions.

$ stellar network ls
future
futurenet
local
testnet
mainnet


$ stellar network ls -l
Local "/Users/chadoh/code/s/cli/.soroban/network/future.toml"
Name: future
Network {
    rpc_url: "https://rpc-futurenet.stellar.org:443",
    network_passphrase: "Test SDF Future Network ; October 2022",
}

Local "/Users/chadoh/code/s/cli/.soroban/network/futurenet.toml"
Name: futurenet
Network {
    rpc_url: "https://rpc-futurenet.stellar.org:443",
    network_passphrase: "Test SDF Future Network ; October 2022",
}

Global "/Users/chadoh/.config/soroban/network/future.toml"
Name: future
Network {
    rpc_url: "https://rpc-futurenet.stellar.org:443",
    network_passphrase: "Test SDF Future Network ; October 2022",
}

Global "/Users/chadoh/.config/soroban/network/local.toml"
Name: local
Network {
    rpc_url: "http://localhost:8000/rpc",
    network_passphrase: "Standalone Network ; February 2017",
}

Global "/Users/chadoh/.config/soroban/network/testnet.toml"
Name: testnet
Network {
    rpc_url: "https://soroban-testnet.stellar.org",
    network_passphrase: "Test SDF Network ; September 2015",
}

Default
Name: local
Network {
    rpc_url: "http://localhost:8000/rpc",
    network_passphrase: "Standalone Network ; February 2017",
}

Default
Name: futurenet
Network {
    rpc_url: "https://soroban-testnet.stellar.org",
    network_passphrase: "Test SDF Network ; September 2015",
}

Default
Name: mainnet
Network {
    rpc_url: "Bring Your Own: https://developers.stellar.org/docs/data/rpc/rpc-providers",
    network_passphrase: "Public Global Stellar Network ; September 2015",
}

Default
Name: testnet
Network {
    rpc_url: "https://rpc-futurenet.stellar.org:443",
    network_passphrase: "Test SDF Future Network ; October 2022",
}

@chadoh chadoh requested a review from willemneal June 26, 2024 19:36
Copy link
Member

@willemneal willemneal left a comment

Choose a reason for hiding this comment

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

Looks good to me. One thing to check and it might have been filled as an issue in the past, but do the default networks show up when using network ls? Should they?

@janewang
Copy link
Contributor

Amazing and finally. For mainnet, could we also set the network passphrase please 🙏

@chadoh
Copy link
Contributor Author

chadoh commented Jun 26, 2024

do the default networks show up when using network ls?

They do not.

Should they?

Good question! @janewang?


@willemneal did you see the "Known Limitations" section? Are these tests being run? Which CI job runs them?

@janewang
Copy link
Contributor

janewang commented Jun 26, 2024

Should they?

Yes, don't me think.

@chadoh chadoh force-pushed the feat/default-testnet branch from 7079f39 to bff30ea Compare June 27, 2024 14:33
@chadoh chadoh changed the title feat: add --network testnet default setting feat: add --network [testnet|mainnet] default settings Jun 27, 2024
@chadoh
Copy link
Contributor Author

chadoh commented Jun 27, 2024

For mainnet, could we also set the network passphrase please

@willemneal is there a straightforward way to do this? We currently require a Network to have both rpc_url and network_passphrase both set. Maybe we make a default that looks something like this?

Network {
    rpc_url: "https://example.com/bring-your-own-rpc".to_owned(), 
    network_passphrase: "Public Global Stellar Network ; September 2015".to_owned(),
},

@janewang
Copy link
Contributor

For rpc_url, we have a page on the dev docs that lists all available mainnet rpc in the ecosystem. This page is likely a good place to send someone who needs a mainnet rpc url: https://developers.stellar.org/docs/data/rpc/rpc-providers

@chadoh chadoh changed the title feat: add --network [testnet|mainnet] default settings feat: add --network [local|testnet|mainnet] default settings Jul 1, 2024
@chadoh chadoh force-pushed the feat/default-testnet branch from bff30ea to fb9868e Compare July 1, 2024 19:04
@chadoh chadoh changed the title feat: add --network [local|testnet|mainnet] default settings feat: add (local|testnet|mainnet) default networks Jul 1, 2024
@chadoh
Copy link
Contributor Author

chadoh commented Jul 1, 2024

Great idea, @janewang! I've updated the PR description to show the full output of network ls and network ls -l; here's what mainnet looks like with the long listing:

Default
Name: mainnet
Network {
    rpc_url: "Bring Your Own: https://developers.stellar.org/docs/data/rpc/rpc-providers",
    network_passphrase: "Public Global Stellar Network ; September 2015",
}`

@chadoh chadoh force-pushed the feat/default-testnet branch from fb9868e to 3c8ae9f Compare July 1, 2024 19:51
@chadoh chadoh requested a review from willemneal July 2, 2024 13:43
Copy link
Member

@willemneal willemneal left a comment

Choose a reason for hiding this comment

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

As I have been saying for sometime the config needs some refactoring but this looks good to me!

@chadoh chadoh self-assigned this Jul 2, 2024
@chadoh chadoh enabled auto-merge (squash) July 2, 2024 20:18
Similar to how we support `--network futurenet` before you even set it.

No need to make people go look it up on https://developers.stellar.org/docs/reference/networks

This adds a dependency on [phf](https://crates.io/crates/phf) to
construct a compile-time Map of named networks to named network
settings.

It also lists default networks with the `network ls [-l]` commands, and
slightly updates (fixes, really) the behavior of `network ls`.
Previously, if you had a local and global network named the same thing,
`network ls` would show that name twice. Now it will only show them
once. When you `network ls -l`, it will show all name collisions.

    $ cargo run -q -- network ls
    future
    futurenet
    local
    testnet
    mainnet

    $ cargo run -q -- network ls -l
    Local "/Users/chadoh/code/s/cli/.soroban/network/future.toml"
    Name: future
    Network {
        rpc_url: "https://rpc-futurenet.stellar.org:443",
        network_passphrase: "Test SDF Future Network ; October 2022",
    }

    Local "/Users/chadoh/code/s/cli/.soroban/network/futurenet.toml"
    Name: futurenet
    Network {
        rpc_url: "https://rpc-futurenet.stellar.org:443",
        network_passphrase: "Test SDF Future Network ; October 2022",
    }

    Global "/Users/chadoh/.config/soroban/network/future.toml"
    Name: future
    Network {
        rpc_url: "https://rpc-futurenet.stellar.org:443",
        network_passphrase: "Test SDF Future Network ; October 2022",
    }

    Global "/Users/chadoh/.config/soroban/network/local.toml"
    Name: local
    Network {
        rpc_url: "http://localhost:8000/rpc",
        network_passphrase: "Standalone Network ; February 2017",
    }

    Global "/Users/chadoh/.config/soroban/network/testnet.toml"
    Name: testnet
    Network {
        rpc_url: "https://soroban-testnet.stellar.org",
        network_passphrase: "Test SDF Network ; September 2015",
    }

    Default
    Name: local
    Network {
        rpc_url: "http://localhost:8000/rpc",
        network_passphrase: "Standalone Network ; February 2017",
    }

    Default
    Name: futurenet
    Network {
        rpc_url: "https://soroban-testnet.stellar.org",
        network_passphrase: "Test SDF Network ; September 2015",
    }

    Default
    Name: mainnet
    Network {
        rpc_url: "https://example.com/bring-your-own",
        network_passphrase: "Public Global Stellar Network ; September 2015",
    }

    Default
    Name: testnet
    Network {
        rpc_url: "https://rpc-futurenet.stellar.org:443",
        network_passphrase: "Test SDF Future Network ; October 2022",
    }
@chadoh chadoh force-pushed the feat/default-testnet branch from 3c8ae9f to 58d5cc3 Compare July 2, 2024 20:24
@chadoh chadoh merged commit dafbd73 into stellar:main Jul 2, 2024
24 checks passed
elizabethengelman pushed a commit to AhaLabs/stellar-cli that referenced this pull request Jul 3, 2024
Similar to how we support `--network futurenet` before you even set it.

No need to make people go look it up on https://developers.stellar.org/docs/reference/networks

This adds a dependency on [phf](https://crates.io/crates/phf) to
construct a compile-time Map of named networks to named network
settings.

It also lists default networks with the `network ls [-l]` commands, and
slightly updates (fixes, really) the behavior of `network ls`.
Previously, if you had a local and global network named the same thing,
`network ls` would show that name twice. Now it will only show them
once. When you `network ls -l`, it will show all name collisions.

    $ cargo run -q -- network ls
    future
    futurenet
    local
    testnet
    mainnet

    $ cargo run -q -- network ls -l
    Local "/Users/chadoh/code/s/cli/.soroban/network/future.toml"
    Name: future
    Network {
        rpc_url: "https://rpc-futurenet.stellar.org:443",
        network_passphrase: "Test SDF Future Network ; October 2022",
    }

    Local "/Users/chadoh/code/s/cli/.soroban/network/futurenet.toml"
    Name: futurenet
    Network {
        rpc_url: "https://rpc-futurenet.stellar.org:443",
        network_passphrase: "Test SDF Future Network ; October 2022",
    }

    Global "/Users/chadoh/.config/soroban/network/future.toml"
    Name: future
    Network {
        rpc_url: "https://rpc-futurenet.stellar.org:443",
        network_passphrase: "Test SDF Future Network ; October 2022",
    }

    Global "/Users/chadoh/.config/soroban/network/local.toml"
    Name: local
    Network {
        rpc_url: "http://localhost:8000/rpc",
        network_passphrase: "Standalone Network ; February 2017",
    }

    Global "/Users/chadoh/.config/soroban/network/testnet.toml"
    Name: testnet
    Network {
        rpc_url: "https://soroban-testnet.stellar.org",
        network_passphrase: "Test SDF Network ; September 2015",
    }

    Default
    Name: local
    Network {
        rpc_url: "http://localhost:8000/rpc",
        network_passphrase: "Standalone Network ; February 2017",
    }

    Default
    Name: futurenet
    Network {
        rpc_url: "https://soroban-testnet.stellar.org",
        network_passphrase: "Test SDF Network ; September 2015",
    }

    Default
    Name: mainnet
    Network {
        rpc_url: "https://example.com/bring-your-own",
        network_passphrase: "Public Global Stellar Network ; September 2015",
    }

    Default
    Name: testnet
    Network {
        rpc_url: "https://rpc-futurenet.stellar.org:443",
        network_passphrase: "Test SDF Future Network ; October 2022",
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants