Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
rouzwelt committed Jan 13, 2025
1 parent 253b381 commit 1264824
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 42 deletions.
48 changes: 34 additions & 14 deletions src/modes/interOrderbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,23 @@ export async function dryrun({
const estimation = await estimateGasCost(rawtx, signer, config, l1GasPrice);
l1Cost = estimation.l1Cost;
gasLimit = ethers.BigNumber.from(estimation.gas).mul(config.gasLimitMultiplier).div(100);
spanAttributes["gasEst.headroom.gasLimit"] = estimation.gas.toString();
spanAttributes["gasEst.headroom.totalCost"] = estimation.totalGasCost.toString();
spanAttributes["gasEst.headroom.gasPrice"] = estimation.gasPrice.toString();
if (config.isSpecialL2) {
spanAttributes["gasEst.headroom.l1GasPrice"] = estimation.l1GasPrice.toString();
spanAttributes["gasEst.headroom.l1Cost"] = estimation.l1Cost.toString();
}

// include dryrun headroom gas estimation in otel logs
extendSpanAttributes(
spanAttributes,
{
gasLimit: estimation.gas.toString(),
totalCost: estimation.totalGasCost.toString(),
gasPrice: estimation.gasPrice.toString(),
...(config.isSpecialL2
? {
l1GasPrice: estimation.l1Cost.toString(),
l1Cost: estimation.l1GasPrice.toString(),
}
: {}),
},
"gasEst.headroom",
);
} catch (e) {
const isNodeError = containsNodeError(e as BaseError);
const errMsg = errorSnapshot("", e);
Expand Down Expand Up @@ -188,13 +198,23 @@ export async function dryrun({
.div(100);
rawtx.gas = gasLimit.toBigInt();
gasCost = gasLimit.mul(gasPrice).add(estimation.l1Cost);
spanAttributes["gasEst.final.gasLimit"] = estimation.gas.toString();
spanAttributes["gasEst.final.totalCost"] = estimation.totalGasCost.toString();
spanAttributes["gasEst.final.gasPrice"] = estimation.gasPrice.toString();
if (config.isSpecialL2) {
spanAttributes["gasEst.final.l1GasPrice"] = estimation.l1GasPrice.toString();
spanAttributes["gasEst.final.l1Cost"] = estimation.l1Cost.toString();
}

// include dryrun final gas estimation in otel logs
extendSpanAttributes(
spanAttributes,
{
gasLimit: estimation.gas.toString(),
totalCost: estimation.totalGasCost.toString(),
gasPrice: estimation.gasPrice.toString(),
...(config.isSpecialL2
? {
l1GasPrice: estimation.l1Cost.toString(),
l1Cost: estimation.l1GasPrice.toString(),
}
: {}),
},
"gasEst.final",
);
task.evaluable.bytecode = await parseRainlang(
await getBountyEnsureRainlang(
ethers.utils.parseUnits(inputToEthPrice),
Expand Down
48 changes: 34 additions & 14 deletions src/modes/intraOrderbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,23 @@ export async function dryrun({
const estimation = await estimateGasCost(rawtx, signer, config, l1GasPrice);
l1Cost = estimation.l1Cost;
gasLimit = ethers.BigNumber.from(estimation.gas).mul(config.gasLimitMultiplier).div(100);
spanAttributes["gasEst.headroom.gasLimit"] = estimation.gas.toString();
spanAttributes["gasEst.headroom.totalCost"] = estimation.totalGasCost.toString();
spanAttributes["gasEst.headroom.gasPrice"] = estimation.gasPrice.toString();
if (config.isSpecialL2) {
spanAttributes["gasEst.headroom.l1GasPrice"] = estimation.l1GasPrice.toString();
spanAttributes["gasEst.headroom.l1Cost"] = estimation.l1Cost.toString();
}

// include dryrun headroom gas estimation in otel logs
extendSpanAttributes(
spanAttributes,
{
gasLimit: estimation.gas.toString(),
totalCost: estimation.totalGasCost.toString(),
gasPrice: estimation.gasPrice.toString(),
...(config.isSpecialL2
? {
l1GasPrice: estimation.l1Cost.toString(),
l1Cost: estimation.l1GasPrice.toString(),
}
: {}),
},
"gasEst.headroom",
);
} catch (e) {
// reason, code, method, transaction, error, stack, message
const isNodeError = containsNodeError(e as BaseError);
Expand Down Expand Up @@ -190,13 +200,23 @@ export async function dryrun({
.div(100);
rawtx.gas = gasLimit.toBigInt();
gasCost = gasLimit.mul(gasPrice).add(estimation.l1Cost);
spanAttributes["gasEst.final.gasLimit"] = estimation.gas.toString();
spanAttributes["gasEst.final.totalCost"] = estimation.totalGasCost.toString();
spanAttributes["gasEst.final.gasPrice"] = estimation.gasPrice.toString();
if (config.isSpecialL2) {
spanAttributes["gasEst.final.l1GasPrice"] = estimation.l1GasPrice.toString();
spanAttributes["gasEst.final.l1Cost"] = estimation.l1Cost.toString();
}

// include dryrun final gas estimation in otel logs
extendSpanAttributes(
spanAttributes,
{
gasLimit: estimation.gas.toString(),
totalCost: estimation.totalGasCost.toString(),
gasPrice: estimation.gasPrice.toString(),
...(config.isSpecialL2
? {
l1GasPrice: estimation.l1Cost.toString(),
l1Cost: estimation.l1GasPrice.toString(),
}
: {}),
},
"gasEst.final",
);
task.evaluable.bytecode = await parseRainlang(
await getWithdrawEnsureRainlang(
signer.account.address,
Expand Down
48 changes: 34 additions & 14 deletions src/modes/routeProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,23 @@ export async function dryrun({
gasLimit = ethers.BigNumber.from(estimation.gas)
.mul(config.gasLimitMultiplier)
.div(100);
spanAttributes["gasEst.headroom.gasLimit"] = estimation.gas.toString();
spanAttributes["gasEst.headroom.totalCost"] = estimation.totalGasCost.toString();
spanAttributes["gasEst.headroom.gasPrice"] = estimation.gasPrice.toString();
if (config.isSpecialL2) {
spanAttributes["gasEst.headroom.l1GasPrice"] = estimation.l1GasPrice.toString();
spanAttributes["gasEst.headroom.l1Cost"] = estimation.l1Cost.toString();
}

// include dryrun headroom gas estimation in otel logs
extendSpanAttributes(
spanAttributes,
{
gasLimit: estimation.gas.toString(),
totalCost: estimation.totalGasCost.toString(),
gasPrice: estimation.gasPrice.toString(),
...(config.isSpecialL2
? {
l1GasPrice: estimation.l1Cost.toString(),
l1Cost: estimation.l1GasPrice.toString(),
}
: {}),
},
"gasEst.headroom",
);
} catch (e) {
// reason, code, method, transaction, error, stack, message
const isNodeError = containsNodeError(e as BaseError);
Expand Down Expand Up @@ -254,13 +264,23 @@ export async function dryrun({
.div(100);
rawtx.gas = gasLimit.toBigInt();
gasCost = gasLimit.mul(gasPrice).add(estimation.l1Cost);
spanAttributes["gasEst.final.gasLimit"] = estimation.gas.toString();
spanAttributes["gasEst.final.totalCost"] = estimation.totalGasCost.toString();
spanAttributes["gasEst.final.gasPrice"] = estimation.gasPrice.toString();
if (config.isSpecialL2) {
spanAttributes["gasEst.final.l1GasPrice"] = estimation.l1GasPrice.toString();
spanAttributes["gasEst.final.l1Cost"] = estimation.l1Cost.toString();
}

// include dryrun final gas estimation in otel logs
extendSpanAttributes(
spanAttributes,
{
gasLimit: estimation.gas.toString(),
totalCost: estimation.totalGasCost.toString(),
gasPrice: estimation.gasPrice.toString(),
...(config.isSpecialL2
? {
l1GasPrice: estimation.l1Cost.toString(),
l1Cost: estimation.l1GasPrice.toString(),
}
: {}),
},
"gasEst.final",
);
task.evaluable.bytecode = await parseRainlang(
await getBountyEnsureRainlang(
ethers.utils.parseUnits(ethPrice),
Expand Down

0 comments on commit 1264824

Please sign in to comment.