Skip to content

[Feature]: Lift maximum precompile calls limit #135

@Pitasi

Description

@Pitasi

Summary

An arbitrary limit of 7 precompiled contract was introduced to prevent perfomance issues since a deep copy of the story was being made at every call, but that's no longer the case.

Problem Definition

No response

Proposed Feature

  • currently, a smart contract can make a maximum of 7 calls to precompiled contracts
  • this limit was introduced because each call made a deep copy of the store
  • after deps: Remove SDK Fork #79, the need for a deep copy was removed

See the precompiles counter here:

// The count of calls to precompiles
precompileCallsCounter uint8

evm/x/vm/statedb/statedb.go

Lines 345 to 359 in a48a796

// AddPrecompileFn adds a precompileCall journal entry
// with a snapshot of the multi-store and events previous
// to the precompile call.
func (s *StateDB) AddPrecompileFn(addr common.Address, cms storetypes.CacheMultiStore, events sdk.Events) error {
stateObject := s.getOrNewStateObject(addr)
if stateObject == nil {
return fmt.Errorf("could not add precompile call to address %s. State object not found", addr)
}
stateObject.AddPrecompileFn(cms, events)
s.precompileCallsCounter++
if s.precompileCallsCounter > types.MaxPrecompileCalls {
return fmt.Errorf("max calls to precompiles (%d) reached", types.MaxPrecompileCalls)
}
return nil
}

And the maximum count defined here:

evm/x/vm/types/call.go

Lines 12 to 15 in a48a796

// MaxPrecompileCalls is the maximum number of precompile
// calls within a transaction. We want to limit this because
// for each precompile tx we're creating a cached context
const MaxPrecompileCalls uint8 = 7

Work Breakdown

#### Must have
- [ ] remove precompile calls counter

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions