'solidity delegatecall to call issue?

My delegatecall to call flow isn't completing the transaction and has no errors to show. is it a gas issue? (local harhdat)

I have the following:

contract TestRouter {
    using SafeERC20 for IERC20;

    constructor() {}

    function deposit2(address asset, uint256 amount, address pool_, address caller) public {
        (bool success, bytes memory result) = pool_.call(abi.encodeWithSignature("deposit(address,uint256,address,uint16)",asset,amount,caller,0));
        console.log("deposit2", success);

}

contract TestRoutee {
    using SafeERC20 for IERC20;
    address public testRouter;

    constructor(address _testRouter) {
        testRouter = _testRouter;
    }

    function deposit(address asset, uint256 _amount, address pool_) public {
        IERC20(asset).safeTransferFrom(msg.sender, address(this), _amount);
        IERC20(asset).approve(pool_, _amount);
        (bool success, bytes memory result) = testRouter.delegatecall(abi.encodeWithSignature("deposit2(address,uint256,address,address)",asset,_amount,pool_,address(this)));
    }
}

The flow is user -> TestRoutee.deposit(...) -> TestRouter.deposit2(...) -> LendingPool.sol (AAVE V2)

This ends up going to another protocol called AAVE V2

The function calling in that protocol is:

  function deposit(
    address asset,
    uint256 amount,
    address onBehalfOf,
    uint16 referralCode
  ) external override whenNotPaused {
    DataTypes.ReserveData storage reserve = _reserves[asset];

    console.log("deposit asset", asset);
    console.log("deposit amount", amount);
    console.log("deposit onBehalfOf", onBehalfOf);
    console.log("deposit referralCode", referralCode);
    console.log("deposit msg.sender", msg.sender);

    ValidationLogic.validateDeposit(reserve, amount);

    address aToken = reserve.aTokenAddress;

    reserve.updateState();
    reserve.updateInterestRates(asset, aToken, amount, 0);

    IERC20(asset).safeTransferFrom(msg.sender, aToken, amount);

    bool isFirstDeposit = IAToken(aToken).mint(onBehalfOf, amount, reserve.liquidityIndex);

    if (isFirstDeposit) {
      _usersConfig[onBehalfOf].setUsingAsCollateral(reserve.id, true);
      emit ReserveUsedAsCollateralEnabled(asset, onBehalfOf);
    }

    emit Deposit(asset, msg.sender, onBehalfOf, amount, referralCode);
  }

In that protocol, I deployed it locally and have it console.log'ing msg.sender and onBehalfOf correctly, that is it is showing the address of TestRoutee, which is what I want.

Although, it only gets up to console.log("deposit after safeTransferFrom");... Which is odd.

In there, the function is gets caught up on is the _mint function:

  function _mint(address account, uint256 amount) internal virtual {
    require(account != address(0), 'ERC20: mint to the zero address');
    console.log("IncentivizedERC20 after require");

    _beforeTokenTransfer(address(0), account, amount);

    uint256 oldTotalSupply = _totalSupply;
    _totalSupply = oldTotalSupply.add(amount);

    uint256 oldAccountBalance = _balances[account];
    console.log("IncentivizedERC20 _mint oldAccountBalance", oldAccountBalance);
    _balances[account] = oldAccountBalance.add(amount);
    console.log("IncentivizedERC20 _mint oldAccountBalance", oldAccountBalance);

    if (address(_getIncentivesController()) != address(0)) {
      _getIncentivesController().handleAction(account, oldTotalSupply, oldAccountBalance);
    }
  }

It console.log's up until console.log("IncentivizedERC20 _mint oldAccountBalance", oldAccountBalance);. Is it running out of gas or is there anohter issue here?

There shouldn't be any storage issues with the delegatecall, which is a usual concern but i pass all of the parameters to the TestRouter contract and it calls the LendingPool successfully.



Solution 1:[1]

IIUC:

df[df["Image_Type"] == "CBCT"].groupby("Patient_ID").size() == df.groupby("Patient_ID").size()

#Patient_ID
#P001    False
#P002     True
#P003     True
#dtype: bool

I'm using df as

   Patient_ID Image_Type
0        P001     Paired
1        P001     Paired
2        P001     Paired
3        P001       CBCT
4        P002       CBCT
5        P002       CBCT
6        P002       CBCT
7        P002       CBCT
8        P002       CBCT
9        P002       CBCT
10       P003       CBCT

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pablo C