forked from openethereum/parity-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new version of transactionPermissionContract
- Loading branch information
Showing
2 changed files
with
12 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[ { "constant": true, "inputs": [], "name": "contractNameHash", "outputs": [ { "name": "", "type": "bytes32" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "contractName", "outputs": [ { "name": "", "type": "string" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "contractVersion", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "sender", "type": "address" }, { "name": "to", "type": "address" }, { "name": "value", "type": "uint256" }, { "name": "gasPrice", "type": "uint256" }], "name": "allowedTxTypes", "outputs": [ { "name": "", "type": "uint32" }, { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "view", "type": "function" } ] |
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 |
---|---|---|
|
@@ -29,6 +29,7 @@ use hash::KECCAK_EMPTY; | |
|
||
use_contract!(transact_acl_deprecated, "res/contracts/tx_acl_deprecated.json"); | ||
use_contract!(transact_acl, "res/contracts/tx_acl.json"); | ||
use_contract!(transact_acl_gas_price, "res/contracts/tx_acl_gas_price.json"); | ||
|
||
const MAX_CACHE_SIZE: usize = 4096; | ||
|
||
|
@@ -109,6 +110,16 @@ impl TransactionFilter { | |
(tx_permissions::NONE, true) | ||
}) | ||
}, | ||
0xfffffffffffffffe => { | ||
let (data, decoder) = transact_acl_gas_price::functions::allowed_tx_types::call(sender, to, value, transaction.gas_price); | ||
client.call_contract(BlockId::Hash(*parent_hash), contract_address, data) | ||
.and_then(|value| decoder.decode(&value).map_err(|e| e.to_string())) | ||
.map(|(p, f)| (p.low_u32(), f)) | ||
.unwrap_or_else(|e| { | ||
error!(target: "tx_filter", "Error calling tx permissions contract: {:?}", e); | ||
(tx_permissions::NONE, true) | ||
}) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
afck
Collaborator
|
||
}, | ||
_ => { | ||
error!(target: "tx_filter", "Unknown version of tx permissions contract is used"); | ||
(tx_permissions::NONE, true) | ||
|
I think we'll also need to extend the permission cache (see line 86) and add the gas price to the key. (Will that hurt performance in practice, since transactions can come with many different gas prices? Also, why do the keys only contain thesender
, even though the existingallowed_tx_types
can already return different results byto
andvalue
?)