Skip to content

Commit

Permalink
Merge pull request #36 from PowerLoom/dockerify
Browse files Browse the repository at this point in the history
Latest release v1.2
  • Loading branch information
SwaroopH authored Aug 22, 2024
2 parents e53d606 + d177f96 commit 292f37b
Show file tree
Hide file tree
Showing 16 changed files with 2,940 additions and 2,287 deletions.
14 changes: 7 additions & 7 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
source .env

echo "setting up codebase...";
echo "setting up codebase..."

rm -rf snapshotter-lite-local-collector;
git clone https://github.com/PowerLoom/snapshotter-lite-local-collector.git;
cd ./snapshotter-lite-local-collector;
git checkout simulation_node_bi;
cd ..;
rm -rf snapshotter-lite-local-collector
git clone https://github.com/PowerLoom/snapshotter-lite-local-collector.git
cd ./snapshotter-lite-local-collector
git checkout feat/trusted-relayers
cd ..

echo "bootstrapping complete!";
echo "bootstrapping complete!"
27 changes: 1 addition & 26 deletions build-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,6 @@ fi

source .env

if [ -z "$OVERRIDE_DEFAULTS" ]; then
echo "reset to default values...";
export PROST_RPC_URL="https://rpc-prost1h-proxy.powerloom.io"
export PROTOCOL_STATE_CONTRACT="0x10c5E2ee14006B3860d4FdF6B173A30553ea6333"
export PROST_CHAIN_ID="11165"
export SEQUENCER_ID="QmdJbNsbHpFseUPKC9vLt4vMsfdxA4dyHPzsAWuzYz3Yxx"
export RELAYER_RENDEZVOUS_POINT="Relayer_POP_test_simulation_phase_1"
export CLIENT_RENDEZVOUS_POINT="POP_Client_simulation_test_alpha"
fi


echo "testing before build...";

if [ -z "$SOURCE_RPC_URL" ]; then
Expand Down Expand Up @@ -86,9 +75,6 @@ if [ "$PROTOCOL_STATE_CONTRACT" ]; then
echo "Found PROTOCOL_STATE_CONTRACT ${PROTOCOL_STATE_CONTRACT}";
fi

if [ "$RELAYER_HOST" ]; then
echo "Found RELAYER_HOST ${RELAYER_HOST}";
fi

if [ "$WEB3_STORAGE_TOKEN" ]; then
echo "Found WEB3_STORAGE_TOKEN ${WEB3_STORAGE_TOKEN}";
Expand Down Expand Up @@ -118,17 +104,6 @@ fi

# setting up git submodules
git submodule update --init --recursive
# check if snapshotter-lite-local-collector exists
# if [ -d "./snapshotter-lite-local-collector" ]; then
# echo "snapshotter-lite-local-collector exists, do you want to delete and clone a fresh one? (y/n)";
# read response;
# if [ "$response" == "y" ]; then
# rm -rf ./snapshotter-lite-local-collector

# fi
# fi
rm -rf snapshotter-lite-local-collector
git clone https://github.com/PowerLoom/snapshotter-lite-local-collector/ snapshotter-lite-local-collector --single-branch --branch fix/generate-new-p2pid
cd ./snapshotter-lite-local-collector/ && chmod +x build-docker.sh && ./build-docker.sh;
cd ../;

Expand All @@ -149,4 +124,4 @@ else
else
docker-compose -f docker-compose-dev.yaml up --no-deps -V --abort-on-container-exit
fi
fi
fi
16 changes: 5 additions & 11 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@ fi
source .env

if [ -z "$OVERRIDE_DEFAULTS" ]; then
echo "reset to default values...";
export PROST_RPC_URL="https://rpc-prost1h-proxy.powerloom.io"
export PROTOCOL_STATE_CONTRACT="0x10c5E2ee14006B3860d4FdF6B173A30553ea6333"
export PROST_CHAIN_ID="11165"
export SEQUENCER_ID="QmdJbNsbHpFseUPKC9vLt4vMsfdxA4dyHPzsAWuzYz3Yxx"
export RELAYER_RENDEZVOUS_POINT="Relayer_POP_test_simulation_phase_1"
export CLIENT_RENDEZVOUS_POINT="POP_Client_simulation_test_alpha"
echo "setting default values...";
export PROST_RPC_URL="https://rpc-prost1m.powerloom.io"
export PROTOCOL_STATE_CONTRACT="0xE88E5f64AEB483d7057645326AdDFA24A3B312DF"
export DATA_MARKET_CONTRACT="0x0C2E22fe7526fAeF28E7A58c84f8723dEFcE200c"
export PROST_CHAIN_ID="11169"
fi


