-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Operator attestation policy #10721
Operator attestation policy #10721
Changes from 1 commit
caf6d7a
621e22f
0b57a65
1e52a41
fb4ff30
bc28201
cd2a40c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { makeTracer } from '@agoric/internal'; | ||
import { prepareDurablePublishKit } from '@agoric/notifier'; | ||
import { M } from '@endo/patterns'; | ||
import { keyEQ, M } from '@endo/patterns'; | ||
import { Fail } from '@endo/errors'; | ||
import { CctpTxEvidenceShape } from '../type-guards.js'; | ||
import { defineInertInvitation } from '../utils/zoe.js'; | ||
import { prepareOperatorKit } from './operator-kit.js'; | ||
|
@@ -127,6 +128,7 @@ export const prepareTransactionFeedKit = (zone, zcf) => { | |
const { operators, pending } = this.state; | ||
trace('submitEvidence', operatorId, evidence); | ||
|
||
// TODO https://github.com/Agoric/agoric-sdk/pull/10720 | ||
// TODO validate that it's a valid for Fast USDC before accepting | ||
// E.g. that the `recipientAddress` is the FU settlement account and that | ||
// the EUD is a chain supported by FU. | ||
|
@@ -160,7 +162,26 @@ export const prepareTransactionFeedKit = (zone, zcf) => { | |
return; | ||
} | ||
|
||
// TODO verify that all found deep equal | ||
let lastEvidence; | ||
for (const store of found) { | ||
const next = store.get(txHash); | ||
if (lastEvidence) { | ||
if (keyEQ(lastEvidence, next)) { | ||
lastEvidence = next; | ||
} else { | ||
trace( | ||
'🚨 conflicting evidence for', | ||
txHash, | ||
':', | ||
lastEvidence, | ||
'!=', | ||
next, | ||
Comment on lines
+176
to
+178
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we have to use this in anger, I expect we'll want to see which operator submitted which evidence. is that already traced? |
||
); | ||
Fail`conflicting evidence for ${txHash}`; | ||
} | ||
} | ||
lastEvidence = next; | ||
} | ||
|
||
// sufficient agreement, so remove from pending and publish | ||
for (const store of found) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ test('happy aggregation', async t => { | |
const evidenceSubscriber = feedKit.public.getEvidenceSubscriber(); | ||
|
||
const { op1, op2, op3 } = await makeOperators(feedKit); | ||
|
||
const e1 = MockCctpTxEvidences.AGORIC_PLUS_OSMO(); | ||
op1.operator.submitEvidence(e1); | ||
op2.operator.submitEvidence(e1); | ||
|
@@ -74,6 +75,48 @@ test('happy aggregation', async t => { | |
}); | ||
}); | ||
|
||
test('disagreement', async t => { | ||
const feedKit = makeFeedKit(); | ||
const { op1, op2 } = await makeOperators(feedKit); | ||
const e1 = MockCctpTxEvidences.AGORIC_PLUS_OSMO(); | ||
const e1bad = { ...e1, tx: { ...e1.tx, amount: 999_999_999n } }; | ||
assert(e1.txHash === e1bad.txHash); | ||
op1.operator.submitEvidence(e1); | ||
|
||
t.throws(() => op2.operator.submitEvidence(e1bad), { | ||
message: | ||
'conflicting evidence for "0xc81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761702"', | ||
}); | ||
}); | ||
|
||
test('disagreement after publishing', async t => { | ||
const feedKit = makeFeedKit(); | ||
const evidenceSubscriber = feedKit.public.getEvidenceSubscriber(); | ||
const { op1, op2, op3 } = await makeOperators(feedKit); | ||
const e1 = MockCctpTxEvidences.AGORIC_PLUS_OSMO(); | ||
const e1bad = { ...e1, tx: { ...e1.tx, amount: 999_999_999n } }; | ||
assert(e1.txHash === e1bad.txHash); | ||
op1.operator.submitEvidence(e1); | ||
op2.operator.submitEvidence(e1); | ||
|
||
t.like(await evidenceSubscriber.getUpdateSince(0), { | ||
updateCount: 1n, | ||
}); | ||
|
||
// it's simply ignored | ||
t.notThrows(() => op3.operator.submitEvidence(e1bad)); | ||
t.like(await evidenceSubscriber.getUpdateSince(0), { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why ask for updates since 0 again? isn't the n+1th call supposed to pass in the updateCount from the nth call? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's just a handy way to ask for the latest without risk of a hanging await while writing tests |
||
updateCount: 1n, | ||
}); | ||
|
||
// now another op repeats the bad evidence, so it's published to the stream. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ooh. tricky. |
||
// It's the responsibility of the Advancer to fail because it has already processed that tx hash. | ||
op1.operator.submitEvidence(e1bad); | ||
t.like(await evidenceSubscriber.getUpdateSince(0), { | ||
updateCount: 2n, | ||
}); | ||
}); | ||
|
||
test('disabled operator', async t => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good; the "unknown transaction" test mixed in testing this, and I wondered about reducing coverage. |
||
const feedKit = makeFeedKit(); | ||
const { op1 } = await makeOperators(feedKit); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a red-alert situation? It seems like we recover: we don't act on inconsistent evidence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it deserves immediate operational attention if two oracles are disagreeing. At least one is unreliable and may require immediate action.