Skip to content

Calling deployed contract method fails with "Exceeded the cost limit of the guaranteed section" #291

@adamreynolds-io

Description

@adamreynolds-io

Context & versions

Not specified in the original ticket.

Steps to reproduce

Deploy the following contract:

export ledger round: Counter;
export ledger set: Set<Uint<64>>;
export ledger list: List<Uint<64>>;
export ledger map1: Map<Uint<64>, Vector<1, Uint<64>>>;
export ledger map2: Map<Uint<64>, Vector<1, Vector<1, Uint<64>>>>;

export circuit tom(b: Boolean, c: Boolean): Uint<32> {
    return ((b: Boolean, c: Boolean) : Uint<32> => {
      if(b != c) {
        return 1 * (b as Uint<32>);
      } else {
        return 1 * (c as Uint<32>);
      }
    })(b, c);
}

constructor() {
  tom(true, false);
}

export circuit increment(): [] {
  for (const i of 1..5) {
    round.increment(i);
    set.insert(i);
    list.pushFront(i);
    map1.insert(i, [i]);
    map2.insert(i, [[1]]);
    kernel.checkpoint();
  }
}

export circuit decrement(): [] {
  round.decrement(1);
}

import CompactStandardLibrary;

Then call the increment method on the deployed contract.

Actual behavior

Calling increment fails with:

Exceeded the cost limit of the guaranteed section (real cost: 386313, without tx size cost: 371832, limit: 362025)

Expected behavior

Either the circuit executes within the cost limit, or the compiler/tooling provides a way for users to understand and predict the transaction cost before deployment so they can avoid this error.


Migrated from PM-16380

Metadata

Metadata

Assignees

Labels

triagedIssues that have been triaged by the team

Type

No type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions