Recover from bot account ETH balance running out
Recover from situation where Commit ETH bot account's ETH balance runs out and gets replenished by re-deploying contracts that were not actually written to the blockchain. Fixes: #58
This commit is contained in:
parent
ad2e396ef1
commit
f171259ed4
|
@ -165,7 +165,8 @@ WHERE issue_id = :issue_id;
|
|||
-- :doc retrieves pending transaction ids
|
||||
SELECT
|
||||
issue_id,
|
||||
transaction_hash
|
||||
transaction_hash,
|
||||
owner_address
|
||||
FROM issues
|
||||
WHERE contract_address IS NULL
|
||||
AND issues.transaction_hash IS NOT NULL;
|
||||
|
|
|
@ -45,18 +45,33 @@
|
|||
balance-str))))))
|
||||
|
||||
|
||||
(defn deploy-contract [owner-address issue-id]
|
||||
(let [transaction-hash (eth/deploy-contract owner-address)]
|
||||
(if (nil? transaction-hash)
|
||||
(log/error "Failed to deploy contract to" owner-address)
|
||||
(log/info "Contract deployed, transaction-hash:"
|
||||
transaction-hash ))
|
||||
(issues/update-transaction-hash issue-id transaction-hash)))
|
||||
|
||||
|
||||
(defn redeploy-failed-contracts
|
||||
"If the bot account runs out of gas, we end up with transaction-id in db, but with nothing written to blockchain. In this case we should try to re-deploy the contract."
|
||||
[]
|
||||
(doseq [{issue-id :issue_id
|
||||
transaction-hash :transaction_hash
|
||||
owner-address :owner_address} (issues/list-pending-deployments)]
|
||||
(when (nil? (eth/get-transaction-receipt transaction-hash))
|
||||
(log/info "Detected nil transaction receipt for pending contract deployment for issue" issue-id ", re-deploying contract")
|
||||
(deploy-contract owner-address issue-id))))
|
||||
|
||||
|
||||
(defn deploy-pending-contracts
|
||||
"Under high-concurrency circumstances or in case geth is in defunct state, a bounty contract may not deploy successfully when the bounty label is addded to an issue. This function deploys such contracts."
|
||||
[]
|
||||
(doseq [{issue-id :issue_id
|
||||
owner-address :owner_address} (db-bounties/pending-contracts)]
|
||||
(log/debug "Trying to re-deploy failed bounty contract deployment, issue-id:" issue-id)
|
||||
(let [transaction-hash (eth/deploy-contract owner-address)]
|
||||
(if (nil? transaction-hash)
|
||||
(log/error "Failed to deploy contract to" owner-address)
|
||||
(log/info "Contract deployed, transaction-hash:"
|
||||
transaction-hash ))
|
||||
(issues/update-transaction-hash issue-id transaction-hash))))
|
||||
(deploy-contract owner-address issue-id)))
|
||||
|
||||
(defn self-sign-bounty
|
||||
"Walks through all issues eligible for bounty payout and signs corresponding transaction"
|
||||
|
@ -169,6 +184,7 @@
|
|||
(defn run-periodic-tasks [time]
|
||||
(do
|
||||
(log/debug "run-periodic-tasks" time)
|
||||
(redeploy-failed-contracts)
|
||||
(deploy-pending-contracts)
|
||||
(update-issue-contract-address)
|
||||
(update-confirm-hash)
|
||||
|
|
Loading…
Reference in New Issue