-
Notifications
You must be signed in to change notification settings - Fork 113
Open
Labels
Description
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:
Lines 65 to 66 in a48a796
| // The count of calls to precompiles | |
| precompileCallsCounter uint8 |
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:
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