Skip to content

Commit

Permalink
feat: devnet config and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
eddort committed Jan 23, 2025
1 parent 28d4093 commit 0fc730d
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 2 deletions.
86 changes: 86 additions & 0 deletions docker-compose.devnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
version: "3.7"

networks:
devnet:
name: ${DOCKER_NETWORK_NAME}
external: true

services:
depositor-bot:
build: .
networks:
- devnet
restart: unless-stopped
ports:
- 127.0.0.1:9000:9000
environment:
- WEB3_RPC_ENDPOINTS=${WEB3_RPC_ENDPOINTS}
- LIDO_LOCATOR=${LIDO_LOCATOR}
- WALLET_PRIVATE_KEY=${WALLET_PRIVATE_KEY}
- CREATE_TRANSACTIONS=${CREATE_TRANSACTIONS}
- DEPOSIT_CONTRACT=${DEPOSIT_CONTRACT}

- MESSAGE_TRANSPORTS=${MESSAGE_TRANSPORTS}

- ONCHAIN_TRANSPORT_ADDRESS=${ONCHAIN_TRANSPORT_ADDRESS}
- ONCHAIN_TRANSPORT_RPC_ENDPOINTS=${ONCHAIN_TRANSPORT_RPC_ENDPOINTS}

- RABBIT_MQ_URL=${RABBIT_MQ_URL}
- RABBIT_MQ_USERNAME=${RABBIT_MQ_USERNAME}
- RABBIT_MQ_PASSWORD=${RABBIT_MQ_PASSWORD}
- RELAY_RPC=${RELAY_RPC}
- AUCTION_BUNDLER_PRIVATE_KEY=${AUCTION_BUNDLER_PRIVATE_KEY}
- DEPOSIT_MODULES_WHITELIST=${DEPOSIT_MODULES_WHITELIST}
- PROMETHEUS_PREFIX=${PROMETHEUS_PREFIX}
command: depositor

pause-bot:
build: .
networks:
- devnet
restart: unless-stopped
ports:
- 127.0.0.1:9001:9000
environment:
- WEB3_RPC_ENDPOINTS=${WEB3_RPC_ENDPOINTS}
- LIDO_LOCATOR=${LIDO_LOCATOR}
- WALLET_PRIVATE_KEY=${WALLET_PRIVATE_KEY}
- CREATE_TRANSACTIONS=${CREATE_TRANSACTIONS}
- DEPOSIT_CONTRACT=${DEPOSIT_CONTRACT}

- MESSAGE_TRANSPORTS=${MESSAGE_TRANSPORTS}

- ONCHAIN_TRANSPORT_ADDRESS=${ONCHAIN_TRANSPORT_ADDRESS}
- ONCHAIN_TRANSPORT_RPC_ENDPOINTS=${ONCHAIN_TRANSPORT_RPC_ENDPOINTS}

- RABBIT_MQ_URL=${RABBIT_MQ_URL}
- RABBIT_MQ_USERNAME=${RABBIT_MQ_USERNAME}
- RABBIT_MQ_PASSWORD=${RABBIT_MQ_PASSWORD}
- PROMETHEUS_PREFIX=${PROMETHEUS_PREFIX}
command: pauser

unvetting-bot:
build: .
networks:
- devnet
restart: unless-stopped
ports:
- 127.0.0.1:9002:9000
environment:
- WEB3_RPC_ENDPOINTS=${WEB3_RPC_ENDPOINTS}
- LIDO_LOCATOR=${LIDO_LOCATOR}
- WALLET_PRIVATE_KEY=${WALLET_PRIVATE_KEY}
- CREATE_TRANSACTIONS=${CREATE_TRANSACTIONS}
- DEPOSIT_CONTRACT=${DEPOSIT_CONTRACT}

- MESSAGE_TRANSPORTS=${MESSAGE_TRANSPORTS}

- ONCHAIN_TRANSPORT_ADDRESS=${ONCHAIN_TRANSPORT_ADDRESS}
- ONCHAIN_TRANSPORT_RPC_ENDPOINTS=${ONCHAIN_TRANSPORT_RPC_ENDPOINTS}

- RABBIT_MQ_URL=${RABBIT_MQ_URL}
- RABBIT_MQ_USERNAME=${RABBIT_MQ_USERNAME}
- RABBIT_MQ_PASSWORD=${RABBIT_MQ_PASSWORD}

- PROMETHEUS_PREFIX=${PROMETHEUS_PREFIX}
command: unvetter
9 changes: 7 additions & 2 deletions src/blockchain/deposit_strategy/gas_price_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def get_recommended_gas_fee(self) -> Wei:
return Wei(int(numpy.percentile(gas_history, variables.GAS_FEE_PERCENTILE_1))) + variables.GAS_ADDENDUM

def _fetch_gas_fee_history(self, days: int) -> list[Wei]:
latest_block_num = self.w3.eth.get_block('latest')['number']
latest_block = self.w3.eth.get_block('latest')

latest_block_num = latest_block['number']
logger.info({'msg': 'Fetch gas fee history.', 'value': {'block_number': latest_block_num}})

total_blocks_to_fetch = self._BLOCKS_IN_ONE_DAY * days
Expand All @@ -40,6 +42,9 @@ def _fetch_gas_fee_history(self, days: int) -> list[Wei]:

for _ in range(requests_count):
stats = self.w3.eth.fee_history(self._REQUEST_SIZE, last_block, [])
last_block = BlockNumber(stats['oldestBlock'] - 2)
# TODO: review and make fix for devnet without day history
stat_item = last_block if stats['oldestBlock'] == 0 else stats['oldestBlock'] - 2
last_block = BlockNumber(stat_item)

gas_fees = stats['baseFeePerGas'] + gas_fees
return gas_fees[: days * self._BLOCKS_IN_ONE_DAY]

0 comments on commit 0fc730d

Please sign in to comment.