From 7d8891ff515c749b7ed2e3476def3596fd1151a4 Mon Sep 17 00:00:00 2001 From: Dimo99 Date: Fri, 30 Jun 2023 11:38:56 +0300 Subject: [PATCH] feat(relay): Fix publishing on the first possible slot for the period given --- .gitignore | 2 ++ Makefile | 2 +- relay/run-relay.sh | 8 +++++--- relay/workers/poll-updates/do_update.ts | 7 +++++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 76fdcd1aa..a4b198c1c 100644 --- a/.gitignore +++ b/.gitignore @@ -167,3 +167,5 @@ target .ccls-cache redis-server/ + +data/ diff --git a/Makefile b/Makefile index 758c649a8..f597fb524 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ dendreth-relay-node: nix run '.#docker-image-yarn.copyToDockerDaemon' nix run '.?submodules=1#docker-image-all.copyToDockerDaemon' - docker build -t metacraft/dendeth-relay-node -f Dockerfile.relay . + docker build -t metacraft/dendreth-relay-node -f Dockerfile.relay . publish-dendreth-relay-node: dendreth-relay-node docker push metacraft/dendeth-relay-node diff --git a/relay/run-relay.sh b/relay/run-relay.sh index 929df30ad..1504d65e1 100755 --- a/relay/run-relay.sh +++ b/relay/run-relay.sh @@ -26,7 +26,7 @@ download_zkey_file() { download_dat_file() { echo "Downloading .dat file from https://media.githubusercontent.com/media/metacraft-labs/DendrETH-build-artifacts/master/light_client_cpp/light_client.dat ..." - curl -k https://media.githubusercontent.com/media/metacraft-labs/DendrETH-build-artifacts/master/light_client_cpp/light_client.dat > "datalight_client.dat" + curl -k https://media.githubusercontent.com/media/metacraft-labs/DendrETH-build-artifacts/master/light_client_cpp/light_client.dat > "data/light_client.dat" CALCULATED_DAT_SUM=$(calculate_checksum data/light_client.dat) @@ -64,7 +64,9 @@ else fi fi -cp relay/light_client data/light_client +# rapidnskark prover server searches for the witness generator exe in build directory +mkdir -p build +cp relay/light_client build/light_client cp data/light_client.dat light_client.dat if [[ -z "$REDIS_HOST" ]] && [[ -z "$REDIS_PORT" ]]; then @@ -292,4 +294,4 @@ fi supervisorctl start general_logs -tail -f ./prover_server.log relay/general_logs.log relay/pollUpdatesWorker.log relay/proofGenerationWorker.log beacon-light-client/solidity/goerli.log beacon-light-client/solidity/optimisticGoerli.log beacon-light-client/solidity/baseGoerli.log beacon-light-client/solidity/arbitrumGoerli.log beacon-light-client/solidity/sepolia.log beacon-light-client/solidity/mumbai.log +tail -f ./prover_server.log relay/general_logs.log relay/pollUpdatesWorker.log relay/proofGenerationWorker.log beacon-light-client/solidity/goerli.log beacon-light-client/solidity/optimisticGoerli.log beacon-light-client/solidity/baseGoerli.log beacon-light-client/solidity/arbitrumGoerli.log beacon-light-client/solidity/sepolia.log beacon-light-client/solidity/mumbai.log beacon-light-client/solidity/gnosis.log diff --git a/relay/workers/poll-updates/do_update.ts b/relay/workers/poll-updates/do_update.ts index fd8b39d74..d6d2e2f4b 100644 --- a/relay/workers/poll-updates/do_update.ts +++ b/relay/workers/poll-updates/do_update.ts @@ -25,13 +25,16 @@ export default async function doUpdate( console.log('Last downloaded update: ', lastDownloadedUpdate); - if (currentHeadSlot <= lastDownloadedUpdate + slotsJump) { + const initialUpdate = + lastDownloadedUpdate - (lastDownloadedUpdate % slotsJump); + + if (currentHeadSlot <= initialUpdate + slotsJump) { console.log('No new enought slot'); // the job will be retried throw new Error('No new enought slot'); } - let nextHeaderSlot = lastDownloadedUpdate + slotsJump; + let nextHeaderSlot = initialUpdate + slotsJump; let signatureSlot = nextHeaderSlot + 1; let prevNextHeaderSlot = nextHeaderSlot;