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 issue 2 #355

Closed avolkov-dev closed 2 years ago

avolkov-dev commented 2 years ago

After release 7.2.25 the issue, described here, still remain, but on different block (450391) 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/")
                .Effects.ForLedger(450391)
                .Limit(100)
                .Execute();
        }
    }
}

fails with error:

Newtonsoft.Json.JsonSerializationException
Error converting value "12345678901234567899" to type 'System.Nullable`1[System.Int64]'. Path 'account_muxed_id', line 308, position 50.
   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.EffectDeserializer.ReadJson(JsonReader reader, Type objectType, EffectResponse 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 Stellar.Domain.BlocksReader.LoadAllEffectsForLedger(Int64 blockNumber)

This is weird, cause looks like according to docs it should fit int64.

Probably we should use BigInteger here?

Kirbyrawr commented 2 years ago

Hi, will take a look soon, most likely i will end up using string instead of any numeric type.

elucidsoft commented 2 years ago

This should most likely be a UInt64

Kirbyrawr commented 2 years ago

Done, sorry for the delay, basically the EffectResponse was still using long? instead of ulong? https://github.com/elucidsoft/dotnet-stellar-sdk/pull/356