Skip to content

Commit

Permalink
feat(relay): Fix publishing on the first possible slot for the period…
Browse files Browse the repository at this point in the history
… given
  • Loading branch information
Dimo99 authored and zah committed Jul 3, 2023
1 parent 7149903 commit a87de7e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,5 @@ target
.ccls-cache

redis-server/

data/
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions relay/run-relay.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
7 changes: 5 additions & 2 deletions relay/workers/poll-updates/do_update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a87de7e

Please sign in to comment.