-
Notifications
You must be signed in to change notification settings - Fork 2.6k
client: Replace unsafe_rpc_expose
with an RpcMethods
enum
#5729
Conversation
It looks like @Xanewok signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
5f8a3e9
to
da72329
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, tiny issues to address. And we should decide on how to deprecate the old options - is there a policy now? CC @bkchr ?
client/cli/src/commands/runcmd.rs
Outdated
/// | ||
/// Same as `--rpc-external`. | ||
#[structopt(long = "unsafe-rpc-external")] | ||
pub unsafe_rpc_external: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, these options should stay. They suppress the warning in case you are not a validator and allow you to expose the interface in case you are.
Solving the docker case should be via a separate flag, see #5418
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On a second though, perhaps it's actually a good idea to remove them and simplify the CLI. I wonder if we should rather deprecate them gracefuly (i.e. keep them for now, and make them an alias of --rpc-external
but print a warning when used).
77159c5
to
98394ff
Compare
Left out the removal of For validator nodes, passing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
All green except
Let me retrigger the CI |
8574bb7
to
4852d1a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CLI is purrfect 🐱
@Xanewok needs resolving and possibly a Polkadot companion PR submitting |
@Xanework status? |
Will resolve this today, sorry for the delay.
…On Mon, 4 May 2020 at 14:08, Bastian Köcher ***@***.***> wrote:
@Xanework status?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#5729 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAXTFXOKXEQ4KA6WHYFP4A3RP2V3PANCNFSM4MNPDX4Q>
.
|
which can be either Default, Safe or Unsafe. The idea is to have the following: | | --rpc-external=false | --rpc-external=true | |--------------------- |------------------- |----------------- | | --rpc-methods=Default | | unsafe calls denied | | --rpc-methods=Safe | unsafe calls denied | unsafe calls denied | | --rpc-methods=Unsafe | | | Since the previous `unsafe-rpc-expose` option was confusing.
Co-Authored-By: Cecile Tonglet <cecile.tonglet@cecton.com>
Checks are all green and as far as I understand, this does not affect Polkadot since the changes here touch CLI mostly, which are contained already as a flattened base struct in the @gnunicorn is this good to merge? |
@Xanewok please do not force-push, it reverts history and makes it harder to review – just use regular merges, thus a reviewer can use the "Review only changes since you've last seen" to speed up the process. We squash-merge anyways, all merge commit are going away then. |
Will do. I'm am used to rebasing on master + merging all of the commits from a feature branch and so wanted to avoid multiple merge commits but we're squashing anyway so there won't be any clutter in the first place 👍 Sorry about that. |
To facilitate the review, the only bits needed resolving where import directives:
and the rest stayed the same. |
client/cli/src/commands/run_cmd.rs
Outdated
/// Please do this if you know what you're doing. | ||
#[structopt(long = "unsafe-rpc-expose")] | ||
pub unsafe_rpc_expose: bool, | ||
/// Defaults to `Safe` (allow only a safe subset of RPC methods) if RPC is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this documentation reads very confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You describe the possible values, but not the Default
variant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it strikes a good balance without being very explicit - variants of Safe
and Unsafe
are explained (which can be explicitly picked and the behaviour is as explained) and Default
, well, defaults to one of them, depending on the situation as listed.
Do you have any concrete example on how you'd like to improve it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs don't specify what happens with Default
though, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You say that it defaults to Safe
, which is not true. It will default to Safe
, when the RPC port is exposed externally.
The user can see all the values this CLI accepts by looking into --help
and the user also sees the default value. The docs should describe that this argument is doing, so that the user can decide which value he wants.
Declare which RPC methods should be exposed under different conditions:
- `Default`: Expose safe & unsafe RPC methods when the RPC is only reachable on localhost. If the RPC port is reachable on all interfaces only the safe RPC methods are exposed.
- `Safe`: Only expose safe RPC methods under any conditions.
- `Unsafe`: Expose safe & unsafe RPC methods under any condition.
Something like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// RPC methods to expose.
///
/// The `Unsafe` variant allows every RPC method to be called, while the
/// `Safe` variant only allows for its safe subset.
/// If `Default` variant is specified, it acts as `Safe` if RPC is served
/// externally, e.g. when `--{rpc,ws}-external` is passed, or as `Unsafe` otherwise.
Does this read better?
EDIT: @bkchr We raced with a reply, let me reply to the above in a sec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Xanewok sounds good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bkchr I liked your list approach, so I went with that instead (Also needed verbatim_doc_comment
or the list would get wrapped, otherwise).
This now renders as:
--rpc-methods <METHOD SET>
RPC methods to expose.
- `Unsafe`: Exposes every RPC method.
- `Safe`: Exposes only a safe subset of RPC methods, denying unsafe RPC methods.
- `Default`: Acts as `Safe` if RPC is served externally, e.g. when `--{rpc,ws}-external` is passed,
otherwise acts as `Unsafe`. [default: Default] [possible values: Default, Safe, Unsafe]
Now that I read about it, the Default variant name does seem off... Especially if structopt injects the [default: Default]
for us.
Maybe something like Protected
(or Auto
?) would be a better name? Or should we just leave it for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Auto
sounds good as it handles it for you automatically :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(auto
is also more common for a CLI)
The polkadot companion build is failing but it looks like it's unrelated:
|
...by printing to stderr the stderr of the command. This is normally suppressed for succesful tests but not for failing ones - if that's the case then it's useful to see the test failure reason inline rather than having to execute the command separately ourselves.
Pushed the Default variant rename to Auto. |
That is because you don't have latest Substrate master in. |
...which can be either Default, Safe or Unsafe. The idea is to have the
following:
Since the previous
unsafe-rpc-expose
option was confusing.Fixes #5710
cc @tomusdrw @xlc
I also modified the Compose file since it mentioned the now-removed flag but wasn't sure if that's the right thing to do here; lmk if I should back out the related changes.