Skip to content
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

Fix circle attack #45

Merged
merged 2 commits into from
Feb 20, 2024
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
3 changes: 3 additions & 0 deletions packages/indexer/src/thegraph/ormp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,16 @@ export class ThegraphIndexOrmp extends GraphCommon {
message_to
message_gasLimit
message_encoded
logIndex

oracleAssigned
oracleAssignedFee
oracleLogIndex
relayerAssigned
relayerAssignedFee
relayerAssignedProof
relayerAssignedParams
relayerLogIndex
}
}
`;
Expand Down
3 changes: 3 additions & 0 deletions packages/indexer/src/types/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,16 @@ export interface OrmpMessageAccepted extends BaseGraphEntity {
message_to: string
message_encoded: string
message_gasLimit: string
logIndex: string

oracleAssigned?: string
oracleAssignedFee?: string
oracleLogIndex?: string
relayerAssigned?: string
relayerAssignedFee?: string
relayerAssignedProof?: string
relayerAssignedParams?: string
relayerLogIndex?: string
}

export interface OrmpMessageDispatched extends BaseGraphEntity {
Expand Down
10 changes: 10 additions & 0 deletions packages/relay-oracle/src/relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,16 @@ export class OracleRelay extends CommonRelay<OracleRelayLifecycle> {
await super.storage.put(OracleRelay.CK_ORACLE_SIGNED, sourceNextMessageAccepted.message_index);
return;
}
if ((+sourceNextMessageAccepted.logIndex + 2) != (+(sourceNextMessageAccepted.oracleLogIndex ?? 0))) {
logger.warn(
`unexpected log index (%s, %s)`,
sourceNextMessageAccepted.logIndex,
sourceNextMessageAccepted.oracleLogIndex ?? 0,
super.meta('ormpipe-relay-oracle', ['oracle:sign']),
);
await super.storage.put(OracleRelay.CK_ORACLE_SIGNED, sourceNextMessageAccepted.message_index);
return;
}
const cachedSignedMessageIndex: number | undefined = await super.storage.get(OracleRelay.CK_ORACLE_SIGNED);
if (cachedSignedMessageIndex != undefined) {
if (+sourceNextMessageAccepted.message_index == cachedSignedMessageIndex) {
Expand Down
10 changes: 10 additions & 0 deletions packages/relay-relayer/src/relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ export class RelayerRelay extends CommonRelay<RelayerRelayLifecycle> {
await super.storage.put(RelayerRelay.CK_RELAYER_RELAIED, sourceNextMessageAccepted.message_index);
return;
}
if ((+sourceNextMessageAccepted.logIndex + 1) != (+(sourceNextMessageAccepted.relayerLogIndex ?? 0))) {
logger.warn(
`unexpected log index (%s, %s)`,
sourceNextMessageAccepted.logIndex,
sourceNextMessageAccepted.relayerLogIndex ?? 0,
super.meta('ormpipe-relay-relayer', ['relayer']),
);
await super.storage.put(RelayerRelay.CK_RELAYER_RELAIED, sourceNextMessageAccepted.message_index);
return;
}

const message: OrmpProtocolMessage = {
channel: sourceNextMessageAccepted.message_channel,
Expand Down
Loading