elucidsoft / dotnet-stellar-sdk

Stellar API SDK for .NET 6.x
Apache License 2.0
117 stars 55 forks source link

'to_muxed_id' overflow while reading operations #352

Closed avolkov-dev closed 2 years ago

avolkov-dev commented 2 years ago

sdk version 7.2.18 not able to read operations for block 349876 in horizon testnet. Piece of code:

using System.Threading.Tasks;
using stellar_dotnet_sdk;
using Xunit;

namespace Tests
{
    public class ToMutexIdFailure
    {
        [Fact]
        public async Task Run()
        {
            await new Server( "https://horizon-testnet.stellar.org/")
                .Operations.ForLedger(349876)
                .IncludeFailed(true)
                .Limit(100)
                .Execute();
        }
    }
}

fails with error:

Newtonsoft.Json.JsonSerializationException: Error converting value "18446744073709551615" to type 'System.Nullable`1[System.Int64]'. Path 'to_muxed_id...

Newtonsoft.Json.JsonSerializationException
Error converting value "18446744073709551615" to type 'System.Nullable`1[System.Int64]'. Path 'to_muxed_id', line 49, position 45.
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Populate(JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerProxy.PopulateInternal(JsonReader reader, Object target)
   at Newtonsoft.Json.JsonSerializer.Populate(JsonReader reader, Object target)
   at stellar_dotnet_sdk.responses.OperationDeserializer.ReadJson(JsonReader reader, Type objectType, OperationResponse existingValue, Boolean hasExistingValue, JsonSerializer serializer)
   at Newtonsoft.Json.JsonConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonConverter[] converters)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonConverter[] converters)
   at stellar_dotnet_sdk.responses.JsonSingleton.GetInstance[T](String content)
   at stellar_dotnet_sdk.requests.ResponseHandler`1.HandleResponse(HttpResponseMessage response)
   at stellar_dotnet_sdk.requests.RequestBuilder`1.Execute[TZ](Uri uri)
   at stellar_dotnet_sdk.requests.RequestBuilderExecutePageable`2.Execute()
   at Tests.ToMutexIdFailure.Run() in D:\Projects\Swisschain\Sirius.Integrations.Stellar\tests\Tests\ToMutexIdFailure.cs:line 12
   at Xunit.Sdk.TestInvoker`1.<>c__DisplayClass48_1.<<InvokeTestMethodAsync>b__1>d.MoveNext() in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\Runners\TestInvoker.cs:line 264
--- End of stack trace from previous location ---
   at Xunit.Sdk.ExecutionTimer.AggregateAsync(Func`1 asyncAction) in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\ExecutionTimer.cs:line 48
   at Xunit.Sdk.ExceptionAggregator.RunAsync(Func`1 code) in C:\Dev\xunit\xunit\src\xunit.core\Sdk\ExceptionAggregator.cs:line 90

System.OverflowException
Value was either too large or too small for an Int64.
   at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
   at System.Number.ParseInt64(ReadOnlySpan`1 value, NumberStyles styles, NumberFormatInfo info)
   at System.String.System.IConvertible.ToInt64(IFormatProvider provider)
   at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)

Suggested solution : use BigInteger instead of int64

elucidsoft commented 2 years ago

This is being looked into...Will have an update shortly

elucidsoft commented 2 years ago

Can you provide insight on why this id is null in testnet?

avolkov-dev commented 2 years ago

sorry, i don't get. What id are you referring to?

elucidsoft commented 2 years ago

oh sorry, the muxed_id is what I was referring to in the exception.

Kirbyrawr commented 2 years ago

Hi, sorry for the delay i was on a trip, i'm gonna check it!

Kirbyrawr commented 2 years ago

As always, very thankful for the detailed reports!

Kirbyrawr commented 2 years ago

Fixed, i will upload the PR today as soon as i check everything of muxed, thanks!

Kirbyrawr commented 2 years ago

imagen

avolkov-dev commented 2 years ago

@elucidsoft could you make a release, please? we are using nuget package