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

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

Merged
merged 2 commits into from
Jun 28, 2021

Conversation

mina86
Copy link
Contributor

@mina86 mina86 commented Jun 20, 2021

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
Copy link
Contributor Author

mina86 commented Jun 20, 2021

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

@ailisp
Copy link
Member

ailisp commented Jun 21, 2021

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
Copy link
Contributor Author

mina86 commented Jun 21, 2021

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
Copy link
Contributor Author

mina86 commented Jun 21, 2021

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.

Copy link
Collaborator

@bowenwang1996 bowenwang1996 left a comment

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
Copy link
Contributor Author

mina86 commented Jun 21, 2021

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
Collaborator

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

Copy link
Collaborator

@bowenwang1996 bowenwang1996 left a comment

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
Copy link
Member

ailisp commented Jun 22, 2021

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

Copy link
Collaborator

@frol frol left a comment

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.

nearcore/src/runtime/mod.rs Outdated Show resolved Hide resolved
nearcore/src/runtime/mod.rs Outdated Show resolved Hide resolved
tools/indexer/example/Cargo.toml Outdated Show resolved Hide resolved
tools/indexer/example/src/configs.rs Outdated Show resolved Hide resolved
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>,
Copy link
Contributor

@matklad matklad Jun 23, 2021

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
Copy link
Contributor Author

mina86 commented Jun 24, 2021

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.

@mina86 mina86 requested a review from olonho as a code owner June 24, 2021 17:05
Copy link
Collaborator

@bowenwang1996 bowenwang1996 left a comment

Choose a reason for hiding this comment

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

Great work!

Copy link
Contributor

@olonho olonho left a comment

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
Copy link
Member

@ailisp ailisp 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!

@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