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

Stack overflow exception on storing struct with an enum value. #664

Open
divyang-desai opened this issue Aug 15, 2021 · 0 comments
Open

Comments

@divyang-desai
Copy link

Version: StratisFullNode-1.0.9.0 PoA with devmode=miner

Sample contract to generate the issue:

[Deploy]
public class SampleContract : SmartContract
{
    public SampleContract(ISmartContractState smartContractState)
    : base(smartContractState)
    {                
    }

    private void SetRequest(uint id, Request request) => State.SetStruct($"request:{id}", request);

    public Request GetRequest(uint id) => State.GetStruct<Request>($"request:{id}");

    public bool SampleRequest (uint id)
    {
        var request = new Request()
        {
             Id = id,
             RequestStatus = Status.Created
        };

        SetRequest(id, request);

        return true;
    }

    public struct Request
    {
        [Index]
        public uint Id;

        public Status RequestStatus;        
    }

    public enum Status
    {
        Created,
        Canceled
    }
}

You can reproduce the issue by executing the SampleRequest method.

Error:

image

If you change RequestStatus to int and cast while storing, it works fine.

@divyang-desai divyang-desai changed the title Stack Overflow exception on storing struct with an enum value Stack overflow exception on storing struct with an enum value. Aug 15, 2021
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

No branches or pull requests

1 participant