Skip to content

Commit

Permalink
fix: update to minGasPrice = 1
Browse files Browse the repository at this point in the history
  • Loading branch information
LuizAsFight committed Dec 14, 2023
1 parent c134329 commit 2f7d29b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 19 deletions.
1 change: 1 addition & 0 deletions docker/fuel-core/fuel_core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ exec /root/fuel-core run \
--relayer $L1_CHAIN_HTTP \
--relayer-v2-listening-contracts $FUEL_MESSAGE_PORTAL_CONTRACT_ADDRESS \
--poa-interval-period 1s \
--min-gas-price 1 \
--chain ./chainConfig.json
14 changes: 11 additions & 3 deletions packages/integration-tests/tests/bridge_erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from '@fuel-bridge/test-utils';
import chai from 'chai';
import type { BigNumber, Signer } from 'ethers';
import { Address, BN, InputType } from 'fuels';
import { Address, BN, InputType, bn } from 'fuels';
import type {
AbstractAddress,
Contract,
Expand Down Expand Up @@ -58,11 +58,20 @@ describe('Bridging ERC20 tokens', async function () {
);
fuel_testContractId = fuel_testToken.id.toHexString();
fuel_testAssetId = getTokenId(fuel_testToken);

const { value: expectedTokenContractId } = await fuel_testToken.functions
.bridged_token()
.txParams({
gasLimit: bn(1_000),
gasPrice: FUEL_TX_PARAMS.gasPrice,
})
.dryRun();
const { value: expectedGatewayContractId } = await fuel_testToken.functions
.bridged_token_gateway()
.txParams({
gasLimit: bn(1_000),
gasPrice: FUEL_TX_PARAMS.gasPrice,
})
.dryRun();

// check that values for the test token and gateway contract match what
Expand Down Expand Up @@ -144,7 +153,6 @@ describe('Bridging ERC20 tokens', async function () {
it('Relay message from Ethereum on Fuel', async function () {
// override the default test timeout from 2000ms
this.timeout(FUEL_MESSAGE_TIMEOUT_MS);

// relay the message ourselves
const message = await waitForMessage(
env.fuel.provider,
Expand All @@ -153,7 +161,7 @@ describe('Bridging ERC20 tokens', async function () {
FUEL_MESSAGE_TIMEOUT_MS
);
expect(message).to.not.be.null;
const tx = await relayCommonMessage(env.fuel.deployer, message);
const tx = await relayCommonMessage(env.fuel.deployer, message, { ...FUEL_TX_PARAMS, maturity: undefined });
expect((await tx.waitForResult()).status).to.equal('success');
});

Expand Down
3 changes: 2 additions & 1 deletion packages/test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"./dist"
],
"scripts": {
"build": "tsup"
"build": "tsup",
"build:watch": "tsup --watch"
},
"peerDependencies": {
"fuels": "next",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,9 @@ export async function getOrDeployFuelTokenContract(
storageSlots: [],
}
);
// This for avoiding transaction for failing because of insufficient funds
// The current fund method only accounts for a static gas fee that is not
// enough for deploying a contract
transactionRequest.gasPrice = bn(100_000);
const { maxFee, requiredQuantities } =
await fuelAcct.provider.getTransactionCost(transactionRequest);
await fuelAcct.fund(transactionRequest, requiredQuantities, maxFee);
// Chnage gas price back to the original value provided via params
transactionRequest.gasPrice = bn(fuelTxParams.gasPrice);
// send transaction
const response = await fuelAcct.sendTransaction(transactionRequest);
await response.wait();
Expand All @@ -113,6 +107,10 @@ export async function getOrDeployFuelTokenContract(

await fuelTestToken.functions
.register_bridge()
.txParams({
gasPrice: bn(fuelTxParams.gasPrice),
gasLimit: bn(10_000)
})
.callParams({
gasLimit: bn(10_000)
})
Expand Down Expand Up @@ -152,8 +150,8 @@ export async function getOrDeployFuelTokenContract(
waitForBlockFinalization(env, messageProof),
])
)
.then(([relayMessageParams]) =>
env.eth.fuelMessagePortal.relayMessage(
.then(([relayMessageParams]) =>
env.eth.fuelMessagePortal.relayMessage(
relayMessageParams.message,
relayMessageParams.rootBlockHeader,
relayMessageParams.blockHeader,
Expand Down
17 changes: 10 additions & 7 deletions packages/test-utils/src/utils/fuels/relayCommonMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ function getCommonRelayableMessages(provider: Provider) {
// build the transaction
const transaction = new ScriptTransactionRequest({
script,
...txParams,
});
transaction.inputs.push({
type: InputType.Message,
Expand Down Expand Up @@ -102,11 +101,15 @@ function getCommonRelayableMessages(provider: Provider) {

transaction.witnesses.push('0x');

const { gasUsed } = await relayer.provider.getTransactionCost(
transaction
);
transaction.gasPrice = bn(txParams.gasPrice);
console.log(`transaction`, transaction);

// const { gasUsed } = await relayer.provider.getTransactionCost(
// transaction
// );

transaction.gasLimit = gasUsed.mul(1.2);
// transaction.gasLimit = gasUsed.mul(1.2);
transaction.gasLimit = bn(10_000);

debug(
'-------------------------------------------------------------------'
Expand Down Expand Up @@ -145,10 +148,10 @@ type CommonMessageDetails = {
export async function relayCommonMessage(
relayer: FuelWallet,
message: Message,
txParams: Pick<
txParams?: Pick<
ScriptTransactionRequestLike,
'gasLimit' | 'gasPrice' | 'maturity'
> = {}
>
): Promise<TransactionResponse> {
// find the relay details for the specified message
let messageRelayDetails: CommonMessageDetails = null;
Expand Down

0 comments on commit 2f7d29b

Please sign in to comment.