Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exit 1 if we can't list events #5

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/contracts/DrandCaller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ contract DrandCaller is LilypadCallerInterface {

function lilypadCancelled(
address _from,
uint _jobId,
uint,
string calldata _errorMsg
) external override {
) external override view {
require(_from == address(bridge));
console.log(_errorMsg);
}
Expand Down
77 changes: 43 additions & 34 deletions examples/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"hardhat": "^2.12.7"
},
"dependencies": {
"@openzeppelin/contracts": "^4.8.2",
"@openzeppelin/contracts-upgradeable": "^4.8.2",
"lilypad": "file:../hardhat"
}
}
8 changes: 7 additions & 1 deletion pkg/bridge/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/ecdsa"
"fmt"
"math/big"
"os"
"time"

"github.com/bacalhau-project/lilypad/hardhat/artifacts/contracts/LilypadEvents.sol"
Expand Down Expand Up @@ -156,7 +157,12 @@ func (r *realContract) ReadLogs(ctx context.Context, out chan<- ContractSubmitte
logs, err := r.contract.LilypadEventsFilterer.FilterNewBacalhauJobSubmitted(&opts)
if err != nil {
log.Ctx(ctx).Error().Err(err).Send()
return
// if we have an error here we should exit and restart
// this avoids problems if the network is down and we are holding onto a previous
// block number that is later than 24 hours and we get into a death loop
// if the network is down or for whatever other reason we are unable
// to list the events we should exit and restart to try and start again
os.Exit(1)
}
defer logs.Close()

Expand Down