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

soroban-cli: allow dev to set transaction limits #1130

Closed
namankumar opened this issue Dec 13, 2023 · 1 comment
Closed

soroban-cli: allow dev to set transaction limits #1130

namankumar opened this issue Dec 13, 2023 · 1 comment

Comments

@namankumar
Copy link

What problem does your feature solve?

Debugging resource-related issues and getting around bugs in the preflight flow.

What would you like to see?

  • CLI allows dev to set limits for a particular resource-type. The specified limits can be greater than the estimated cost. If preflight estimates 10M cpu insn for my transaction, allow me to set 20M.
  • Allow for setting limits of multiple resource types.

What alternatives are there?

Use the JS SDK:

// transactionData field from https://soroban.stellar.org/api/methods/simulateTransaction
const preflightResponse = /* base64 */
const txBuilder = /* ... some TransactionBuilder instance ... */
const tx = txBuilder.setSorobanData(
    bumpCpuInstructions(preflightResponse, BUMP_FACTOR).build()
).build();

function bumpCpuInstructions(
    preflight: string, 
    bumpFactor: number
): SorobanDataBuilder {
    const sorobanData = new SorobanDataBuilder(preflight).build();

    // get existing data
    const [ cpuIns, rdBytes, wrBytes ] = [ 
        sorobanData.resources().instructions(),
        sorobanData.resources().readBytes(),
        sorobanData.resources().writeBytes(),
    ];
    
    return new SorobanDataBuilder(preflightResponse)
        .setResources(cpuIns + bumpFactor, rdBytes, wrBytes);
}
@janewang
Copy link
Contributor

Closing as a dup of #1148

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@namankumar @janewang and others