Skip to content

Commit

Permalink
Revert "update"
Browse files Browse the repository at this point in the history
This reverts commit 7cfd60c.
  • Loading branch information
rouzwelt committed Feb 14, 2025
1 parent 37a5f3c commit a11452d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 29 deletions.
6 changes: 3 additions & 3 deletions src/modes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,21 @@ export async function findOpp({
if ((allResults[0] as any)?.reason?.spanAttributes) {
extendSpanAttributes(
spanAttributes,
JSON.stringify((allResults[0] as any).reason.spanAttributes),
(allResults[0] as any).reason.spanAttributes,
"routeProcessor",
);
}
if ((allResults[1] as any)?.reason?.spanAttributes) {
extendSpanAttributes(
spanAttributes,
JSON.stringify((allResults[1] as any).reason.spanAttributes),
(allResults[1] as any).reason.spanAttributes,
"intraOrderbook",
);
}
if ((allResults[2] as any)?.reason?.spanAttributes) {
extendSpanAttributes(
spanAttributes,
JSON.stringify((allResults[2] as any).reason.spanAttributes),
(allResults[2] as any).reason.spanAttributes,
"interOrderbook",
);
}
Expand Down
10 changes: 5 additions & 5 deletions src/modes/interOrderbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export async function dryrun({
// include dryrun headroom gas estimation in otel logs
extendSpanAttributes(
spanAttributes,
JSON.stringify({
{
gasLimit: estimation.gas.toString(),
totalCost: estimation.totalGasCost.toString(),
gasPrice: estimation.gasPrice.toString(),
Expand All @@ -140,7 +140,7 @@ export async function dryrun({
l1GasPrice: estimation.l1GasPrice.toString(),
}
: {}),
}),
},
"gasEst.headroom",
);
} catch (e) {
Expand Down Expand Up @@ -214,7 +214,7 @@ export async function dryrun({
// include dryrun final gas estimation in otel logs
extendSpanAttributes(
spanAttributes,
JSON.stringify({
{
gasLimit: estimation.gas.toString(),
totalCost: estimation.totalGasCost.toString(),
gasPrice: estimation.gasPrice.toString(),
Expand All @@ -224,7 +224,7 @@ export async function dryrun({
l1GasPrice: estimation.l1GasPrice.toString(),
}
: {}),
}),
},
"gasEst.final",
);
task.evaluable.bytecode = await parseRainlang(
Expand Down Expand Up @@ -426,7 +426,7 @@ export async function findOpp({
for (let i = 0; i < e.errors.length; i++) {
extendSpanAttributes(
spanAttributes,
JSON.stringify(e.errors[i].spanAttributes),
e.errors[i].spanAttributes,
"againstOrderbooks." + opposingOrderbookOrders[i].orderbook,
);
}
Expand Down
14 changes: 5 additions & 9 deletions src/modes/intraOrderbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export async function dryrun({
// include dryrun headroom gas estimation in otel logs
extendSpanAttributes(
spanAttributes,
JSON.stringify({
{
gasLimit: estimation.gas.toString(),
totalCost: estimation.totalGasCost.toString(),
gasPrice: estimation.gasPrice.toString(),
Expand All @@ -132,7 +132,7 @@ export async function dryrun({
l1GasPrice: estimation.l1GasPrice.toString(),
}
: {}),
}),
},
"gasEst.headroom",
);
} catch (e) {
Expand Down Expand Up @@ -216,7 +216,7 @@ export async function dryrun({
// include dryrun final gas estimation in otel logs
extendSpanAttributes(
spanAttributes,
JSON.stringify({
{
gasLimit: estimation.gas.toString(),
totalCost: estimation.totalGasCost.toString(),
gasPrice: estimation.gasPrice.toString(),
Expand All @@ -226,7 +226,7 @@ export async function dryrun({
l1GasPrice: estimation.l1GasPrice.toString(),
}
: {}),
}),
},
"gasEst.final",
);
task.evaluable.bytecode = await parseRainlang(
Expand Down Expand Up @@ -394,11 +394,7 @@ export async function findOpp({
});
} catch (e: any) {
allNoneNodeErrors.push(e?.value?.noneNodeError);
extendSpanAttributes(
spanAttributes,
JSON.stringify(e.spanAttributes),
"intraOrderbook." + i,
);
extendSpanAttributes(spanAttributes, e.spanAttributes, "intraOrderbook." + i);
}
}
const noneNodeErrors = allNoneNodeErrors.filter((v) => !!v);
Expand Down
12 changes: 6 additions & 6 deletions src/modes/routeProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export async function dryrun({
// include dryrun headroom gas estimation in otel logs
extendSpanAttributes(
spanAttributes,
JSON.stringify({
{
gasLimit: estimation.gas.toString(),
totalCost: estimation.totalGasCost.toString(),
gasPrice: estimation.gasPrice.toString(),
Expand All @@ -203,7 +203,7 @@ export async function dryrun({
l1GasPrice: estimation.l1GasPrice.toString(),
}
: {}),
}),
},
"gasEst.headroom",
);
} catch (e) {
Expand Down Expand Up @@ -279,7 +279,7 @@ export async function dryrun({
// include dryrun final gas estimation in otel logs
extendSpanAttributes(
spanAttributes,
JSON.stringify({
{
gasLimit: estimation.gas.toString(),
totalCost: estimation.totalGasCost.toString(),
gasPrice: estimation.gasPrice.toString(),
Expand All @@ -289,7 +289,7 @@ export async function dryrun({
l1GasPrice: estimation.l1GasPrice.toString(),
}
: {}),
}),
},
"gasEst.final",
);
task.evaluable.bytecode = await parseRainlang(
Expand Down Expand Up @@ -430,7 +430,7 @@ export async function findOpp({
// the fail reason can only be no route in case all hops fail reasons are no route
if (e.reason !== RouteProcessorDryrunHaltReason.NoRoute) noRoute = false;
allNoneNodeErrors.push(e?.value?.noneNodeError);
extendSpanAttributes(spanAttributes, JSON.stringify(e.spanAttributes), "full");
extendSpanAttributes(spanAttributes, e.spanAttributes, "full");
}
if (!hasPriceMatch.value) {
const maxTradeSize = findMaxInput({
Expand Down Expand Up @@ -463,7 +463,7 @@ export async function findOpp({
// the fail reason can only be no route in case all hops fail reasons are no route
if (e.reason !== RouteProcessorDryrunHaltReason.NoRoute) noRoute = false;
allNoneNodeErrors.push(e?.value?.noneNodeError);
extendSpanAttributes(spanAttributes, JSON.stringify(e.spanAttributes), "partial");
extendSpanAttributes(spanAttributes, e.spanAttributes, "partial");
}
}
}
Expand Down
10 changes: 4 additions & 6 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -816,18 +816,16 @@ export function scale18To(value: BigNumberish, targetDecimals: BigNumberish): Bi
*/
export function extendSpanAttributes(
spanAttributes: Record<string, any>,
newAttributes: string,
newAttributes: Record<string, any>,
header: string,
excludeHeaderForKeys: string[] = [],
) {
const attrs = JSON.parse(newAttributes);
for (const attrKey in attrs) {
for (const attrKey in newAttributes) {
if (!excludeHeaderForKeys.includes(attrKey)) {
spanAttributes[header + "." + attrKey] = attrs[attrKey];
Object.assign(spanAttributes, { [header + "." + attrKey]: newAttributes[attrKey] });
} else {
spanAttributes[attrKey] = attrs[attrKey];
Object.assign(spanAttributes, { [attrKey]: newAttributes[attrKey] });
}
delete attrs[attrKey];
}
}

Expand Down

0 comments on commit a11452d

Please sign in to comment.