Skip to content
This repository was archived by the owner on May 12, 2025. It is now read-only.

Conversation

zeroXbrock
Copy link
Member

@zeroXbrock zeroXbrock commented Feb 29, 2024

  • adds Bundle.simulateBundle(bundleObj): syntactical sugar to call Suave.simulateBundle(encodeSimBundle(bundleObj))
  • adds encodeSimBundle: encodes bundleObj for Bundle.simulateBundle
bundleObj = Bundle.BundleObj({
    blockNumber: uint64(bundle.blockNumber + i),
    minTimestamp: 0,
    maxTimestamp: 0,
    txns: bundle.txs,
    revertingHashes: new bytes32[](0),
    refundPercent: 51
});

// simulate bundle and revert if it fails
uint64 simResult = Bundle.simulateBundle(bundleObj);
require(simResult > 0, "sim failed");

// send bundle w/ same bundleObj
bundleRes = Bundle.sendBundle(GOERLI_BUNDLE_RPC, bundleObj);

you can also use the using ... for syntax:

using Bundle for Bundle.BundleObj;

// ...

uint64 egp = bundleObj.simulateBundle();

merged with #51 to use its JSON library removed bc gas too high

@zeroXbrock zeroXbrock changed the title simulateBundle helpers simulateBundle helpers + JSON RPC lib from #51 Mar 13, 2024
Copy link

@lthibault lthibault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked really hard for something to nit pick about, but couldn't find anything.
LGTM. Send it :)

@zeroXbrock
Copy link
Member Author

While doing some integration testing, I noticed that the JSON encoder lib is using a LOT of gas. I have to set my gas limit to 30M for one CCR that JSON-encodes 10 (each) simBundle & sendBundle payloads. When the CCR lands, it only ends up using about 36k gas. But if I don't set the limit extremely high, I get an out of gas error.

Is this OK? I wonder if it would be better to do the JSON encoding offchain to avoid this, or maybe there's a way to tweak the gas estimate logic on the backend to avoid this confusion.
cc @jinmel @lthibault @ferranbt

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants