aurora-is-near / aurora-engine

⚙️ Aurora Engine implements an Ethereum Virtual Machine (EVM) on the NEAR Protocol.
https://doc.aurora.dev/develop/compat/evm
327 stars 80 forks source link

Prevent subtraction underflow in CrossContractCall #888

Closed guidovranken closed 8 months ago

guidovranken commented 8 months ago

Description

call.promise_count() can be 0, in which case call.promise_count() - 1 causes a subtraction underflow:

https://github.com/aurora-is-near/aurora-engine/blob/1213f2c7c035aa523601fced8f75bef61b4728ab/engine-precompiles/src/xcc.rs#L141

This PR makes the function return to caller with an error if (and only if) this is the case.

Performance / NEAR gas cost considerations

Testing

Fuzzing.

How should this be reviewed

Additional information

aleksuss commented 8 months ago

Probably this PR should be merged after #885.