[Neo Core Fix] Check params at Calling Contract#3438
[Neo Core Fix] Check params at Calling Contract#3438Jim8y wants to merge 34 commits intoneo-project:HF_Echidnafrom
Conversation
|
Wait, wait, wait a minute! As much as I love this change you can't just roll it out with the nearest hardfork. Remember all the pain of #2810. We need to:
|
|
Will this affect calls between contracts? |
Exactly, this pr is marked as blocked, so will not be merged without careful review and discussion. |
Yes, it will. That is why this pr may only take effect to contracts that are depolyed or updated after the next hardfork,,,,,, will be discussed. |
shargon
left a comment
There was a problem hiding this comment.
It's hard to know if this will break some contracts, because we can alter the type in some operations and the opcodes are compatible with multiple types..
| private static bool CheckItemType(StackItem item, ContractParameterType type) | ||
| { | ||
| StackItemType aType = item.Type; | ||
| if (aType == StackItemType.Any) return true; |
There was a problem hiding this comment.
I don't think it's correct for VM-compatible SC types, because for example, if you require stackitem to be Boolean, then Any just doesn't match this requirement.
There was a problem hiding this comment.
I see what you mean, will update.
| for (int i = args.Count - 1; i >= 0; i--) | ||
| { | ||
| if (!CheckItemType(args[i], method.Parameters[i].Type)) | ||
| throw new InvalidOperationException($"The type of the argument `{args[i]}` does not match the formal parameter."); |
There was a problem hiding this comment.
It may be too harsh for mainnet contracts (even if enabled with hardfrok), this change may break some of them and even prevent them from update. What do you think about using the same approach as it was done for SC Events parameters check (#2810 (comment)): in next release we firstly enable a warning log in case of parameters mismatch, and then in the subsequent release we convert the log to an exception.
There was a problem hiding this comment.
It may be too harsh for mainnet contracts (even if enabled with hardfrok), this change may break some of them and even prevent them from update. What do you think about using the same approach as it was done for SC Events parameters check (#2810 (comment)): in next release we firstly enable a warning log in case of parameters mismatch, and then in the subsequent release we convert the log to an exception.
We have discussed this in the last meeting, check will only happen for newly deployed or updated contracts, this pr will be updated.
…eo-project#3449) * Part-1 `Neo.IO` - move * Part-2 * Added `BigInteger` to `Neo.Extensions` * Found more `BigInteger` * Added `ByteArray` to `Neo.Extensions` * Added `DateTime` Extensions to `Neo.Extensions` * Added `HashSetExtensions`, `HashSetExtensions2`, `IpAddressExtensions`, `AssemblyExtensions`, `StringExtensdions` Deleted `Helper.cs` file * Added `ICollection`, `Memory`, `String`, `Unsafe` extensions * Adding `using` * dotnet format * Added more Extensions * Move some methods * Added Tests * Added `tests` from `Part-2` * Added `tests` for `PART-4` * Added `tests` for `PART-5` * Added the `Part` 7 * `PART-8` * `PART-9` * `PART-10` * Revert some changes --------- Co-authored-by: Shargon <shargon@gmail.com>
* [Add] Get Accounts and Balances for GasToken * Removed `BalanceOf` extension * Added null check * Changed `Seek` to `Find` for `DataCache` --------- Co-authored-by: Jimmy <jinghui@wayne.edu>
* Update to correct version of `dotnet` for devcontainer * Add comment --------- Co-authored-by: Jimmy <jinghui@wayne.edu> Co-authored-by: NGD Admin <154295625+NGDAdmin@users.noreply.github.com>
Co-authored-by: NGD Admin <154295625+NGDAdmin@users.noreply.github.com>
…3626) * fix: UInt160.TryParse when source has whitespaces * Update tests/Neo.UnitTests/UT_UInt160.cs --------- Co-authored-by: Shargon <shargon@gmail.com> Co-authored-by: Jimmy <jinghui@wayne.edu>
* feature: add missed unit-tests for LogStorageStore * feature: add missed unit-tests for LogStorageStore --------- Co-authored-by: Jimmy <jinghui@wayne.edu> Co-authored-by: NGD Admin <154295625+NGDAdmin@users.noreply.github.com>
* fix issue 3629 * update test * format * add debug for rpcexception * Update src/Plugins/RpcServer/RpcException.cs --------- Co-authored-by: nan01ab <yjcc201374@outlook.com>
# Conflicts: # tests/Neo.UnitTests/SmartContract/Native/UT_NeoToken.cs
shargon
left a comment
There was a problem hiding this comment.
Is not rebased? I see changes from other PRs
I am tring to fix, but still have no clue, changed that are already merged into the base branch still showing here, i tried reset, rebase, merge,,, none of them work |
Description
Neo core does not check the type of vales being passed to the contract, and this can cause problems.
for example: neo-project/neo-devpack-dotnet#863
Fixes # #1891 neo-project/neo-devpack-dotnet#863
Type of change
How Has This Been Tested?
Test Configuration:
Checklist: