From 6253651f8cb81ceee21d49b29fbd3d95f44874ca Mon Sep 17 00:00:00 2001 From: Guilherme Soares Date: Tue, 19 Dec 2023 11:09:18 +0100 Subject: [PATCH 1/3] Extended pegin gas limit --- http/server.go | 13 +++++++++++-- http/watcher.go | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/http/server.go b/http/server.go index ca10032a..7a505862 100644 --- a/http/server.go +++ b/http/server.go @@ -831,6 +831,7 @@ func (s *Server) getQuoteHandler(w http.ResponseWriter, r *http.Request) { var gas uint64 gas, err = s.rsk.EstimateGas(qr.CallEoaOrContractAddress, big.NewInt(int64(qr.ValueToTransfer)), []byte(qr.CallContractArguments)) + if err != nil { log.Error(ErrorEstimatingGas, err.Error()) customError := NewServerError(ErrorEstimatingGas, make(Details), true) @@ -844,6 +845,13 @@ func (s *Server) getQuoteHandler(w http.ResponseWriter, r *http.Request) { ResponseError(w, customError, http.StatusInternalServerError) return } + gasDao, err := s.rsk.EstimateGas(qr.CallEoaOrContractAddress, big.NewInt(int64(qr.ValueToTransfer)), make([]byte, 0)) + if err != nil { + log.Error(ErrorEstimatingGas, err.Error()) + customError := NewServerError(ErrorEstimatingGas, make(Details), true) + ResponseError(w, customError, http.StatusInternalServerError) + return + } var quotes []*QuoteReturn fedAddress, err := s.rsk.GetFedAddress() @@ -876,8 +884,9 @@ func (s *Server) getQuoteHandler(w http.ResponseWriter, r *http.Request) { getQuoteFailed := false amountBelowMinLockTxValue := false - q := parseReqToQuote(qr, s.rsk.GetLBCAddress(), fedAddress, gas, daoFeeAmount) - pq, err := s.provider.GetQuote(q, gas, types.NewBigWei(price)) + totalGas := gas + gasDao + q := parseReqToQuote(qr, s.rsk.GetLBCAddress(), fedAddress, totalGas, daoFeeAmount) + pq, err := s.provider.GetQuote(q, totalGas, types.NewBigWei(price)) if err != nil { log.Error("error getting quote: ", err) getQuoteFailed = true diff --git a/http/watcher.go b/http/watcher.go index d9bb9bdf..086b1980 100644 --- a/http/watcher.go +++ b/http/watcher.go @@ -57,7 +57,7 @@ type BTCAddressPegOutWatcher struct { } const ( - pegInGasLim = 1500000 + pegInGasLim = 2500000 CFUExtraGas = 180000 WatcherClosedError = "watcher is closed; cannot handle OnNewConfirmation; hash: %v" WatcherOnExpireError = "watcher is closed; cannot handle OnExpire; hash: %v" From 5d04958a6dcd61d9adeebfdf68b0b474a68b2bc6 Mon Sep 17 00:00:00 2001 From: Guilherme Soares Date: Tue, 19 Dec 2023 14:38:53 +0100 Subject: [PATCH 2/3] Fixed env var --- docker-compose/lbc-deployer/Dockerfile | 6 ++--- docker-compose/local/.env.regtest | 4 +++- docker-compose/local/.env.testnet | 2 ++ docker-compose/local/docker-compose.lps.yml | 1 + docker-compose/local/lps-env.sh | 5 +++-- http/server.go | 25 +++++++++++---------- 6 files changed, 25 insertions(+), 18 deletions(-) diff --git a/docker-compose/lbc-deployer/Dockerfile b/docker-compose/lbc-deployer/Dockerfile index 44724d7b..45170c2c 100644 --- a/docker-compose/lbc-deployer/Dockerfile +++ b/docker-compose/lbc-deployer/Dockerfile @@ -16,9 +16,9 @@ RUN gitBranch=${LBC_GIT_BRANCH} && \ git fetch --depth 1 origin "$gitBranch" && \ git checkout "$gitBranch" -COPY --chown=node truffle-config.patch ./ - -RUN git apply truffle-config.patch +#COPY --chown=node truffle-config.patch ./ +# +#RUN git apply truffle-config.patch RUN npm ci diff --git a/docker-compose/local/.env.regtest b/docker-compose/local/.env.regtest index b97418d4..25e69ab9 100644 --- a/docker-compose/local/.env.regtest +++ b/docker-compose/local/.env.regtest @@ -84,4 +84,6 @@ CAPTCHA_SECRET_KEY= CAPTCHA_SITE_KEY= CAPTCHA_THRESHOLD=0.8 DISABLE_CAPTCHA=true -PROVIDER_TYPE=both \ No newline at end of file +PROVIDER_TYPE=both + +DAO_FEE_COLLECTOR_ADDRESS=0x86B6534687A176A476C16083a373fB9Fe4FAb449 \ No newline at end of file diff --git a/docker-compose/local/.env.testnet b/docker-compose/local/.env.testnet index a9f0645b..225fa251 100644 --- a/docker-compose/local/.env.testnet +++ b/docker-compose/local/.env.testnet @@ -44,3 +44,5 @@ CAPTCHA_SITE_KEY= CAPTCHA_THRESHOLD=0.8 DISABLE_CAPTCHA=false PROVIDER_TYPE=both + +DAO_FEE_COLLECTOR_ADDRESS=0x86B6534687A176A476C16083a373fB9Fe4FAb449 diff --git a/docker-compose/local/docker-compose.lps.yml b/docker-compose/local/docker-compose.lps.yml index 82627530..2196ba90 100644 --- a/docker-compose/local/docker-compose.lps.yml +++ b/docker-compose/local/docker-compose.lps.yml @@ -78,6 +78,7 @@ services: - DISABLE_CAPTCHA - BTC_WALLET_PASSWORD - BTC_ENCRYPTED_WALLET + - DAO_FEE_COLLECTOR_ADDRESS ports: - "8080:8080" volumes: diff --git a/docker-compose/local/lps-env.sh b/docker-compose/local/lps-env.sh index e2d4773c..1ebaf892 100755 --- a/docker-compose/local/lps-env.sh +++ b/docker-compose/local/lps-env.sh @@ -146,8 +146,9 @@ if [ "$LPS_STAGE" = "regtest" ]; then echo "LBC_ADDR is not set. Deploying LBC contract..." # deploy LBC contracts to RSKJ - LBC_ADDR_LINE=$(docker-compose --env-file "$ENV_FILE" -f docker-compose.yml -f docker-compose.lbc-deployer.yml run --rm lbc-deployer bash deploy-lbc.sh | grep LBC_ADDR | head -n 1 | tr -d '\r') - export LBC_ADDR="${LBC_ADDR_LINE#"LBC_ADDR="}" + # LBC_ADDR_LINE=$(docker-compose --env-file "$ENV_FILE" -f docker-compose.yml -f docker-compose.lbc-deployer.yml run --rm lbc-deployer bash deploy-lbc.sh | grep LBC_ADDR | head -n 1 | tr -d '\r') + export LBC_ADDR="0x55c46eBC90C903Ff830b203Da1e7CA7CD2f0C3aa" + # export LBC_ADDR="${LBC_ADDR_LINE#"LBC_ADDR="}" fi fi diff --git a/http/server.go b/http/server.go index 7a505862..94ebe184 100644 --- a/http/server.go +++ b/http/server.go @@ -845,7 +845,19 @@ func (s *Server) getQuoteHandler(w http.ResponseWriter, r *http.Request) { ResponseError(w, customError, http.StatusInternalServerError) return } - gasDao, err := s.rsk.EstimateGas(qr.CallEoaOrContractAddress, big.NewInt(int64(qr.ValueToTransfer)), make([]byte, 0)) + + daoFeePercentage, err := s.rsk.GetDaoFeePercentage() + + if err != nil { + log.Error(ErrorRetrievingDaoFeePercentage, err.Error()) + customError := NewServerError(ErrorRetrievingDaoFeePercentage, make(map[string]interface{}), true) + ResponseError(w, customError, http.StatusInternalServerError) + return + } + + daoFeeAmount := qr.ValueToTransfer * daoFeePercentage / 100 + + gasDao, err := s.rsk.EstimateGas(os.Getenv("DAO_FEE_COLLECTOR_ADDRESS"), big.NewInt(int64(daoFeeAmount)), make([]byte, 0)) if err != nil { log.Error(ErrorEstimatingGas, err.Error()) customError := NewServerError(ErrorEstimatingGas, make(Details), true) @@ -871,17 +883,6 @@ func (s *Server) getQuoteHandler(w http.ResponseWriter, r *http.Request) { } minLockTxValueInWei := types.SatoshiToWei(minLockTxValueInSatoshi.Uint64()) - daoFeePercentage, err := s.rsk.GetDaoFeePercentage() - - if err != nil { - log.Error(ErrorRetrievingDaoFeePercentage, err.Error()) - customError := NewServerError(ErrorRetrievingDaoFeePercentage, make(map[string]interface{}), true) - ResponseError(w, customError, http.StatusInternalServerError) - return - } - - daoFeeAmount := qr.ValueToTransfer * daoFeePercentage / 100 - getQuoteFailed := false amountBelowMinLockTxValue := false totalGas := gas + gasDao From 58ef1d5bef7412cba4d3f7a32b02963f2296c7c4 Mon Sep 17 00:00:00 2001 From: Guilherme Soares Date: Tue, 19 Dec 2023 14:57:05 +0100 Subject: [PATCH 3/3] Remove comments from init script --- docker-compose/local/lps-env.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docker-compose/local/lps-env.sh b/docker-compose/local/lps-env.sh index 1ebaf892..e2d4773c 100755 --- a/docker-compose/local/lps-env.sh +++ b/docker-compose/local/lps-env.sh @@ -146,9 +146,8 @@ if [ "$LPS_STAGE" = "regtest" ]; then echo "LBC_ADDR is not set. Deploying LBC contract..." # deploy LBC contracts to RSKJ - # LBC_ADDR_LINE=$(docker-compose --env-file "$ENV_FILE" -f docker-compose.yml -f docker-compose.lbc-deployer.yml run --rm lbc-deployer bash deploy-lbc.sh | grep LBC_ADDR | head -n 1 | tr -d '\r') - export LBC_ADDR="0x55c46eBC90C903Ff830b203Da1e7CA7CD2f0C3aa" - # export LBC_ADDR="${LBC_ADDR_LINE#"LBC_ADDR="}" + LBC_ADDR_LINE=$(docker-compose --env-file "$ENV_FILE" -f docker-compose.yml -f docker-compose.lbc-deployer.yml run --rm lbc-deployer bash deploy-lbc.sh | grep LBC_ADDR | head -n 1 | tr -d '\r') + export LBC_ADDR="${LBC_ADDR_LINE#"LBC_ADDR="}" fi fi