Expand Down Expand Up @@ -87,10 +85,6 @@ if [ "$PROTOCOL_STATE_CONTRACT" ]; then
fi


if [ "$RELAYER_HOST" ]; then
echo "Found RELAYER_HOST ${RELAYER_HOST}";
fi

if [ "$WEB3_STORAGE_TOKEN" ]; then
echo "Found WEB3_STORAGE_TOKEN ${WEB3_STORAGE_TOKEN}";
fi
Expand Down
2 changes: 1 addition & 1 deletion config
Submodule config updated 1 files
+2 −1 settings.example.json
6 changes: 2 additions & 4 deletions docker-compose-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ services:
- PROST_CHAIN_ID=$PROST_CHAIN_ID
- REDIS_HOST=${REDIS_HOST:-redis}
- REDIS_PORT=${REDIS_PORT:-6379}
- SEQUENCER_ID=$SEQUENCER_ID
- RELAYER_RENDEZVOUS_POINT=$RELAYER_RENDEZVOUS_POINT
- LOCAL_COLLECTOR_PORT=$LOCAL_COLLECTOR_PORT
- CLIENT_RENDEZVOUS_POINT=$CLIENT_RENDEZVOUS_POINT
- RELAYER_PRIVATE_KEY=$RELAYER_PRIVATE_KEY
- BLOCK_TIME=$BLOCK_TIME
- DATA_MARKET_CONTRACT=$DATA_MARKET_CONTRACT
command:
bash -c "bash server_autofill.sh && bash init_processes.sh"

