Skip to content

Commit

Permalink
Merge branch 'master' into speed-features
Browse files Browse the repository at this point in the history
  • Loading branch information
dohaki committed Sep 5, 2024
2 parents c4d9f00 + 53547a6 commit 98dcc9b
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@across-protocol/sdk",
"author": "UMA Team",
"version": "3.1.30",
"version": "3.1.32",
"license": "AGPL-3.0",
"homepage": "https://docs.across.to/reference/sdk",
"files": [
Expand Down
22 changes: 15 additions & 7 deletions src/caching/Arweave/ArweaveClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,21 @@ export class ArweaveClient {
});
const results = await Promise.all(
entries.map(async (edge) => {
const data = await this.get<T>(edge.node.id, validator);
return isDefined(data)
? {
data,
hash: edge.node.id,
}
: null;
try {
const data = await this.get<T>(edge.node.id, validator);
return isDefined(data)
? {
data,
hash: edge.node.id,
}
: null;
} catch (e) {
this.logger.warn({
at: "ArweaveClient:getByTopic",
message: `Bad request for Arweave topic ${edge.node.id}: ${e}`,
});
return null;
}
})
);
return results.filter(isDefined);
Expand Down
9 changes: 5 additions & 4 deletions src/clients/SpokePoolClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
RelayerRefundExecutionWithBlock,
RootBundleRelayWithBlock,
SlowFillRequestWithBlock,
SpeedUp,
SpeedUpWithBlock,
TokensBridged,
V3FundsDepositedEvent,
} from "../interfaces";
Expand Down Expand Up @@ -67,7 +67,7 @@ export class SpokePoolClient extends BaseAbstractClient {
protected oldestTime = 0;
protected depositHashes: { [depositHash: string]: DepositWithBlock } = {};
protected depositHashesToFills: { [depositHash: string]: FillWithBlock[] } = {};
protected speedUps: { [depositorAddress: string]: { [depositId: number]: SpeedUp[] } } = {};
protected speedUps: { [depositorAddress: string]: { [depositId: number]: SpeedUpWithBlock[] } } = {};
protected slowFillRequests: { [relayDataHash: string]: SlowFillRequestWithBlock } = {};
protected depositRoutes: { [originToken: string]: { [DestinationChainId: number]: boolean } } = {};
protected tokensBridged: TokensBridged[] = [];
Expand Down Expand Up @@ -296,7 +296,7 @@ export class SpokePoolClient extends BaseAbstractClient {
* Retrieves speed up requests grouped by depositor and depositId.
* @returns A mapping of depositor addresses to deposit ids with their corresponding speed up requests.
*/
public getSpeedUps(): { [depositorAddress: string]: { [depositId: number]: SpeedUp[] } } {
public getSpeedUps(): { [depositorAddress: string]: { [depositId: number]: SpeedUpWithBlock[] } } {
return this.speedUps;
}

Expand Down Expand Up @@ -592,7 +592,8 @@ export class SpokePoolClient extends BaseAbstractClient {
const speedUpEvents = [...(queryResults[eventsToQuery.indexOf("RequestedSpeedUpV3Deposit")] ?? [])];

for (const event of speedUpEvents) {
const speedUp: SpeedUp = { ...spreadEvent(event.args), originChainId: this.chainId };
const rawEvent = spreadEventWithBlockNumber(event);
const speedUp = { ...rawEvent, originChainId: this.chainId } as SpeedUpWithBlock;
assign(this.speedUps, [speedUp.depositor, speedUp.depositId], [speedUp]);

// Find deposit hash matching this speed up event and update the deposit data associated with the hash,
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/SpokePool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ export interface SpeedUp {
updatedMessage: string;
}

export interface SpeedUpWithBlock extends SpeedUp, SortableEvent {}

export interface SlowFillRequest extends RelayData {
destinationChainId: number;
}
Expand Down
12 changes: 12 additions & 0 deletions src/providers/retryProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ export class RetryProvider extends ethers.providers.StaticJsonRpcProvider {
...inputs
)
);

// This is added for interim testing to see whether relayer fill performance improves.
this.providers.forEach((provider) => {
const url = getOriginFromURL(provider.connection.url);
const { pollingInterval } = provider;
provider.pollingInterval = 1000;
logger?.debug({
at: "RetryProvider",
message: `Dropped ${url} pollingInterval ${pollingInterval} -> ${provider.pollingInterval}.`,
});
});

if (this.nodeQuorumThreshold < 1 || !Number.isInteger(this.nodeQuorumThreshold)) {
throw new Error(
`nodeQuorum,Threshold cannot be < 1 and must be an integer. Currently set to ${this.nodeQuorumThreshold}`
Expand Down
2 changes: 2 additions & 0 deletions src/providers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ const IGNORED_FIELDS = {
"l1BatchTimestamp", // zkSync
"size", // Alchemy/Arbitrum (temporary)
"totalDifficulty", // Quicknode/Alchemy (sometimes)
"logsBloom", // zkSync (third-party providers return 0x0..0)
"transactions", // Polygon yParity field in transactions[]
],
eth_getLogs: ["blockTimestamp", "transactionLogIndex", "l1BatchNumber", "logType"],
};
Expand Down
4 changes: 2 additions & 2 deletions test/common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe("Utils test", () => {
const relayerAddress = DEFAULT_SIMULATED_RELAYER_ADDRESS;

// @todo: Ensure that NODE_URL_1 is always defined in test CI?
const rpcUrl = process.env.NODE_URL_1 ?? "https://cloudflare-eth.com";
const rpcUrl = process.env.NODE_URL_1 ?? "https://mainnet.gateway.tenderly.co";
const provider = new providers.JsonRpcProvider(rpcUrl, 1);
const spokePool: SpokePool = SpokePool__factory.connect(spokePoolAddress, provider);

Expand All @@ -53,7 +53,7 @@ describe("Utils test", () => {
await estimateTotalGasRequiredByUnsignedTransaction(fill, relayerAddress, provider, 0.0, gasPrice);
expect(toBN(refGasEstimate).eq(toBN(refGasCost).mul(gasPrice))).to.be.true;

for (let gasMarkup = -0.99; gasMarkup <= 4.0; gasMarkup += 0.33) {
for (let gasMarkup = -0.99; gasMarkup <= 1.0; gasMarkup += 0.33) {
const { nativeGasCost, tokenGasCost } = await estimateTotalGasRequiredByUnsignedTransaction(
fill,
relayerAddress,
Expand Down

0 comments on commit 98dcc9b

Please sign in to comment.