TxPermission
contract TxPermission
is UpgradeableOwned, ITxPermission
Controls the use of zero gas price by validators in service transactions, protecting the network against "transaction spamming" by malicious validators. The protection logic is declared in the `allowedTxTypes` function.
Index
Reference
Modifiers
onlyInitialized
modifier onlyInitialized()
Ensures the `initialize` function was called before.
Functions
_addAllowedSender
function _addAllowedSender(address _sender) internal
An internal function used by the `addAllowedSender` and `initialize` functions.
- Parameters:
_sender
- The address for which transactions of any type must be allowed.
addAllowedSender
function addAllowedSender(address _sender) public
Adds the address for which transactions of any type must be allowed. Can only be called by the `owner`. See also the `allowedTxTypes` getter.
- Modifiers:
- onlyOwner onlyInitialized
- Parameters:
_sender
- The address for which transactions of any type must be allowed.
allowedSenders
function allowedSenders() public view returns (address[])
Returns the list of addresses allowed to initiate transactions of any type. For these addresses the `allowedTxTypes` getter always returns the `ALL` bit mask (see https://openethereum.github.io/wiki/Permissioning.html#how-it-works-1).
- Returns:
- address[]
allowedTxTypes
function allowedTxTypes(address _sender, address _to, uint256 _value, uint256 _gasPrice, bytes _data) public view returns (uint32, bool)
Defines the allowed transaction types which may be initiated by the specified sender with the specified gas price and data. Used by node's engine each time a transaction is about to be included into a block. See https://openethereum.github.io/wiki/Permissioning.html#how-it-works-1.
- Parameters:
_sender
- Transaction sender address._to
- Transaction recipient address. If creating a contract, the `_to` address is zero._value
- Transaction amount in wei._gasPrice
- Gas price in wei for the transaction._data
- Transaction data.- Returns:
- `uint32 typesMask` - Set of allowed transactions for `_sender` depending on tx `_to` address, `_gasPrice`, and `_data`. The result is represented as a set of flags: 0x01 - basic transaction (e.g. ether transferring to user wallet); 0x02 - contract call; 0x04 - contract creation; 0x08 - private transaction. `bool cache` - If `true` is returned, the same permissions will be applied from the same `_sender` without calling this contract again.
blockGasLimit
function blockGasLimit() public view returns (uint256)
Returns the current block gas limit which depends on the stage of the current staking epoch: the block gas limit is temporarily reduced for the latest block of the epoch.
- Returns:
- uint256
contractName
function contractName() public pure returns (string)
Returns the contract's name recognizable by node's engine.
- Returns:
- string
contractNameHash
function contractNameHash() public pure returns (bytes32)
Returns the contract name hash needed for node's engine.
- Returns:
- bytes32
contractVersion
function contractVersion() public pure returns (uint256)
Returns the contract's version number needed for node's engine.
- Returns:
- uint256
initialize
function initialize(address[] _allowed, address _certifier, address _validatorSet) external
Initializes the contract at network startup. Can only be called by the constructor of the `InitializerAuRa` contract or owner.
- Parameters:
_allowed
- The addresses for which transactions of any type must be allowed. See the `allowedTxTypes` getter._certifier
- The address of the `Certifier` contract. It is used by `allowedTxTypes` function to know whether some address is explicitly allowed to use zero gas price._validatorSet
- The address of the `ValidatorSetAuRa` contract.
isInitialized
function isInitialized() public view returns (bool)
Returns a boolean flag indicating if the `initialize` function has been called.
- Returns:
- bool
removeAllowedSender
function removeAllowedSender(address _sender) public
Removes the specified address from the array of addresses allowed to initiate transactions of any type. Can only be called by the `owner`. See also the `addAllowedSender` function and `allowedSenders` getter.
- Modifiers:
- onlyOwner onlyInitialized
- Parameters:
_sender
- The removed address.