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: ensure that we fetch node info per estimation #3324

Merged
merged 17 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
54 changes: 29 additions & 25 deletions packages/account/src/providers/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,39 +598,41 @@ export default class Provider {
await this.fetchChainAndNodeInfo();
}

async refreshCacheFunction(): Promise<{ chain: ChainInfo; nodeInfo: NodeInfo }> {
maschad marked this conversation as resolved.
Show resolved Hide resolved
const data = await this.operations.getChainAndNodeInfo();

const nodeInfo = {
maxDepth: bn(data.nodeInfo.maxDepth),
maxTx: bn(data.nodeInfo.maxTx),
nodeVersion: data.nodeInfo.nodeVersion,
utxoValidation: data.nodeInfo.utxoValidation,
vmBacktrace: data.nodeInfo.vmBacktrace,
};

Provider.ensureClientVersionIsSupported(nodeInfo);
const chain = processGqlChain(data.chain);
Provider.chainInfoCache[this.urlWithoutAuth] = chain;
Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;

return { chain, nodeInfo };
}
Torres-ssf marked this conversation as resolved.
Show resolved Hide resolved

/**
* Return the chain and node information.
*
* @returns A promise that resolves to the Chain and NodeInfo.
*/
async fetchChainAndNodeInfo() {
let nodeInfo: NodeInfo;
let chain: ChainInfo;

async fetchChainAndNodeInfo(
refreshCache = false
): Promise<{ chain: ChainInfo; nodeInfo: NodeInfo }> {
if (refreshCache) {
return this.refreshCacheFunction();
}
try {
nodeInfo = this.getNode();
chain = this.getChain();
return { chain: this.getChain(), nodeInfo: this.getNode() };
} catch (error) {
const data = await this.operations.getChainAndNodeInfo();

nodeInfo = {
maxDepth: bn(data.nodeInfo.maxDepth),
maxTx: bn(data.nodeInfo.maxTx),
nodeVersion: data.nodeInfo.nodeVersion,
utxoValidation: data.nodeInfo.utxoValidation,
vmBacktrace: data.nodeInfo.vmBacktrace,
};

Provider.ensureClientVersionIsSupported(nodeInfo);
chain = processGqlChain(data.chain);
Provider.chainInfoCache[this.urlWithoutAuth] = chain;
Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
return this.refreshCacheFunction();
}

return {
chain,
nodeInfo,
};
}

/**
Expand Down Expand Up @@ -1150,6 +1152,8 @@ Supported fuel-core version: ${supportedVersion}.`
const { transactionRequest } = params;
let { gasPrice } = params;

await this.fetchChainAndNodeInfo(true);
maschad marked this conversation as resolved.
Show resolved Hide resolved

const chainInfo = this.getChain();
const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* eslint-disable @typescript-eslint/consistent-type-imports */

/*
Fuels version: 0.95.0
Fuels version: 0.96.0
*/

export { Src14OwnedProxy } from './Src14OwnedProxy';
Expand Down
Loading