Open ezdac opened 11 months ago
The shutter node is the instance which connects the Keyper network with the OP node. It is responsible for storing the decryption keys published by the keyper network.
There is a two step process
The received message containing the decryption key, epoch ID (block number) and eon ID will validate if the key is valid for the eon key stored on chain for the given ID, and the epoch id. If the eon key is not on chain validation will fail and the key will be dropped.
This verification of the key for block N must run against the state for block N-1. So if block N-1 has not been seen by the shutter node, the shutter node must wait until Block N-1 has been seen. It will be checked if shutter is active and if the eon key is aktive for the next block.
The shutter node will only write the key into the DB (and thus provide this key to the endpoint for the OP node) iff the key validated successful both steps. I.e. if shutter is disabled keys will not be written into the DB. The content of the DB will not make any statement of completeness. Keys could be missing if i.e. the shutter node were offline or the shutter node didn't see the eon key yet, thus validation would fail.
The endpoint will be a long polling GET endpoint. getDecryptionKey
requires a block number as input. In case the key has not been written into the DB, but could be in the future the call will be blocking until one of the following events occur the key for the requested block number is available.
The requester (currently the OP node) is responsible for handling requests which do not return.
@ezdac will suggest an API standard.
The shutter node will be a separate application that serves as a gateway to the shutter P2P network and reading the shutter contract's state for the op-node. It will expose an HTTP API where the op-node can poll for the decryption-key of a certain L2 block-number.
[x] define the HTTP API's technology (push/pull/longpoll, RPC/REST, WS, etc.):
getDecryptionKey(blocknumber int)
. The endpoint will either return immediately when a key has been received already, or it will block until it receives the key and then return. Like that, the op-node can already callgetDecryptionKey(n+1)
, whenn
is the current block-number to be build. Keyper's then wait for their op-geth to returnn
frometh_blockNumber
and release their key forn+1
. Once the key is received by the shutter node, it will return the key immediately to the blocking http request.[x] define the HTTP API's methods / state-transfer model
[x] P2P Handler / Validator functions
[x] L2 JSON RPC client
eth_blockNumber
new unsafe head event worker[x] internal promise based event listening for long-polling GET requests
[x] concurrency safe data-structure for received events & data persistence (database)