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
|
-- :doc retrieves pending transaction ids
|
||||||
SELECT
|
SELECT
|
||||||
issue_id,
|
issue_id,
|
||||||
transaction_hash
|
transaction_hash,
|
||||||
|
owner_address
|
||||||
FROM issues
|
FROM issues
|
||||||
WHERE contract_address IS NULL
|
WHERE contract_address IS NULL
|
||||||
AND issues.transaction_hash IS NOT NULL;
|
AND issues.transaction_hash IS NOT NULL;
|
||||||
|
|
|
@ -45,18 +45,33 @@
|
||||||
balance-str))))))
|
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
|
(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."
|
"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
|
(doseq [{issue-id :issue_id
|
||||||
owner-address :owner_address} (db-bounties/pending-contracts)]
|
owner-address :owner_address} (db-bounties/pending-contracts)]
|
||||||
(log/debug "Trying to re-deploy failed bounty contract deployment, issue-id:" issue-id)
|
(log/debug "Trying to re-deploy failed bounty contract deployment, issue-id:" issue-id)
|
||||||
(let [transaction-hash (eth/deploy-contract owner-address)]
|
(deploy-contract owner-address issue-id)))
|
||||||
(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 self-sign-bounty
|
(defn self-sign-bounty
|
||||||
"Walks through all issues eligible for bounty payout and signs corresponding transaction"
|
"Walks through all issues eligible for bounty payout and signs corresponding transaction"
|
||||||
|
@ -169,6 +184,7 @@
|
||||||
(defn run-periodic-tasks [time]
|
(defn run-periodic-tasks [time]
|
||||||
(do
|
(do
|
||||||
(log/debug "run-periodic-tasks" time)
|
(log/debug "run-periodic-tasks" time)
|
||||||
|
(redeploy-failed-contracts)
|
||||||
(deploy-pending-contracts)
|
(deploy-pending-contracts)
|
||||||
(update-issue-contract-address)
|
(update-issue-contract-address)
|
||||||
(update-confirm-hash)
|
(update-confirm-hash)
|
||||||
|
|
Loading…
Reference in New Issue