HydraChain / hydrachain

Permissioned Distributed Ledger based on Ethereum
MIT License
358 stars 105 forks source link

Transaction Capability Authorization #63

Open heikoheiko opened 8 years ago

heikoheiko commented 8 years ago

Currently anyone can send transactions to the system. Support external KYC processes by having a restricting set of sender_addresses (users) that are granted the right to have their transactions evaluated (note sending in transactions is a different issue) by the system.

Task:

User Registry Contract:

Stores

Contract Logic:

Users are added and removed by registrars. Registrars are added and removed by super registrars (this supports cascaded registrars). In a practical application any registrar can add any user or sub registrar that she has done real world a KYC process with, and potentially have signed agreements with. Users/Registrars can only be removed by the onboarding registrar. Note an initial admin is necessary to add the first users/registrars to the system. Every registrar is also a user. When a transaction is added to the block, it is checked if the sender_address is in users/registrars and current block_height must be >= begin_block. Users are removed by setting begin_block to -1. If users were removed their address must not be added to the system again (this restriction simplifies the contract as we do not need to maintain authorized block_height ranges).

Hydrachain/Pyethereum

Create a wrapper around validate_transaction: https://github.com/ethereum/pyethereum/blob/develop/ethereum/processblock.py#L77

The wrapper should check if the sender address is authorized for the current block_height. The chain configuration (which must have the address of the user registry contract) can be found in block.config https://github.com/ethereum/pyethereum/blob/develop/ethereum/blocks.py#L387. The wrapper should then call the original implementation. Hydrachain code needs to monkey patch processblock.py by replacing validate_transaction with validate_transaction_wrapper.

Note: Think about configuration and bootstrapping.