Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

### STATE BREAKING

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

### API-BREAKING

- [\#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.
Expand Down
33 changes: 0 additions & 33 deletions tests/integration/precompiles/staking/test_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -1813,39 +1813,6 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, create network.CreateEvmAp
Expect(txSenderFinalBal.Amount).To(Equal(txSenderInitialBal.Amount.Sub(fees)))
})

It("should revert the changes and NOT delegate - failed tx - max precompile calls reached", func() {
callArgs := testutiltypes.CallArgs{
ContractABI: stakingReverterContract.ABI,
MethodName: "multipleDelegations",
Args: []interface{}{
big.NewInt(int64(evmtypes.MaxPrecompileCalls + 2)), s.network.GetValidators()[0].OperatorAddress,
},
}

// Tx should fail due to MaxPrecompileCalls
_, _, err := s.factory.CallContractAndCheckLogs(
s.keyring.GetPrivKey(0),
evmtypes.EvmTxArgs{
To: &stkReverterAddr,
GasPrice: gasPrice.BigInt(),
},
callArgs,
execRevertedCheck,
)
Expect(err).To(BeNil(), "error while calling the smart contract: %v", err)

// contract balance should remain unchanged
balRes, err := s.grpcHandler.GetBalanceFromBank(stkReverterAddr.Bytes(), s.bondDenom)
Expect(err).To(BeNil())
contractFinalBalance := balRes.Balance
Expect(contractFinalBalance.Amount).To(Equal(contractInitialBalance.Amount))

// No delegation should be created
_, err = s.grpcHandler.GetDelegation(sdk.AccAddress(stkReverterAddr.Bytes()).String(), s.network.GetValidators()[0].OperatorAddress)
Expect(err).NotTo(BeNil())
Expect(err.Error()).To(ContainSubstring("not found"), "expected NO delegation created")
})

It("should delegate before and after intentionaly ignored delegation revert - successful tx", func() {
delegationAmount := math.NewInt(10)
expectedDelegationAmount := delegationAmount.Add(delegationAmount)
Expand Down
9 changes: 1 addition & 8 deletions x/vm/statedb/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (

"github.com/cosmos/evm/x/vm/store/snapshotmulti"
vmstoretypes "github.com/cosmos/evm/x/vm/store/types"
"github.com/cosmos/evm/x/vm/types"

errorsmod "cosmossdk.io/errors"
storetypes "cosmossdk.io/store/types"
Expand Down Expand Up @@ -76,9 +75,6 @@ type StateDB struct {

// Per-transaction access list
accessList *accessList

// The count of calls to precompiles
precompileCallsCounter uint8
}

func (s *StateDB) CreateContract(address common.Address) {
Expand Down Expand Up @@ -449,10 +445,7 @@ func (s *StateDB) AddPrecompileFn(snapshot int, events sdk.Events) error {
snapshot: snapshot,
events: events,
})
s.precompileCallsCounter++
if s.precompileCallsCounter > types.MaxPrecompileCalls {
return fmt.Errorf("max calls to precompiles (%d) reached", types.MaxPrecompileCalls)
}

return nil
}

Expand Down
5 changes: 0 additions & 5 deletions x/vm/types/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,3 @@ const (
// Internal call type is used in case of smart contract methods calls
Internal
)

// 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
Loading