-
Notifications
You must be signed in to change notification settings - Fork 786
Introduce ‘max_gas_burnt_view’ client config and command line flag #4381
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1707,6 +1707,7 @@ mod test { | |
| vec![], | ||
| vec![], | ||
| None, | ||
| None, | ||
| )) as Arc<dyn RuntimeAdapter> | ||
| }) | ||
| .collect() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,6 +67,7 @@ impl GenesisBuilder { | |
| vec![], | ||
| vec![], | ||
| None, | ||
| None, | ||
| ); | ||
| Self { | ||
| home_dir: home_dir.to_path_buf(), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -122,7 +122,10 @@ impl EpochInfoProvider for SafeEpochManager { | |
| /// TODO: this possibly should be merged with the runtime cargo or at least reconciled on the interfaces. | ||
| pub struct NightshadeRuntime { | ||
| 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>, | ||
|
Comment on lines
124
to
+128
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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 ;-) |
||
|
|
||
| store: Arc<Store>, | ||
| tries: ShardTries, | ||
|
|
@@ -142,11 +145,18 @@ impl NightshadeRuntime { | |
| initial_tracking_accounts: Vec<AccountId>, | ||
| initial_tracking_shards: Vec<ShardId>, | ||
| trie_viewer_state_size_limit: Option<u64>, | ||
| max_gas_burnt_view: Option<Gas>, | ||
| ) -> Self { | ||
| let runtime = Runtime::new(); | ||
| let trie_viewer = TrieViewer::new_with_state_size_limit(trie_viewer_state_size_limit); | ||
| let trie_viewer = TrieViewer::new(trie_viewer_state_size_limit, max_gas_burnt_view); | ||
| let genesis_config = genesis.config.clone(); | ||
| let genesis_runtime_config = Arc::new(genesis_config.runtime_config.clone()); | ||
| let runtime_config = Arc::new({ | ||
| let mut cfg = genesis_config.runtime_config.clone(); | ||
| if let Some(gas) = max_gas_burnt_view { | ||
| cfg.wasm_config.limit_config.max_gas_burnt_view = gas; | ||
| } | ||
| cfg | ||
| }); | ||
| let num_shards = genesis.config.num_block_producer_seats_per_shard.len() as NumShards; | ||
| let initial_epoch_config = EpochConfig::from(&genesis_config); | ||
| let reward_calculator = RewardCalculator::new(&genesis_config); | ||
|
|
@@ -175,7 +185,7 @@ impl NightshadeRuntime { | |
| ); | ||
| NightshadeRuntime { | ||
| genesis_config, | ||
| genesis_runtime_config, | ||
| runtime_config, | ||
| store, | ||
| tries, | ||
| runtime, | ||
|
|
@@ -420,7 +430,7 @@ impl NightshadeRuntime { | |
| random_seed, | ||
| current_protocol_version, | ||
| config: RuntimeConfig::from_protocol_version( | ||
| &self.genesis_runtime_config, | ||
| &self.runtime_config, | ||
| current_protocol_version, | ||
| ), | ||
| cache: Some(Arc::new(StoreCompiledContractCache { store: self.store.clone() })), | ||
|
|
@@ -552,10 +562,8 @@ impl RuntimeAdapter for NightshadeRuntime { | |
| verify_signature: bool, | ||
| current_protocol_version: ProtocolVersion, | ||
| ) -> Result<Option<InvalidTxError>, Error> { | ||
| let runtime_config = RuntimeConfig::from_protocol_version( | ||
| &self.genesis_runtime_config, | ||
| current_protocol_version, | ||
| ); | ||
| let runtime_config = | ||
| RuntimeConfig::from_protocol_version(&self.runtime_config, current_protocol_version); | ||
|
|
||
| if let Some(state_root) = state_root { | ||
| let shard_id = self.account_id_to_shard_id(&transaction.transaction.signer_id); | ||
|
|
@@ -624,10 +632,8 @@ impl RuntimeAdapter for NightshadeRuntime { | |
| let mut transactions = vec![]; | ||
| let mut num_checked_transactions = 0; | ||
|
|
||
| let runtime_config = RuntimeConfig::from_protocol_version( | ||
| &self.genesis_runtime_config, | ||
| current_protocol_version, | ||
| ); | ||
| let runtime_config = | ||
| RuntimeConfig::from_protocol_version(&self.runtime_config, current_protocol_version); | ||
|
|
||
| while total_gas_burnt < transactions_gas_limit { | ||
| if let Some(iter) = pool_iterator.next() { | ||
|
|
@@ -1507,8 +1513,17 @@ impl RuntimeAdapter for NightshadeRuntime { | |
| config.protocol_version = protocol_version; | ||
| // Currently only runtime config is changed through protocol upgrades. | ||
| let runtime_config = | ||
| RuntimeConfig::from_protocol_version(&self.genesis_runtime_config, protocol_version); | ||
| config.runtime_config = (*runtime_config).clone(); | ||
| RuntimeConfig::from_protocol_version(&self.runtime_config, protocol_version); | ||
| // If we were initialised with a custom max_gas_burnt_view (see new | ||
| // function), bring back the value from genesis configuration. Since | ||
| // max_gas_burnt_view never changes as a result of protocol upgrade, we | ||
| // can be sure that this value will be correct. | ||
| config.runtime_config = { | ||
| let mut cfg = (*runtime_config).clone(); | ||
| cfg.wasm_config.limit_config.max_gas_burnt_view = | ||
| config.runtime_config.wasm_config.limit_config.max_gas_burnt_view; | ||
| cfg | ||
| }; | ||
| Ok(config) | ||
| } | ||
|
|
||
|
|
@@ -1758,6 +1773,7 @@ mod test { | |
| initial_tracked_accounts, | ||
| initial_tracked_shards, | ||
| None, | ||
| None, | ||
| ); | ||
| let (_store, state_roots) = runtime.genesis_state(); | ||
| let genesis_hash = hash(&vec![0]); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.