Skip to content

Introduce ‘max_gas_burnt_view’ client config and command line flag - #4381

Merged
mina86 merged 2 commits into
near:masterfrom
mina86:max-gas
Jun 28, 2021
Merged

Introduce ‘max_gas_burnt_view’ client config and command line flag#4381
mina86 merged 2 commits into
near:masterfrom
mina86:max-gas

Conversation

@mina86

@mina86 mina86 commented Jun 20, 2021

Copy link
Copy Markdown
Contributor

The ‘max_gas_burnt_view’ affects the RPCs only and therefore doesn’t
need to be part of the consensus. In other words, all nodes could
have this value customised rather than using an agreed upon value
from genesis configuration.

Introduce a ‘max_gas_burnt_view’ field to ClientConfig and
a corresponding flag to ‘init’ and ‘run’ subcommands. When present,
it will override the limit used by the node ignoring whatever is
stored in genesis configuration.

Fixes: #3080

@mina86

mina86 commented Jun 20, 2021

Copy link
Copy Markdown
Contributor Author

I haven’t yet fully tested that the limit actually takes hold. Any hints how to do that welcome. :)

@ailisp

ailisp commented Jun 21, 2021

Copy link
Copy Markdown
Contributor

I haven’t yet fully tested that the limit actually takes hold. Any hints how to do that welcome. :)

I think the best way will be add a pytest (in pytest dir), where you can write a python test to override config.json and command line options, and send rpc request to check the setting is effective

@mina86

mina86 commented Jun 21, 2021

Copy link
Copy Markdown
Contributor Author

and send rpc request to check the setting is effective

I’m struggling a bit with figuring out an RPC to test the setting.

@mina86

mina86 commented Jun 21, 2021

Copy link
Copy Markdown
Contributor Author

The check failure looks related to actix/actix-web#2185. I’ve tried updating actix-web release but that didn’t solve it. The issue is closed but also states that ‘-extras crates to follow’ so we might need to wait for a proper fix.

@bowenwang1996 bowenwang1996 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am a bit unsure whether it is a good idea to make max_gas_burnt_view part of RuntimeConfig since RuntimeConfig is part of the protocol right now and mixing it with non-protocol related config could cause confusion

@mina86

mina86 commented Jun 21, 2021

Copy link
Copy Markdown
Contributor Author

It already is part of the RuntimeConfig (and is included in genesis config). This change will make it so that the actual value used by the runtime will be overridden.

@bowenwang1996

Copy link
Copy Markdown
Contributor

oh I didn't realize that. @evgenykuzyakov what was the motivation to have it as part of RuntimeConfig?

@bowenwang1996 bowenwang1996 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you want to properly test this change, you can first write a contract that has some method that costs more than 200Tgas to run and then either write a python test or a unit in process_blocks.rs to call that method through a view call.

@ailisp

ailisp commented Jun 22, 2021

Copy link
Copy Markdown
Contributor

The check failure looks related to actix/actix-web#2185. I’ve tried updating actix-web release but that didn’t solve it. The issue is closed but also states that ‘-extras crates to follow’ so we might need to wait for a proper fix.

I encountered this fail in my PR too, one way of fix this is to pin actix-http: 7dcfd0d and also update Cargo.lock 6fa4bd8

@frol frol left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall looks good to me, so I unblock the PR, but please address the comments about the Indexer example.

Comment thread nearcore/src/runtime/mod.rs Outdated
Comment thread nearcore/src/runtime/mod.rs Outdated
Comment thread tools/indexer/example/Cargo.toml Outdated
Comment thread tools/indexer/example/src/configs.rs Outdated
Comment on lines 124 to +128
genesis_config: GenesisConfig,
genesis_runtime_config: Arc<RuntimeConfig>,
/// Runtime configuration. Note that it may be slightly different than
/// `genesis_config.runtime_config`. Consider `max_gas_burnt_view` value
/// which may be configured per node.
runtime_config: Arc<RuntimeConfig>,

@matklad matklad Jun 23, 2021

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I feel that config handling here accumulated quite a bit of technical debt, as we now have two separate paths that "patch" config: one with max_gas_burnt, and another with RuntimeConfig::from_protocol_version (which is especcially confusing, as it relies on hidden global state). I have a stalled PR which cleans parts of this up in #4263 (comment).

This isn't strictly related to the PR, so it isn't a blocker, but I want to raise awareness and signal that straightening this up is non-urgent, but important ;-)

@mina86

mina86 commented Jun 24, 2021

Copy link
Copy Markdown
Contributor Author

Added tests though also added a fib.wasm blob which I’m not super happy about but haven’t yet figure out how to use runtime/near-test-contracts.

Comment thread pytest/tests/sanity/rpc_max_gas_burnt.py Outdated
@mina86
mina86 requested a review from olonho as a code owner June 24, 2021 17:05

@bowenwang1996 bowenwang1996 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great work!

Comment thread chain/client/tests/process_blocks.rs
Comment thread nearcore/src/config.rs

@olonho olonho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall looks good, modulo potential argument refactoring and subtle serialized format change, I'm unsure about.

The ‘max_gas_burnt_view’ affects the RPCs only and therefore doesn’t
need to be part of the consensus.  In other words, all nodes could
have this value customised rather than using an agreed upon value
from genesis configuration.

Introduce a ‘max_gas_burnt_view’ field to ClientConfig and
a corresponding flag to ‘init’ and ‘run’ subcommands.  When present,
it will override the limit used by the node ignoring whatever is
stored in genesis configuration.

Fixes: near#3080

@ailisp ailisp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good!

@mina86
mina86 merged commit 7330f37 into near:master Jun 28, 2021
@mina86
mina86 deleted the max-gas branch June 28, 2021 03:52
@jakmeier jakmeier mentioned this pull request Feb 2, 2023
2 tasks
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.

Expose max_gas_burnt_view as part of client config

6 participants