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

feat(SpokePoolClient): Append messageHash to deposit events #846

Merged
merged 27 commits into from
Feb 4, 2025
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
09bb9d8
feat(SpokePoolClient): Prepare for new SlowFillRequest
pxrl Jan 29, 2025
1603e21
Consolidate
pxrl Jan 29, 2025
57da213
Merge remote-tracking branch 'origin/master' into pxrl/slowFillRequest
pxrl Jan 30, 2025
9b827fc
Back out util
pxrl Jan 30, 2025
aac3908
feat: Add getMessageHash utility
pxrl Jan 30, 2025
14bdd26
Merge remote-tracking branch 'origin/master' into pxrl/slowFillRequest
pxrl Jan 31, 2025
72aed49
feat(SpokePoolClient): Append messageHash to deposit events
pxrl Jan 30, 2025
69e0f29
feat(SpokePoolClient): Prepare for new SlowFillRequest
pxrl Jan 29, 2025
7990b56
Consolidate
pxrl Jan 29, 2025
eb4432a
Merge remote-tracking branch 'origin/master' into pxrl/slowFillRequest
pxrl Jan 31, 2025
696ec18
Merge remote-tracking branch 'origin/pxrl/slowFillRequest' into pxrl/…
pxrl Jan 31, 2025
2c9c197
Merge remote-tracking branch 'origin/master' into pxrl/slowFillRequest
pxrl Feb 4, 2025
7ddbdab
Merge remote-tracking branch 'origin/pxrl/slowFillRequest' into pxrl/…
pxrl Feb 4, 2025
477d521
Test
pxrl Feb 4, 2025
ca40678
reflow
pxrl Feb 4, 2025
c79efe9
Merge remote-tracking branch 'origin/pxrl/slowFillRequest' into pxrl/…
pxrl Feb 4, 2025
4b2303b
test
pxrl Feb 4, 2025
4f1a619
Fix test
pxrl Feb 4, 2025
9f03bc0
Merge remote-tracking branch 'origin/pxrl/slowFillRequest' into pxrl/…
pxrl Feb 4, 2025
2114231
Handle block issue
pxrl Feb 4, 2025
5e9a0f6
Merge remote-tracking branch 'origin/master' into pxrl/slowFillRequest
pxrl Feb 4, 2025
03687a5
Merge remote-tracking branch 'origin/pxrl/slowFillRequest' into pxrl/…
pxrl Feb 4, 2025
7e61ac3
lint
pxrl Feb 4, 2025
211f8b3
Merge remote-tracking branch 'origin/pxrl/slowFillRequest' into pxrl/…
pxrl Feb 4, 2025
0e91508
Tweak test
pxrl Feb 4, 2025
d31255e
Merge remote-tracking branch 'origin/pxrl/slowFillRequest' into pxrl/…
pxrl Feb 4, 2025
179d7b2
Merge branch 'master' into pxrl/depositMessageHash
pxrl Feb 4, 2025
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
Prev Previous commit
Next Next commit
feat(SpokePoolClient): Prepare for new SlowFillRequest
`getRelayDataHash()` can no longer be used for hashing a SlowFillRequest
because the new event types emit `messageHash` instead of `message`.
This is OK in the SpokePoolClient because it only needs a very simple
method of indexing SlowFillRequest events.
pxrl committed Jan 31, 2025
commit 69e0f291e5f64a36d96c54660697f84e027cd69c
20 changes: 12 additions & 8 deletions src/clients/SpokePoolClient.ts
Original file line number Diff line number Diff line change
@@ -9,10 +9,11 @@ import {
MAX_BIG_INT,
MakeOptional,
assign,
getRelayDataHash,
keccak256,
isDefined,
toBN,
bnOne,
isMessageEmpty,
isUnsafeDepositId,
} from "../utils";
import {
@@ -22,7 +23,7 @@ import {
spreadEventWithBlockNumber,
} from "../utils/EventUtils";
import { validateFillForDeposit } from "../utils/FlowUtils";
import { ZERO_ADDRESS } from "../constants";
import { ZERO_ADDRESS, ZERO_BYTES } from "../constants";
import {
Deposit,
DepositWithBlock,
@@ -278,7 +279,7 @@ export class SpokePoolClient extends BaseAbstractClient {
* @returns The corresponding SlowFIllRequest event if found, otherwise undefined.
*/
public getSlowFillRequest(relayData: RelayData): SlowFillRequestWithBlock | undefined {
const hash = getRelayDataHash(relayData, this.chainId);
const hash = this.getDepositHash(relayData);
return this.slowFillRequests[hash];
}

@@ -617,16 +618,19 @@ export class SpokePoolClient extends BaseAbstractClient {
if (eventsToQuery.includes("RequestedV3SlowFill")) {
const slowFillRequests = queryResults[eventsToQuery.indexOf("RequestedV3SlowFill")];
for (const event of slowFillRequests) {
const message = event.args["message"];
const messageHash = isMessageEmpty(message)
? ZERO_BYTES
: keccak256(message);

const slowFillRequest = {
...spreadEventWithBlockNumber(event),
messageHash,
destinationChainId: this.chainId,
} as SlowFillRequestWithBlock;

const relayDataHash = getRelayDataHash(slowFillRequest, this.chainId);
if (this.slowFillRequests[relayDataHash] !== undefined) {
continue;
}
this.slowFillRequests[relayDataHash] = slowFillRequest;
const depositHash = this.getDepositHash(slowFillRequest);
this.slowFillRequests[depositHash] ??= slowFillRequest;
}
}

1 change: 1 addition & 0 deletions src/interfaces/SpokePool.ts
Original file line number Diff line number Diff line change
@@ -78,6 +78,7 @@ export interface SpeedUp {
export interface SpeedUpWithBlock extends SpeedUp, SortableEvent {}

export interface SlowFillRequest extends RelayData {
messageHash: string;
destinationChainId: number;
}
export interface SlowFillRequestWithBlock extends SlowFillRequest, SortableEvent {}
2 changes: 2 additions & 0 deletions src/utils/common.ts
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@ export type Decimalish = string | number | Decimal;
export const AddressZero = ethers.constants.AddressZero;
export const MAX_BIG_INT = BigNumber.from(Number.MAX_SAFE_INTEGER.toString());

export const { keccak256 } = ethers.utils;

/**
* toBNWei.
*