Expand All @@ -44,9 +42,9 @@ services:
- SIGNER_ACCOUNT_PRIVATE_KEY=$SIGNER_ACCOUNT_PRIVATE_KEY
- SLOT_ID=$SLOT_ID
- SOURCE_RPC_URL=$SOURCE_RPC_URL
- RELAYER_HOST=$RELAYER_HOST
- PROST_RPC_URL=$PROST_RPC_URL
- IPFS_URL=$IPFS_URL
- DATA_MARKET_CONTRACT=$DATA_MARKET_CONTRACT
- IPFS_API_KEY=$IPFS_API_KEY
- IPFS_API_SECRET=$IPFS_API_SECRET
- PROTOCOL_STATE_CONTRACT=$PROTOCOL_STATE_CONTRACT
Expand Down
6 changes: 2 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ services:
- IPFS_API_KEY=$IPFS_API_KEY
- IPFS_API_SECRET=$IPFS_API_SECRET
- PROTOCOL_STATE_CONTRACT=$PROTOCOL_STATE_CONTRACT
- DATA_MARKET_CONTRACT=$DATA_MARKET_CONTRACT
- PROST_RPC_URL=$PROST_RPC_URL
- PROST_CHAIN_ID=$PROST_CHAIN_ID
- REDIS_HOST=${REDIS_HOST:-redis}
- REDIS_PORT=${REDIS_PORT:-6379}
- SEQUENCER_ID=$SEQUENCER_ID
- RELAYER_RENDEZVOUS_POINT=$RELAYER_RENDEZVOUS_POINT
- CLIENT_RENDEZVOUS_POINT=$CLIENT_RENDEZVOUS_POINT
- LOCAL_COLLECTOR_PORT=$LOCAL_COLLECTOR_PORT
- RELAYER_PRIVATE_KEY=$RELAYER_PRIVATE_KEY
- BLOCK_TIME=$BLOCK_TIME
Expand All @@ -41,13 +39,13 @@ services:
- SIGNER_ACCOUNT_ADDRESS=$SIGNER_ACCOUNT_ADDRESS
- SIGNER_ACCOUNT_PRIVATE_KEY=$SIGNER_ACCOUNT_PRIVATE_KEY
- SLOT_ID=$SLOT_ID
- RELAYER_HOST=$RELAYER_HOST
- SOURCE_RPC_URL=$SOURCE_RPC_URL
- PROST_RPC_URL=$PROST_RPC_URL
- IPFS_URL=$IPFS_URL
- IPFS_API_KEY=$IPFS_API_KEY
- IPFS_API_SECRET=$IPFS_API_SECRET
- PROTOCOL_STATE_CONTRACT=$PROTOCOL_STATE_CONTRACT
- DATA_MARKET_CONTRACT=$DATA_MARKET_CONTRACT
- LOCAL_COLLECTOR_PORT=$LOCAL_COLLECTOR_PORT
- SLACK_REPORTING_URL=$SLACK_REPORTING_URL
- POWERLOOM_REPORTING_URL=$POWERLOOM_REPORTING_URL
Expand Down
11 changes: 4 additions & 7 deletions env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ SOURCE_RPC_URL=<source-rpc-url>
SIGNER_ACCOUNT_ADDRESS=<signer-account-address>
SIGNER_ACCOUNT_PRIVATE_KEY=<signer-account-private-key>
SLOT_ID=<slot-id>
PROST_RPC_URL=https://rpc-prost1h-proxy.powerloom.io
PROTOCOL_STATE_CONTRACT=0x10c5E2ee14006B3860d4FdF6B173A30553ea6333
RELAYER_HOST=https://prost1h-relayer-public.powerloom.io
PROST_RPC_URL=https://rpc-prost1m.powerloom.io
PROTOCOL_STATE_CONTRACT=0xE88E5f64AEB483d7057645326AdDFA24A3B312DF
DATA_MARKET_CONTRACT=0x0C2E22fe7526fAeF28E7A58c84f8723dEFcE200c
NAMESPACE=UNISWAPV2
POWERLOOM_REPORTING_URL=https://nms-testnet-reporting.powerloom.io
PROST_CHAIN_ID=11165
SEQUENCER_ID=QmSHDGMY6DydSPAuyxCbrTgmfAi4Zfg7arrw2SbRZC22Jb
RELAYER_RENDEZVOUS_POINT=Relayer_POP_test_simulation_phase_1
CLIENT_RENDEZVOUS_POINT=POP_Client_simulation_test_alpha
PROST_CHAIN_ID=11169
LOCAL_COLLECTOR_PORT=50051
CORE_API_PORT=8002
# Optional
Expand Down
13 changes: 7 additions & 6 deletions snapshotter/core_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ async def get_current_epoch(
"""
try:
[current_epoch_data] = await request.app.state.anchor_rpc_helper.web3_call(
[request.app.state.protocol_state_contract.functions.currentEpoch()],
[request.app.state.protocol_state_contract.functions.currentEpoch(Web3.to_checksum_address(settings.data_market))],
)
current_epoch = {
'begin': current_epoch_data[0],
Expand Down Expand Up @@ -145,7 +145,7 @@ async def get_epoch_info(
"""
try:
[epoch_info_data] = await request.app.state.anchor_rpc_helper.web3_call(
[request.app.state.protocol_state_contract.functions.epochInfo(epoch_id)],
[request.app.state.protocol_state_contract.functions.epochInfo(Web3.to_checksum_address(settings.data_market), epoch_id)],
)
epoch_info = {
'timestamp': epoch_info_data[0],
Expand Down Expand Up @@ -190,13 +190,13 @@ async def get_project_last_finalized_epoch_info(
# find from contract
epoch_finalized = False
[cur_epoch] = await request.app.state.anchor_rpc_helper.web3_call(
[request.app.state.protocol_state_contract.functions.currentEpoch()],
[request.app.state.protocol_state_contract.functions.currentEpoch(Web3.to_checksum_address(settings.data_market))],
)
epoch_id = int(cur_epoch[2])
while not epoch_finalized and epoch_id >= 0:
# get finalization status
[epoch_finalized_contract] = await request.app.state.anchor_rpc_helper.web3_call(
[request.app.state.protocol_state_contract.functions.snapshotStatus(project_id, epoch_id)],
[request.app.state.protocol_state_contract.functions.snapshotStatus(settings.data_market, project_id, epoch_id)],
)
if epoch_finalized_contract[0]:
epoch_finalized = True
Expand All @@ -210,7 +210,7 @@ async def get_project_last_finalized_epoch_info(
'message': f'Unable to find last finalized epoch for project {project_id}',
}
[epoch_info_data] = await request.app.state.anchor_rpc_helper.web3_call(
[request.app.state.protocol_state_contract.functions.epochInfo(project_last_finalized_epoch)],
[request.app.state.protocol_state_contract.functions.epochInfo(Web3.to_checksum_address(settings.data_market), project_last_finalized_epoch)],
)
epoch_info = {
'epochId': project_last_finalized_epoch,
Expand Down Expand Up @@ -313,6 +313,7 @@ async def get_finalized_cid_for_project_id_epoch_id(
try:
data = await get_project_finalized_cid(
request.app.state.protocol_state_contract,
settings.data_market,
request.app.state.anchor_rpc_helper,
epoch_id,
project_id,
Expand Down Expand Up @@ -371,7 +372,7 @@ async def get_task_status_post(
try:

[last_finalized_epoch] = await request.app.state.anchor_rpc_helper.web3_call(
[request.app.state.protocol_state_contract.functions.lastFinalizedSnapshot(project_id)],
[request.app.state.protocol_state_contract.functions.lastFinalizedSnapshot(Web3.to_checksum_address(settings.data_market), project_id)],
)

except Exception as e:
Expand Down
21 changes: 7 additions & 14 deletions snapshotter/processor_distributor.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def __init__(self):
self._rpc_helper = None
self._source_chain_id = None
self._projects_list = None

self._initialized = False
self._upcoming_project_changes = defaultdict(list)
self._project_type_config_mapping = dict()
Expand Down Expand Up @@ -112,7 +111,7 @@ async def init(self):
abi=protocol_abi,
)
try:
source_block_time = self._protocol_state_contract.functions.SOURCE_CHAIN_BLOCK_TIME().call()
source_block_time = self._protocol_state_contract.functions.SOURCE_CHAIN_BLOCK_TIME(Web3.to_checksum_address(settings.data_market)).call()
except Exception as e:
self._logger.error(
'Exception in querying protocol state for source chain block time: {}',
Expand All @@ -123,7 +122,7 @@ async def init(self):
self._logger.debug('Set source chain block time to {}', self._source_chain_block_time)

try:
epoch_size = self._protocol_state_contract.functions.EPOCH_SIZE().call()
epoch_size = self._protocol_state_contract.functions.EPOCH_SIZE(Web3.to_checksum_address(settings.data_market)).call()
except Exception as e:
self._logger.error(
'Exception in querying protocol state for epoch size: {}',
Expand All @@ -132,16 +131,6 @@ async def init(self):
else:
self._epoch_size = epoch_size

try:
slots_per_day = self._protocol_state_contract.functions.SLOTS_PER_DAY().call()
except Exception as e:
self._logger.error(
'Exception in querying protocol state for slots per day: {}',
e,
)
else:
self._slots_per_day = slots_per_day

try:
snapshotter_address = self._protocol_state_contract.functions.slotSnapshotterMapping(settings.slot_id).call()
if snapshotter_address != to_checksum_address(settings.instance_id):
Expand All @@ -155,9 +144,10 @@ async def init(self):
exit(0)

try:
self._current_day = self._protocol_state_contract.functions.dayCounter().call()
self._current_day = self._protocol_state_contract.functions.dayCounter(Web3.to_checksum_address(settings.data_market)).call()

task_completion_status = self._protocol_state_contract.functions.checkSlotTaskStatusForDay(
Web3.to_checksum_address(settings.data_market),
settings.slot_id,
self._current_day,
).call()
Expand Down Expand Up @@ -197,16 +187,19 @@ async def _load_projects_metadata(self):
self._source_chain_epoch_size = await get_source_chain_epoch_size(
rpc_helper=self._anchor_rpc_helper,
state_contract_obj=protocol_state_contract,
data_market=Web3.to_checksum_address(settings.data_market),
)

self._source_chain_id = await get_source_chain_id(
rpc_helper=self._anchor_rpc_helper,
state_contract_obj=protocol_state_contract,
data_market=Web3.to_checksum_address(settings.data_market),
)

submission_window = await get_snapshot_submision_window(
rpc_helper=self._anchor_rpc_helper,
state_contract_obj=protocol_state_contract,
data_market=Web3.to_checksum_address(settings.data_market),
)
self._submission_window = submission_window

Expand Down
Loading

0 comments on commit 292f37b

Please sign in to comment.