This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
Add block reward contract config to ethash and allow off-chain contracts #9312
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
cf6135b
Add execute_code_as_system and throw error if system call fails
sorpaas 88d1eae
Add SystemOrCodeCallKind and change block reward contract to use it
sorpaas d09d031
Add block_reward_contract_code param
sorpaas 6c4d2c4
Add reward contract support for ethash
sorpaas 6c03980
Fix json crate compile
sorpaas 5c379d4
Be more graceful on uncle with depth calculation
sorpaas 0ea2236
benefactors -> beneficiaries
sorpaas ac0d3e1
Merge branch 'master' of https://github.com/paritytech/parity into sp…
sorpaas 56a409c
Fix linting
sorpaas 0dd53bf
Refactor duplicate system_or_code_call
sorpaas c494b79
Remove old RewardKind::Uncle
sorpaas File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,6 +133,46 @@ pub enum Seal { | |
/// A system-calling closure. Enacts calls on a block's state from the system address. | ||
pub type SystemCall<'a> = FnMut(Address, Vec<u8>) -> Result<Vec<u8>, String> + 'a; | ||
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. Do you think it makes sense to remove this type? It seems like everywhere 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 think we are still using |
||
|
||
/// A system-calling closure. Enacts calls on a block's state with code either from an on-chain contract, or hard-coded EVM or WASM (if enabled on-chain) codes. | ||
pub type SystemOrCodeCall<'a> = FnMut(SystemOrCodeCallKind, Vec<u8>) -> Result<Vec<u8>, String> + 'a; | ||
|
||
/// Kind of SystemOrCodeCall, this is either an on-chain address, or code. | ||
#[derive(PartialEq, Debug, Clone)] | ||
pub enum SystemOrCodeCallKind { | ||
/// On-chain address. | ||
Address(Address), | ||
/// Hard-coded code. | ||
Code(Arc<Vec<u8>>, H256), | ||
} | ||
|
||
/// Default SystemOrCodeCall implementation. | ||
pub fn default_system_or_code_call<'a>(machine: &'a ::machine::EthereumMachine, block: &'a mut ::block::ExecutedBlock) -> impl FnMut(SystemOrCodeCallKind, Vec<u8>) -> Result<Vec<u8>, String> + 'a { | ||
move |to, data| { | ||
let result = match to { | ||
SystemOrCodeCallKind::Address(address) => { | ||
machine.execute_as_system( | ||
block, | ||
address, | ||
U256::max_value(), | ||
Some(data), | ||
) | ||
}, | ||
SystemOrCodeCallKind::Code(code, code_hash) => { | ||
machine.execute_code_as_system( | ||
block, | ||
None, | ||
Some(code), | ||
Some(code_hash), | ||
U256::max_value(), | ||
Some(data), | ||
) | ||
}, | ||
}; | ||
|
||
result.map_err(|e| format!("{}", e)) | ||
} | ||
} | ||
|
||
/// Type alias for a function we can get headers by hash through. | ||
pub type Headers<'a, H> = Fn(H256) -> Option<H> + 'a; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This line is a little awkward. It would be nice to do this work only if tracing is enabled. I'm not sure what the reason is for having both
RewardKind
andRewardType
– is it possible to unify them? That way this line could go away entirely I think?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.
It's probably possible to unify them, although now they're a bit different since the tracing type doesn't distinguish between uncle depth. Although maybe we can change
note_rewards
to takeRewardKind
and handle the conversion itself (only performing it if tracing is enabled)?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 created a new issue on this #9399
(I would hope that we get the above done after #9360, otherwise it'll be a lot of duplicate interface changes.)