Skip to content

Commit

Permalink
feat: change ExitStarted, InFlightExitStarted, InFlightExitChallenged…
Browse files Browse the repository at this point in the history
… events
  • Loading branch information
Paweł Gębal committed Aug 17, 2020
1 parent e37d1e2 commit 2fef884
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ library PaymentChallengeIFENotCanonical {
event InFlightExitChallenged(
address indexed challenger,
bytes32 indexed txHash,
uint256 challengeTxPosition
uint256 challengeTxPosition,
uint16 inFlightTxInputIndex,
bytes challengeTx,
uint16 challengeTxInputIndex,
bytes challengeTxWitness
);

event InFlightExitChallengeResponded(
Expand Down Expand Up @@ -131,7 +135,15 @@ library PaymentChallengeIFENotCanonical {
// Set a flag so that only the inputs are exitable, unless a response is received.
ife.isCanonical = false;

emit InFlightExitChallenged(msg.sender, keccak256(args.inFlightTx), competitorPosition);
emit InFlightExitChallenged({
challenger: msg.sender,
txHash: keccak256(args.inFlightTx),
challengeTxPosition: competitorPosition,
inFlightTxInputIndex: args.inFlightTxInputIndex,
challengeTx: args.competingTx,
challengeTxInputIndex: args.competingTxInputIndex,
challengeTxWitness: args.competingTxWitness
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ library PaymentStartInFlightExit {

event InFlightExitStarted(
address indexed initiator,
bytes32 indexed txHash
bytes32 indexed txHash,
bytes inFlightTx,
uint256[] inputUtxosPos,
bytes[] inputTxs,
bytes[] inFlightTxWitnesses
);

/**
Expand Down Expand Up @@ -105,7 +109,14 @@ library PaymentStartInFlightExit {
StartExitData memory startExitData = createStartExitData(self, args);
verifyStart(startExitData, inFlightExitMap);
startExit(startExitData, inFlightExitMap);
emit InFlightExitStarted(msg.sender, startExitData.inFlightTxHash);
emit InFlightExitStarted({
initiator: msg.sender,
txHash: startExitData.inFlightTxHash,
inFlightTx: args.inFlightTx,
inputUtxosPos: args.inputUtxosPos,
inputTxs: args.inputTxs,
inFlightTxWitnesses: args.inFlightTxWitnesses
});
}

function createStartExitData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ library PaymentStartStandardExit {

event ExitStarted(
address indexed owner,
uint168 exitId
uint168 exitId,
uint256 utxoPos,
bytes rlpOutputTx
);

/**
Expand Down Expand Up @@ -90,7 +92,12 @@ library PaymentStartStandardExit {
saveStandardExitData(data, exitMap);
enqueueStandardExit(data);

emit ExitStarted(msg.sender, data.exitId);
emit ExitStarted({
owner: msg.sender,
exitId: data.exitId,
utxoPos: args.utxoPos,
rlpOutputTx: args.rlpOutputTx
});
}

function setupStartStandardExitData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,13 @@ contract('PaymentStartStandardExit', ([_, outputOwner, nonOutputOwner]) => {

const isTxDeposit = await this.framework.isDeposit(this.dummyBlockNum);
const exitId = await this.exitIdHelper.getStandardExitId(isTxDeposit, args.rlpOutputTx, args.utxoPos);
const { logs } = await this.exitGame.startStandardExit(args, {
const { receipt } = await this.exitGame.startStandardExit(args, {
from: outputOwner,
value: this.startStandardExitTxValue,
gasPrice: this.dummyGasPrice,
});

await expectEvent.inLogs(logs, 'ExitStarted', { owner: outputOwner, exitId });
console.log(args.rlpOutputTx)
await expectEvent.inTransaction(receipt, PaymentStartStandardExit, 'ExitStarted', { owner: outputOwner, exitId, utxoPos: args.utxoPos, rlpOutputTx: args.rlpOutputTx });
});

it('should allow 2 outputs on the same transaction to exit', async () => {
Expand Down

0 comments on commit 2fef884

Please sign in to comment.