Skip to content

Commit

Permalink
chore(bridge): add a FAILED message status
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik committed Nov 29, 2022
1 parent 6500234 commit 7b63737
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 28 deletions.
9 changes: 4 additions & 5 deletions packages/protocol/contracts/L1/TaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,10 @@ contract TaikoL1 is EssentialContract, IHeaderSync, V1Events {
return LibAnchorSignature.signTransaction(hash, k);
}

function getBlockProvers(uint256 id, bytes32 parentHash)
public
view
returns (address[] memory)
{
function getBlockProvers(
uint256 id,
bytes32 parentHash
) public view returns (address[] memory) {
return state.forkChoices[id][parentHash].provers;
}

Expand Down
3 changes: 2 additions & 1 deletion packages/protocol/contracts/bridge/libs/LibBridgeData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ library LibBridgeData {
enum MessageStatus {
NEW,
RETRIABLE,
DONE
DONE,
FAILED
}

struct State {
Expand Down
5 changes: 4 additions & 1 deletion packages/protocol/contracts/bridge/libs/LibBridgeRetry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ library LibBridgeRetry {
) {
state.updateMessageStatus(signal, LibBridgeData.MessageStatus.DONE);
} else if (isLastAttempt) {
state.updateMessageStatus(signal, LibBridgeData.MessageStatus.DONE);
state.updateMessageStatus(
signal,
LibBridgeData.MessageStatus.FAILED
);

address refundAddress = message.refundAddress == address(0)
? message.owner
Expand Down
1 change: 1 addition & 0 deletions packages/protocol/tasks/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const MessageStatus = {
NEW: 0,
RETRIABLE: 1,
DONE: 2,
FAILED: 3,
}

export {
Expand Down
7 changes: 1 addition & 6 deletions packages/protocol/test/bridge/libs/LibBridgeData.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect } from "chai"
import { ethers } from "hardhat"
import { TAIKO_BRIDGE_MESSAGE } from "../../constants/messages"
import { MessageStatus } from "../../../tasks/utils"

describe("LibBridgeData", function () {
async function deployLibBridgeDataFixture() {
Expand Down Expand Up @@ -33,12 +34,6 @@ describe("LibBridgeData", function () {

const testVar = [TAIKO_BRIDGE_MESSAGE, testMessage]

const MessageStatus = {
NEW: 0,
RETRIABLE: 1,
DONE: 2,
}

return {
owner,
nonOwner,
Expand Down
8 changes: 1 addition & 7 deletions packages/protocol/test/bridge/libs/LibBridgeProcess.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect } from "chai"
import * as fs from "fs"
import hre, { ethers } from "hardhat"
import * as path from "path"
import { getSlot } from "../../../tasks/utils"
import { getSlot, MessageStatus } from "../../../tasks/utils"
import { AddressManager, Bridge } from "../../../typechain"
import { Message } from "../../utils/message"

Expand Down Expand Up @@ -109,12 +109,6 @@ describe("LibBridgeProcess", function () {
.connect(etherVaultOwner)
.authorize(libProcess.address, true)

const MessageStatus = {
NEW: 0,
RETRIABLE: 1,
DONE: 2,
}

return {
owner,
srcChainId,
Expand Down
10 changes: 2 additions & 8 deletions packages/protocol/test/bridge/libs/LibBridgeRetry.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as helpers from "@nomicfoundation/hardhat-network-helpers"
import { expect } from "chai"
import hre, { ethers } from "hardhat"
import { decode, getSlot } from "../../../tasks/utils"
import { decode, getSlot, MessageStatus } from "../../../tasks/utils"
import { Message } from "../../utils/message"

describe("LibBridgeRetry", function () {
Expand Down Expand Up @@ -73,12 +73,6 @@ describe("LibBridgeRetry", function () {
await ethers.getContractFactory("TestLibBridgeData")
).deploy()

const MessageStatus = {
NEW: 0,
RETRIABLE: 1,
DONE: 2,
}

return {
owner,
refundAddress,
Expand Down Expand Up @@ -276,7 +270,7 @@ describe("LibBridgeRetry", function () {
getSlot(hre, signal, 202)
)
)
).to.equal(MessageStatus.DONE.toString())
).to.equal(MessageStatus.FAILED.toString())

expect(balancePlusRefund).to.be.equal(
originalBalance.add(message.callValue)
Expand Down

0 comments on commit 7b63737

Please sign in to comment.