diff --git a/contracts b/contracts index 004d466a3..c2575aa26 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit 004d466a3d593e6304e52c74e6c3e801b6a33b32 +Subproject commit c2575aa268734ab6bd03955c6545bd634516e262 diff --git a/monitor/utils/events.js b/monitor/utils/events.js index 812d0f119..6dd751a5f 100644 --- a/monitor/utils/events.js +++ b/monitor/utils/events.js @@ -101,6 +101,21 @@ async function main(mode) { chain: 'home' })).map(normalizeEvent) homeToForeignRequests = [...homeToForeignRequests, ...homeToForeignRequestsNew] + if (bridgeMode === BRIDGE_MODES.ARBITRARY_MESSAGE) { + const used = {} + const total = homeToForeignRequests.length + const onlyFirstUniqueFilter = e => { + const msgId = e.returnValues.messageId || e.transactionHash + if (used[msgId]) { + return false + } + used[msgId] = true + return true + } + homeToForeignRequests = homeToForeignRequests.filter(onlyFirstUniqueFilter) + const dropped = total - homeToForeignRequests.length + logger.debug(`Dropped ${dropped}/${total} UserRequestForSignature events with same message id`) + } logger.debug("calling foreignBridge.getPastEvents('RelayedMessage')") const homeToForeignConfirmations = (await getPastEvents(foreignBridge, { diff --git a/oracle-e2e/test/amb.js b/oracle-e2e/test/amb.js index cecc1f533..5bdde5fde 100644 --- a/oracle-e2e/test/amb.js +++ b/oracle-e2e/test/amb.js @@ -140,6 +140,73 @@ describe('arbitrary message bridging', () => { const value = await foreignBox.methods.value().call() assert(!toBN(value).eq(toBN(newValue)), 'Message should not be relayed by oracle automatically') }) + + it('should reconfirm message in case of validators change', async () => { + const newValue = 15 + + const initialValue = await foreignBox.methods.value().call() + assert(!toBN(initialValue).eq(toBN(newValue)), 'initial value should be different from new value') + + const signatures = await homeBridge.getPastEvents('SignedForUserRequest', { + fromBlock: 0, + toBlock: 'latest' + }) + + const { events } = await homeBox.methods + .setValueOnOtherNetworkUsingManualLane(newValue, amb.home, amb.foreignBox) + .send() + .catch(e => { + console.error(e) + }) + const message = homeWeb3.eth.abi.decodeParameter('bytes', events['0'].raw.data) + + await delay(10000) + + await setRequiredSignatures({ + bridgeContract: homeBridge, + web3: homeWeb3, + requiredSignatures: 3, + options: { + from: validator.address, + gas: '4000000' + } + }) + + const signatures2 = await homeBridge.getPastEvents('SignedForUserRequest', { + fromBlock: 0, + toBlock: 'latest' + }) + + assert( + signatures2.length === signatures.length + requiredSignatures, + `Incorrect amount of signatures submitted, got ${signatures2.length}, expected ${signatures.length + + requiredSignatures}` + ) + + await homeBridge.methods.requestMessageReconfirm(message).send() + + await delay(10000) + + const signatures3 = await homeBridge.getPastEvents('SignedForUserRequest', { + fromBlock: 0, + toBlock: 'latest' + }) + + assert( + signatures3.length === signatures.length + 3, + `Incorrect amount of signatures submitted, got ${signatures3.length}, expected ${signatures.length + 3}` + ) + + await setRequiredSignatures({ + bridgeContract: homeBridge, + web3: homeWeb3, + requiredSignatures: 2, + options: { + from: validator.address, + gas: '4000000' + } + }) + }) } it('should confirm but not relay message from manual lane', async () => {