Skip to content

Repository files navigation

StakeWise Oracle

Oracles are responsible for submitting off-chain data of StakeWise pool validators from ETH2 beacon chain to the Oracles smart contract.

Installation

Prerequisites

Option 1. Build oracle with native Python

pip3 install -r requirements/prod.txt

Option 2. Build oracle with virtualenv

For the virtualenv users, you can create a new venv:

python3 -m venv venv
source venv/bin/activate

and install the dependencies:

pip install -r requirements/prod.txt

Option 3. Build the docker image (see below to use the existing one)

Run the following command locally to build the docker image:

docker build --pull -t oracle .

Usage

Option 1. Use the existing docker image

Run the following command locally to start the oracle:

docker run --env-file ./settings.txt stakewiselabs/oracle:latest

where settings.txt is an environment file with Settings.

Option 2. Run with Python

Run the following command locally to start the oracle:

source ./settings.txt
python main.py

where settings.txt is an environment file with Settings.

Settings

VariableDescriptionRequiredDefault
LOG_LEVELThe log level of the program.NoDEBUG
WEB3_WS_ENDPOINTThe WS endpoint to the ETH1 client. Must be specified if WEB3_HTTP_ENDPOINT endpoint is not provided.No-
WEB3_HTTP_ENDPOINTThe HTTP endpoint to the ETH1 client. Must be specified if WEB3_WS_ENDPOINT endpoint is not provided.No-
BEACON_CHAIN_RPC_ENDPOINTThe Beacon Chain RPC HTTP endpoint.Yes-
INJECT_POA_MIDDLEWAREWhether to inject POA middleware into Web3 client (see POA middleware).NoFalse
INJECT_STALE_CHECK_MIDDLEWAREWhether to check for stale ETH1 blocks in Web3 client (see Stale check middleware).NoFalse
STALE_CHECK_MIDDLEWARE_ALLOWABLE_DELAYThe time specified in seconds after which the block is considered stale in INJECT_STALE_CHECK_MIDDLEWARE middleware. Must be specified if INJECT_STALE_CHECK_MIDDLEWARE is set to True.No-
INJECT_RETRY_REQUEST_MIDDLEWAREWhether to retry failed transactions (see Retry middleware).NoFalse
INJECT_LOCAL_FILTER_MIDDLEWAREWhether to store log event filters locally instead of storing on the ETH1 node (see Local middleware).NoFalse
BALANCE_WARNING_THRESHOLDThe telegram notification will be sent when the oracle's balance will drop below such amount of ether.Yes-
BALANCE_ERROR_THRESHOLDThe program will exit with an error when the oracle's balance will drop below such amount of ether.Yes-
APPLY_GAS_PRICE_STRATEGYDefines whether the gas strategy should be applied.NoFalse
MAX_TX_WAIT_SECONDSThe preferred number of seconds the oracle is willing to wait for the transaction to mine. Will be applied only if APPLY_GAS_PRICE_STRATEGY is set to True.No120
TRANSACTION_TIMEOUTThe maximum number of seconds the oracle is willing to wait for the transaction to mine. After that it will throw time out error.Yes-
POOL_CONTRACT_ADDRESSThe address of the Pool Contract.Yes-
ORACLES_CONTRACT_ADDRESSThe address of the Oracle Contract.Yes-
REWARD_ETH_CONTRACT_ADDRESSThe address of the Reward ETH Token Contract.Yes-
STAKED_ETH_CONTRACT_ADDRESSThe address of the Staked ETH Token Contract.Yes-
ORACLE_PRIVATE_KEYThe ETH1 private key of the operator (see Generating Private Key below).Yes-
NOTIFIERS_TELEGRAM_TOKENTelegram chat token where notifications about low balance or errors will be sent.Yes-
NOTIFIERS_TELEGRAM_CHAT_IDTelegram chat ID where notifications about low balance or errors will be sent.Yes-
PROCESS_INTERVALHow long to wait before processing again.Yes-

Example settings

cat >./settings.txt <<EOLWEB3_WS_ENDPOINT=ws://localhost:8546BEACON_CHAIN_RPC_ENDPOINT=http://localhost:4000INJECT_STALE_CHECK_MIDDLEWARE=FalseSTALE_CHECK_MIDDLEWARE_ALLOWABLE_DELAY=120INJECT_RETRY_REQUEST_MIDDLEWARE=TrueBALANCE_WARNING_THRESHOLD=0.05BALANCE_ERROR_THRESHOLD=0.008APPLY_GAS_PRICE_STRATEGY=TrueMAX_TX_WAIT_SECONDS=180TRANSACTION_TIMEOUT=3600PROCESS_INTERVAL=30ORACLES_CONTRACT_ADDRESS=0x2f1C5E86B13a74f5A6E7B4b35DD77fe29Aa47514POOL_CONTRACT_ADDRESS=0xC874b064f465bdD6411D45734b56fac750Cda29AREWARD_ETH_CONTRACT_ADDRESS=0x20BC832ca081b91433ff6c17f85701B6e92486c5STAKED_ETH_CONTRACT_ADDRESS=0xFe2e637202056d30016725477c5da089Ab0A043AORACLE_PRIVATE_KEY=0x<private_key>NOTIFIERS_TELEGRAM_TOKEN=12345tokenNOTIFIERS_TELEGRAM_CHAT_ID=123456EOL

Generating Private Key

source venv/bin/activate
python -c "from web3 import Web3; w3 = Web3(); acc = w3.eth.account.create(); print(f'private key={w3.toHex(acc.privateKey)}, account={acc.address}')"

About

Reporters submit balances of StakeWise Pool validators to the smart contracts.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages