Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 11 additions & 34 deletions contracts/HubPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -750,43 +750,20 @@ contract HubPool is HubPoolInterface, Testable, Lockable, MultiCaller, Ownable {
}

/**
* @notice Returns ancillary data containing all relevant root bundle data that voters can format into UTF8 and
* use to determine if the root bundle proposal is valid.
* @notice Returns ancillary data containing the minimum data necessary that voters can use to identify
* a root bundle proposal to validate its correctness.
* @dev The root bundle that is being disputed was the most recently proposed one with a block number less than
* or equal to the dispute block time. All of this root bundle data can be found in the ProposeRootBundle event
* params. Moreover, the optimistic oracle will stamp the requester's address (i.e. this contract address) meaning
* that ancillary data for a dispute originating from another HubPool will always be distinct from a dispute
* originating from this HubPool.
* @dev Since bundleEvaluationNumbers for a root bundle proposal are not stored on-chain, DVM voters will always
* have to look up the ProposeRootBundle event to evaluate a dispute, therefore there is no point emitting extra
* data in this ancillary data that is already included in the ProposeRootBundle event.
* @return ancillaryData Ancillary data that can be decoded into UTF8.
*/
function getRootBundleProposalAncillaryData() public view override returns (bytes memory ancillaryData) {
ancillaryData = AncillaryData.appendKeyValueUint(
"",
"requestExpirationTimestamp",
rootBundleProposal.requestExpirationTimestamp
);

ancillaryData = AncillaryData.appendKeyValueUint(
ancillaryData,
"unclaimedPoolRebalanceLeafCount",
rootBundleProposal.unclaimedPoolRebalanceLeafCount
);
ancillaryData = AncillaryData.appendKeyValueBytes32(
ancillaryData,
"poolRebalanceRoot",
rootBundleProposal.poolRebalanceRoot
);
ancillaryData = AncillaryData.appendKeyValueBytes32(
ancillaryData,
"relayerRefundRoot",
rootBundleProposal.relayerRefundRoot
);
ancillaryData = AncillaryData.appendKeyValueBytes32(
ancillaryData,
"slowRelayRoot",
rootBundleProposal.slowRelayRoot
);
ancillaryData = AncillaryData.appendKeyValueUint(
ancillaryData,
"claimedBitMap",
rootBundleProposal.claimedBitMap
);
ancillaryData = AncillaryData.appendKeyValueAddress(ancillaryData, "proposer", rootBundleProposal.proposer);
return "";
}

/**
Expand Down
19 changes: 7 additions & 12 deletions test/HubPool.DisputeRootBundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { SignerWithAddress, seedWallet, expect, Contract, ethers } from "./utils
import * as consts from "./constants";
import { hubPoolFixture, enableTokensForLP } from "./fixtures/HubPool.Fixture";

let hubPool: Contract, weth: Contract, optimisticOracle: Contract, store: Contract;
let hubPool: Contract, weth: Contract, optimisticOracle: Contract, store: Contract, mockOracle: Contract;
let owner: SignerWithAddress, dataWorker: SignerWithAddress, liquidityProvider: SignerWithAddress;

describe("HubPool Root Bundle Dispute", function () {
beforeEach(async function () {
[owner, dataWorker, liquidityProvider] = await ethers.getSigners();
({ weth, hubPool, optimisticOracle, store } = await hubPoolFixture());
({ weth, hubPool, optimisticOracle, store, mockOracle } = await hubPoolFixture());
await enableTokensForLP(owner, hubPool, weth, [weth]);

await seedWallet(dataWorker, [], weth, consts.totalBond.mul(2));
Expand Down Expand Up @@ -48,22 +48,17 @@ describe("HubPool Root Bundle Dispute", function () {
expect(rootBundle.claimedBitMap).to.equal(0); // no claims yet so everything should be marked at 0.
expect(rootBundle.proposer).to.equal(consts.zeroAddress);

// HubPool should use `getRootBundleProposalAncillaryData()` return value as the ancillary data that it sends
// to the oracle, and the oracle should stamp the hub pool's address.
const priceRequestAddedEvent = (await mockOracle.queryFilter(mockOracle.filters.PriceRequestAdded()))[0].args;
const priceProposalEvent = (await optimisticOracle.queryFilter(optimisticOracle.filters.ProposePrice()))[0].args;

expect(priceProposalEvent?.requester).to.equal(hubPool.address);
expect(priceProposalEvent?.identifier).to.equal(consts.identifier);
expect(priceProposalEvent?.ancillaryData).to.equal(preCallAncillaryData);

const parsedAncillaryData = parseAncillaryData(priceProposalEvent?.ancillaryData);
expect(parsedAncillaryData?.requestExpirationTimestamp).to.equal(
proposalTime.add(consts.refundProposalLiveness).toNumber()
);
expect(parsedAncillaryData?.unclaimedPoolRebalanceLeafCount).to.equal(consts.mockPoolRebalanceLeafCount);
expect("0x" + parsedAncillaryData?.poolRebalanceRoot).to.equal(consts.mockPoolRebalanceRoot);
expect("0x" + parsedAncillaryData?.relayerRefundRoot).to.equal(consts.mockRelayerRefundRoot);
expect("0x" + parsedAncillaryData?.slowRelayRoot).to.equal(consts.mockSlowRelayRoot);
expect(parsedAncillaryData?.claimedBitMap).to.equal(0);
expect(ethers.utils.getAddress("0x" + parsedAncillaryData?.proposer)).to.equal(dataWorker.address);
const parsedAncillaryData = parseAncillaryData(priceRequestAddedEvent?.ancillaryData);
expect(ethers.utils.getAddress("0x" + parsedAncillaryData?.ooRequester)).to.equal(hubPool.address);
});
it("Can not dispute after proposal liveness", async function () {
await weth.connect(dataWorker).approve(hubPool.address, consts.totalBond.mul(2));
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/UmaEcosystem.Fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const umaEcosystemFixture = hre.deployments.createFixture(async ({ ethers
// Set up other required UMA ecosystem components.
await identifierWhitelist.addSupportedIdentifier(identifier);

return { timer, finder, collateralWhitelist, identifierWhitelist, store, optimisticOracle };
return { timer, finder, collateralWhitelist, identifierWhitelist, store, optimisticOracle, mockOracle };
});

module.exports.tags = ["UmaEcosystem"];