Concordium / concordium-node

The main concordium node implementation.
GNU Affero General Public License v3.0
45 stars 22 forks source link

InvokeInstance incorrectly counts the amount as the payment amount. #998

Closed abizjak closed 1 year ago

abizjak commented 1 year ago

Bug Description

When running InvokeInstance, the amount that is supplied is used both as the amount to transfer to the instance, and the amount that is reserved for payment of fees. This latter part is incorrect and can lead to spurious "insufficient funds" errors when dry-running contract updates.

Steps to Reproduce

./concordium-client --grpc-ip node.tesntet.concordium.com contract invoke 5881 --entrypoint receive --invoker-account $ACCOUNT --amount ...

works when the amount ... is <= 1/2 of the accounts amount but not if it is more.

The contract being invoked is simple

#[receive(contract = "test_invoke_instance", name = "receive", mutable, payable)]
fn receive<S: HasStateApi>(
    _ctx: &impl HasReceiveContext,
    _host: &mut impl HasHost<State, StateApiType = S>,
    _amount: Amount,
) -> ReceiveResult<()> {
    Ok(())
}

Versions

mh-concordium commented 1 year ago

Just for information, now there is the same contract initialized on Stagenet (index 5) if needed for testing.