mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-05-02 01:23:06 +00:00
remove cancellation of txs in market, handled by ethers now
This commit is contained in:
parent
3b520fc0c6
commit
40ee931d6d
@ -23,7 +23,6 @@ type
|
||||
EventSubscription = ethers.Subscription
|
||||
OnChainMarketSubscription = ref object of MarketSubscription
|
||||
eventSubscription: EventSubscription
|
||||
OnChainMarketError = object of CatchableError
|
||||
|
||||
func new*(_: type OnChainMarket, contract: Marketplace): OnChainMarket =
|
||||
without signer =? contract.signer:
|
||||
@ -33,7 +32,7 @@ func new*(_: type OnChainMarket, contract: Marketplace): OnChainMarket =
|
||||
signer: signer,
|
||||
)
|
||||
|
||||
proc approveFunds(market: OnChainMarket, amount: UInt256, waitForConfirmations = 0) {.async.} =
|
||||
proc approveFunds(market: OnChainMarket, amount: UInt256) {.async.} =
|
||||
debug "Approving tokens", amount
|
||||
let tokenAddress = await market.contract.token()
|
||||
let token = Erc20Token.new(tokenAddress, market.signer)
|
||||
@ -112,20 +111,13 @@ method getActiveSlot*(market: OnChainMarket,
|
||||
return none Slot
|
||||
raise e
|
||||
|
||||
proc cancelTransaction(market: OnChainMarket, nonce: UInt256) {.async.} =
|
||||
let address = await market.getSigner()
|
||||
let cancelTx = Transaction(to: address, value: 0.u256, nonce: some nonce)
|
||||
let populated = await market.signer.populateTransaction(cancelTx)
|
||||
trace "cancelling transaction to prevent stuck transactions", nonce
|
||||
discard market.signer.sendTransaction(populated)
|
||||
|
||||
method fillSlot*(market: OnChainMarket,
|
||||
requestId: RequestId,
|
||||
slotIndex: UInt256,
|
||||
proof: seq[byte],
|
||||
collateral: UInt256) {.async.} =
|
||||
|
||||
await market.approveFunds(collateral, 1)
|
||||
await market.approveFunds(collateral)
|
||||
trace "calling contract fillSlot", slotIndex, requestId
|
||||
discard await market.contract.fillSlot(requestId, slotIndex, proof).confirm(1)
|
||||
|
||||
|
||||
@ -80,16 +80,6 @@ method getActiveSlot*(
|
||||
method cancelTransaction(market: Market, nonce: UInt256) {.base, async.} =
|
||||
raiseAssert("not implemented")
|
||||
|
||||
template cancelOnError*(market: Market, body) =
|
||||
try:
|
||||
body
|
||||
except JsonRpcProviderError as e:
|
||||
trace "error encountered, cancelling tx if there's a nonce present", nonce = e.nonce, error = e.msgDetail
|
||||
writeStackTrace()
|
||||
if e.nonce.isSome:
|
||||
# send a 0-valued transaction with the errored nonce to prevent stuck txs
|
||||
await market.cancelTransaction(!e.nonce)
|
||||
|
||||
method fillSlot*(market: Market,
|
||||
requestId: RequestId,
|
||||
slotIndex: UInt256,
|
||||
|
||||
@ -244,7 +244,8 @@ multinodesuite "Simulate invalid proofs",
|
||||
clients: StartNodeConfig()
|
||||
.nodes(1)
|
||||
.debug()
|
||||
.withLogFile(),
|
||||
.withLogFile()
|
||||
.withLogTopics("node"),
|
||||
|
||||
providers:
|
||||
StartNodeConfig()
|
||||
@ -254,7 +255,6 @@ multinodesuite "Simulate invalid proofs",
|
||||
.withLogFile()
|
||||
.withLogTopics("marketplace",
|
||||
"sales",
|
||||
"proving",
|
||||
"reservations",
|
||||
"node",
|
||||
"JSONRPC-HTTP-CLIENT",
|
||||
@ -266,6 +266,7 @@ multinodesuite "Simulate invalid proofs",
|
||||
validators: StartNodeConfig()
|
||||
.nodes(1)
|
||||
.withLogFile()
|
||||
.withLogTopics("validator", "initial-proving", "proving")
|
||||
):
|
||||
|
||||
# .simulateProofFailuresFor(providerIdx = 0, failEveryNProofs = 2),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user