Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contract Permission exception still affecting neo #2890 #2899

Closed
cschuchardt88 opened this issue Sep 6, 2023 · 3 comments · Fixed by #2948
Closed

Contract Permission exception still affecting neo #2890 #2899

cschuchardt88 opened this issue Sep 6, 2023 · 3 comments · Fixed by #2948

Comments

@cschuchardt88
Copy link
Member

cschuchardt88 commented Sep 6, 2023

Describe the bug
#2890 issue is still affecting ListContracts in the neo.dll

This exception was originally thrown at this call stack:
    Neo.SmartContract.Manifest.ContractPermissionDescriptor.ContractPermissionDescriptor(System.ReadOnlySpan<byte>) in ContractPermissionDescriptor.cs
    Neo.SmartContract.Manifest.ContractManifest.Neo.SmartContract.IInteroperable.FromStackItem.AnonymousMethod__29_3(Neo.VM.Types.StackItem) in ContractManifest.cs
    System.Linq.Enumerable.SelectEnumerableIterator<TSource, TResult>.ToArray() in Select.SpeedOpt.cs
    Neo.SmartContract.Manifest.ContractManifest.Neo.SmartContract.IInteroperable.FromStackItem(Neo.VM.Types.StackItem) in ContractManifest.cs
    Neo.SmartContract.Helper.ToInteroperable<T>(Neo.VM.Types.StackItem) in Helper.cs
    Neo.SmartContract.ContractState.Neo.SmartContract.IInteroperable.FromStackItem(Neo.VM.Types.StackItem) in ContractState.cs
    Neo.SmartContract.StorageItem.GetInteroperable<T>() in StorageItem.cs
    Neo.SmartContract.Native.ContractManagement.ListContracts.AnonymousMethod__15_0((Neo.SmartContract.StorageKey Key, Neo.SmartContract.StorageItem Value)) in ContractManagement.cs
    System.Linq.Enumerable.SelectEnumerableIterator<TSource, TResult>.ToArray() in Select.SpeedOpt.cs
    System.Linq.Buffer<TElement>.Buffer(System.Collections.Generic.IEnumerable<TElement>) in Buffer.cs

To Reproduce
Steps to reproduce the behavior:

var contracts = NativeContract.ContractManagement.ListContracts(_neosystem.StoreView);
if (contracts.Any() == false) return NoContent();
var contractRequestList = contracts.OrderBy(o => o.Manifest.Name);
if (contractRequestList.Any() == false) return NoContent(); // crashes here when reading data

Expected behavior

internal ContractPermissionDescriptor(ReadOnlySpan<byte> span)
{
    switch (span.Length)
    {
        case UInt160.Length:
            Hash = new UInt160(span);
            break;
        case 33:
            Group = ECPoint.DecodePoint(span, ECCurve.Secp256r1);
            break;
        case 0:
            // wildcard logic
        default:
            throw new ArgumentException(null, nameof(span));
    }
}

Screenshots
image

Platform:

  • OS: Windows 10 Pro 22H2 19045.3324
  • Version neo.dll 3.6.0

(Optional) Additional context

System.ArgumentException: 'Value does not fall within the expected range. (Parameter 'span')'
@roman-khimov
Copy link
Contributor

Have you resynchronized your DB? 3.6.0 requires that.

@cschuchardt88
Copy link
Member Author

cschuchardt88 commented Sep 7, 2023

Yes but this time i get

System.InvalidCastException: 'Specified cast is not valid.'

This exception was originally thrown at this call stack:
    Neo.VM.Types.StackItem.GetSpan()
    Neo.SmartContract.Manifest.ContractManifest.Neo.SmartContract.IInteroperable.FromStackItem.AnonymousMethod__29_3(Neo.VM.Types.StackItem) in ContractManifest.cs
    System.Linq.Enumerable.SelectEnumerableIterator<TSource, TResult>.ToArray() in Select.SpeedOpt.cs
    Neo.SmartContract.Manifest.ContractManifest.Neo.SmartContract.IInteroperable.FromStackItem(Neo.VM.Types.StackItem) in ContractManifest.cs
    Neo.SmartContract.Helper.ToInteroperable<T>(Neo.VM.Types.StackItem) in Helper.cs
    Neo.SmartContract.ContractState.Neo.SmartContract.IInteroperable.FromStackItem(Neo.VM.Types.StackItem) in ContractState.cs
    Neo.SmartContract.StorageItem.GetInteroperable<T>() in StorageItem.cs
    Neo.SmartContract.Native.ContractManagement.ListContracts.AnonymousMethod__15_0((Neo.SmartContract.StorageKey Key, Neo.SmartContract.StorageItem Value)) in ContractManagement.cs
    System.Linq.Enumerable.SelectEnumerableIterator<TSource, TResult>.ToArray() in Select.SpeedOpt.cs
    System.Linq.Buffer<TElement>.Buffer(System.Collections.Generic.IEnumerable<TElement>) in Buffer.cs
    ...
    [Call Stack Truncated]

Array array => WildcardContainer<ContractPermissionDescriptor>.Create(array.Select(p => new ContractPermissionDescriptor(p.GetSpan())).ToArray()),

@shargon
Copy link
Member

shargon commented Nov 8, 2023

Using testnet data and last core code, I'm not receive any error parsing the contracts

image

Now testing with mainnet....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants