Skip to content

Commit

Permalink
Add new version of transactionPermissionContract
Browse files Browse the repository at this point in the history
  • Loading branch information
phahulin committed Jan 9, 2019
1 parent cc9b883 commit 60f59e7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions ethcore/res/contracts/tx_acl_gas_price.json
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" } ]
11 changes: 11 additions & 0 deletions ethcore/src/tx_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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.

Copy link
@afck

afck Jan 10, 2019

Collaborator

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 the sender, even though the existing allowed_tx_types can already return different results by to and value?)

This comment has been minimized.

Copy link
@afck

afck Jan 10, 2019

Collaborator

Ah, I see, the permission cache is probably fine as it is: openethereum#8400 (comment)

},
_ => {
error!(target: "tx_filter", "Unknown version of tx permissions contract is used");
(tx_permissions::NONE, true)
Expand Down

0 comments on commit 60f59e7

Please sign in to comment.