Skip to content

Commit 3a6d15f

Browse files
committed
x/vm: remove MaxPrecompileCalls
1 parent 3e37931 commit 3a6d15f

File tree

4 files changed

+2
-46
lines changed

4 files changed

+2
-46
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
### STATE BREAKING
2626

27+
- [\#381](https://github.com/cosmos/evm/pull/381) Remove MaxPrecompileCalls (was 7). A transaction can now make any number of precompiled contracts calls.
28+
2729
### API-BREAKING
2830

2931
- [\#477](https://github.com/cosmos/evm/pull/477) Refactor precompile constructors to accept keeper interfaces instead of concrete implementations, breaking the existing `NewPrecompile` function signatures.

tests/integration/precompiles/staking/test_integration.go

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,39 +1813,6 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, create network.CreateEvmAp
18131813
Expect(txSenderFinalBal.Amount).To(Equal(txSenderInitialBal.Amount.Sub(fees)))
18141814
})
18151815

1816-
It("should revert the changes and NOT delegate - failed tx - max precompile calls reached", func() {
1817-
callArgs := testutiltypes.CallArgs{
1818-
ContractABI: stakingReverterContract.ABI,
1819-
MethodName: "multipleDelegations",
1820-
Args: []interface{}{
1821-
big.NewInt(int64(evmtypes.MaxPrecompileCalls + 2)), s.network.GetValidators()[0].OperatorAddress,
1822-
},
1823-
}
1824-
1825-
// Tx should fail due to MaxPrecompileCalls
1826-
_, _, err := s.factory.CallContractAndCheckLogs(
1827-
s.keyring.GetPrivKey(0),
1828-
evmtypes.EvmTxArgs{
1829-
To: &stkReverterAddr,
1830-
GasPrice: gasPrice.BigInt(),
1831-
},
1832-
callArgs,
1833-
execRevertedCheck,
1834-
)
1835-
Expect(err).To(BeNil(), "error while calling the smart contract: %v", err)
1836-
1837-
// contract balance should remain unchanged
1838-
balRes, err := s.grpcHandler.GetBalanceFromBank(stkReverterAddr.Bytes(), s.bondDenom)
1839-
Expect(err).To(BeNil())
1840-
contractFinalBalance := balRes.Balance
1841-
Expect(contractFinalBalance.Amount).To(Equal(contractInitialBalance.Amount))
1842-
1843-
// No delegation should be created
1844-
_, err = s.grpcHandler.GetDelegation(sdk.AccAddress(stkReverterAddr.Bytes()).String(), s.network.GetValidators()[0].OperatorAddress)
1845-
Expect(err).NotTo(BeNil())
1846-
Expect(err.Error()).To(ContainSubstring("not found"), "expected NO delegation created")
1847-
})
1848-
18491816
It("should delegate before and after intentionaly ignored delegation revert - successful tx", func() {
18501817
delegationAmount := math.NewInt(10)
18511818
expectedDelegationAmount := delegationAmount.Add(delegationAmount)

x/vm/statedb/statedb.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020

2121
"github.com/cosmos/evm/x/vm/store/snapshotmulti"
2222
vmstoretypes "github.com/cosmos/evm/x/vm/store/types"
23-
"github.com/cosmos/evm/x/vm/types"
2423

2524
errorsmod "cosmossdk.io/errors"
2625
storetypes "cosmossdk.io/store/types"
@@ -76,9 +75,6 @@ type StateDB struct {
7675

7776
// Per-transaction access list
7877
accessList *accessList
79-
80-
// The count of calls to precompiles
81-
precompileCallsCounter uint8
8278
}
8379

8480
func (s *StateDB) CreateContract(address common.Address) {
@@ -440,10 +436,6 @@ func (s *StateDB) AddPrecompileFn(addr common.Address, snapshot int, events sdk.
440436
return fmt.Errorf("could not add precompile call to address %s. State object not found", addr)
441437
}
442438
stateObject.AddPrecompileFn(snapshot, events)
443-
s.precompileCallsCounter++
444-
if s.precompileCallsCounter > types.MaxPrecompileCalls {
445-
return fmt.Errorf("max calls to precompiles (%d) reached", types.MaxPrecompileCalls)
446-
}
447439
return nil
448440
}
449441

x/vm/types/call.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,3 @@ const (
88
// Internal call type is used in case of smart contract methods calls
99
Internal
1010
)
11-
12-
// MaxPrecompileCalls is the maximum number of precompile
13-
// calls within a transaction. We want to limit this because
14-
// for each precompile tx we're creating a cached context
15-
const MaxPrecompileCalls uint8 = 7

0 commit comments

Comments
 (0)