From c54d6f8d59f517a3ad239804e28915571e1fbc23 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Mon, 27 Mar 2023 17:27:01 +0800 Subject: [PATCH 1/2] fix BacalhauError call limitation, and some other tiny fix. Signed-off-by: zhangchao --- hardhat/contracts/LilypadEvents.sol | 2 +- main.go | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/hardhat/contracts/LilypadEvents.sol b/hardhat/contracts/LilypadEvents.sol index 87ecaa2..fbfcd6d 100644 --- a/hardhat/contracts/LilypadEvents.sol +++ b/hardhat/contracts/LilypadEvents.sol @@ -106,7 +106,7 @@ contract LilypadEvents is Initializable, AccessControlUpgradeable, UUPSUpgradeab LilypadCallerInterface(_to).lilypadFulfilled(address(this), _jobId, _resultType, _result); } - function returnBacalhauError(address _to, uint _jobId, string memory _errorMsg) public onlyRole(UPGRADER_ROLE) { + function returnBacalhauError(address _to, uint _jobId, string memory _errorMsg) public { BacalhauJobResult memory jobResult = BacalhauJobResult({ requestor: _to, id: _jobId, diff --git a/main.go b/main.go index 39ec037..2de2b56 100644 --- a/main.go +++ b/main.go @@ -10,11 +10,17 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/rs/zerolog" - "github.com/rs/zerolog/log" ) func main() { - ctx := log.Logger.WithContext(context.Background()) + // bacalhaus sets the default logger using buffered writer, so here just create a new one to ensure logs printed. + defaultLog := zerolog.New(os.Stderr).With().Timestamp().Logger() + ctx := defaultLog.WithContext(context.Background()) + //defer func() { + // // bacalhau sets the default logger using buffered writer, so we need to flush it before exiting. + // // Make sure any buffered logs are written if something failed before logging was configured. + // logger.LogBufferedLogs(nil) + //}() lvl := zerolog.InfoLevel if level, found := os.LookupEnv("LOG_LEVEL"); found { @@ -36,6 +42,10 @@ func main() { return } + if !common.IsHexAddress(os.Getenv("DEPLOYED_CONTRACT_ADDRESS")) { + fmt.Fprintln(os.Stderr, "DEPLOYED_CONTRACT_ADDRESS: invalid hex address string") + return + } addr := common.HexToAddress(os.Getenv("DEPLOYED_CONTRACT_ADDRESS")) privKey, err := crypto.HexToECDSA(os.Getenv("WALLET_PRIVATE_KEY")) if err != nil { From d1f53cf7ad8edee04f82b3bb5bb11224eb9301d8 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Mon, 27 Mar 2023 17:31:33 +0800 Subject: [PATCH 2/2] remove useless comment Signed-off-by: zhangchao --- main.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/main.go b/main.go index 2de2b56..ea95198 100644 --- a/main.go +++ b/main.go @@ -16,11 +16,6 @@ func main() { // bacalhaus sets the default logger using buffered writer, so here just create a new one to ensure logs printed. defaultLog := zerolog.New(os.Stderr).With().Timestamp().Logger() ctx := defaultLog.WithContext(context.Background()) - //defer func() { - // // bacalhau sets the default logger using buffered writer, so we need to flush it before exiting. - // // Make sure any buffered logs are written if something failed before logging was configured. - // logger.LogBufferedLogs(nil) - //}() lvl := zerolog.InfoLevel if level, found := os.LookupEnv("LOG_LEVEL"); found {