Coder Social home page Coder Social logo

casper-net-sdk's People

Contributors

andrzej-casper avatar davidatwhiletrue avatar dependabot[bot] avatar mrkara avatar msanlisavas avatar mssteuer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

casper-net-sdk's Issues

Can't serialize results to JSON

What happened?
Can't serialize results to JSON.

Since switch blocks are more than 10MB per era I wanted to dump a few switch blocks as JSON to process them offline so I don't need to request them again and again from the network. Seems like this isn't supported?

What did you expect to happen?
That serialization just works. Indeed I saw that quite a few Write methods aren't implemented yet:
BidsListConverter: throw new NotImplementedException("Write method for Bid not yet implemented");
Delegator: throw new NotImplementedException("Write method for Delegator not yet implemented");
EntryPoint: throw new NotImplementedException("Write method for EntryPointAccess not yet implemented");
SeigniorageAllocation: throw new NotImplementedException("Write method for SeigniorageAllocation not yet implemented");
StoredValue: throw new NotImplementedException("Write method for StoredValue not yet implemented");
Transform: throw new NotImplementedException("Write method for Transform not yet implemented");

Are you willing to submit a pull request to fix this bug?
Sorry, no.

Not a bug, a missing feature: Account Info Standard Support

What happened?
It looks like the Account Info Standard is not directly supported by the .Net SDK.

What did you expect to happen?
Support of the Account Info Standard in the .Net SDK to make it easier to retrieve that info instead of doing this manually.

Two possible solutions:

  1. A quick and easy implementation would be to provide the URL to the JSON file only.
  2. (Preferred) A much better but ideal solution would be a fully type-safe wrapper around the JSON file.

For the contract hashes:
I think it would be OK to store them for the MainNet and TestNet since they shouldn't change.

But for internal test networks I think it also has to be configurable or be passed as an optional parameter somehow.

Are you willing to submit a pull request to fix this bug?
Maybe, I'll have to get some spare time to dig deeper here how a potential implementation could look like.
-> Better don't count on it and I think you have all the skills and knowledge at hand already so it should be pretty straightforward :-)

Generate Secp256k1

What happened?

A Secp256k1 account is created and funded via the faucet account
A transfer is deployed with the new account as the approver
The deploy result is returned and the approval account is analysed
The signer contains the algorithm type ED25519

What did you expect to happen?

The signer contains the algorithm type Secp256k1

Thanks

Carl Norburn

Install error

room@Rooms-MacBook-Pro caspertest1 % dotnet add CasperTest1 package Casper.Network.SDK --version 0.9.4-beta
Determining projects to restore...
Writing /var/folders/kb/v9pqm1312tv73dv25dxvcw240000gn/T/tmpP2WN6V.tmp
info : Adding PackageReference for package 'Casper.Network.SDK' into project '/Users/room/Projects/CasperTest1/CasperTest1/CasperTest1.csproj'.
info : Restoring packages for /Users/room/Projects/CasperTest1/CasperTest1/CasperTest1.csproj...
info : GET https://api.nuget.org/v3-flatcontainer/casper.network.sdk/index.json
info : NotFound https://api.nuget.org/v3-flatcontainer/casper.network.sdk/index.json 885ms
error: NU1101: Unable to find package Casper.Network.SDK. No packages exist with this id in source(s): nuget.org
error: Package 'Casper.Network.SDK' is incompatible with 'all' frameworks in project '/Users/room/Projects/CasperTest1/CasperTest1/CasperTest1.csproj'.

Integration test are failing

What happened?

Integration tests are failing for me:

image

@davidatwhiletrue could you trigger "Integration testing" workflow in order to verify this?

Reproduction steps

  1. Build the latest v2.0.0:
$ git describe
v2.0.0
$ dotnet build
MSBuild version 17.4.8+6918b863a for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
  Casper.Network.SDK -> /home/andrew/casper-net-sdk/Casper.Network.SDK/bin/Debug/net7.0/Casper.Network.SDK.dll
  Casper.Network.SDK.Test -> /home/andrew/casper-net-sdk/Casper.Network.SDK.Test/bin/Debug/net7.0/Casper.Network.SDK.Test.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.61
  1. Run local network:
$ docker run --rm -it --name casper-nctl -d -p 11101:11101 -p 14101:14101 -p 18101:18101 -p 25101:25101 -e DEPLOY_DELAY="5sec" makesoftware/casper-nctl:latest
$ while [ "`docker inspect -f {{.State.Health.Status}} casper-nctl`" != "healthy" ]; do sleep 1; done
  1. Configure PEM keys:
$ docker exec -t casper-nctl cat /home/casper/casper-node/utils/nctl/assets/net-1/faucet/secret_key.pem > Casper.Network.SDK.Test/TestData/faucetact.pem
  1. Run tests:
$ dotnet test --no-build --verbosity normal --settings Casper.Network.SDK.Test/test.runsettings --filter="TestCategory=NCTL"
...
Failed!  - Failed:    26, Passed:    15, Skipped:     0, Total:    41, Duration: 614 ms
...

26 failed tests ๐Ÿ˜จ

Let us try again, this time using NCTL launched with -e PREDEFINED_ACCOUNTS="true":

Build started 8/30/2023 12:09:02PM.
     1>Project "/home/andrew/casper-net-sdk/Casper.Network.SDK.sln" on node 1 (VSTest target(s)).
     1>ValidateSolutionConfiguration:
         Building solution configuration "Debug|Any CPU".
Test run for /home/andrew/casper-net-sdk/Casper.Network.SDK.Test/bin/Debug/net7.0/Casper.Network.SDK.Test.dll (.NETCoreApp,Version=v7.0)
Microsoft (R) Test Execution Command Line Tool Version 17.4.1+79d56b02b69a582cd90428878a5e9411ab7538f5 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
  Failed GetEraSummaryTest [25 ms]
  Error Message:
     Expected: True
  But was:  False

  Stack Trace:
     at NetCasperTest.NctlGetXTest.GetEraSummaryTest() in /home/andrew/casper-net-sdk/Casper.Network.SDK.Test/NctlGetXTest.cs:line 225
   at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.BlockUntilCompleted()
   at NUnit.Framework.Internal.MessagePumpStrategy.NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaiter)
   at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
   at NUnit.Framework.Internal.Commands.TestMethodCommand.RunTestMethod(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.TestMethodCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeAndAfterTestCommand.<>c__DisplayClass1_0.<Execute>b__0()
   at NUnit.Framework.Internal.Commands.DelegatingTestCommand.RunTestMethodInThreadAbortSafeZone(TestExecutionContext context, Action action)

1)    at NetCasperTest.NctlGetXTest.GetEraSummaryTest() in /home/andrew/casper-net-sdk/Casper.Network.SDK.Test/NctlGetXTest.cs:line 225



Failed!  - Failed:     1, Passed:    40, Skipped:     0, Total:    41, Duration: 1 m 40 s - Casper.Network.SDK.Test.dll (net7.0)
     1>Done Building Project "/home/andrew/casper-net-sdk/Casper.Network.SDK.sln" (VSTest target(s)) -- FAILED.

Build FAILED.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:01:42.54

Only 1 failed test! This is much better, but still needs to be fixed.

DeployTemplates ContractDeploy can't add NamedArgs

What happened?

Tried to add user defined NamedArgs to a ContractDeploy
Could not see a way to do this:

`
var paymentArgs = new List{

        new ("amount", CLValue.U512(payment)), 

        new ("token_decimals", CLValue.U8(tokenDecimals)), 

        new ("token_name", CLValue.String(tokenName)),

        new ("token_symbol", CLValue.String(tokenSymbol)), 

        new ("token_total_supply", CLValue.U256(tokenTotalSupply))

`

What did you expect to happen?

The above list of NamedArgs can be added to the ContractDeploy

Thanks

Carl Norburn

Failure to deserialize the System proposed switch block

Try to deserialize the "System proposed switch block" -> the .Net SDK fails because the Proposer is normally a PublicKey but now it is "00" which is invalid.

Reported by "X Y" from the community. He is willing to provide more info if needed.

Standard Tests: CLType Key

Hi

A CLType of Key is added as a NamedArg to RunTimeArgs in a Session Deploy
Before the Deploy the Key has the correct bytes
After the Deploy the NamedArg with the Key value returns the bytes with the last two characters missing:

Expected string length 79 but was 77. Strings differ at index 77. Expected: "...3127D815871618B6F639CF4A4A2DF4EDEACB8A0DF662822707A5E570C9D32" But was: "...3127D815871618B6F639CF4A4A2DF4EDEACB8A0DF662822707A5E570C9D" -------------------------------------------------------------------------^

This is being tested here:

I'm creating the Key here:

Happy to accept I'm doing it wrong!

Many thanks

Telegram: @cnorburn

XML Comments

What happened?
I see that xml comments are not present in the nuget.org.
What did you expect to happen?
Even though the xml comments are present they are pushed to nuget.org without them.
Are you willing to submit a pull request to fix this bug?
No. I think by default it goes to nuget without xml comments. Enabling and pushing again should work.

Wrong parameter name and documentation for GetDictionaryItem method

GetDictionaryItem() method first parameter is dictionaryItem and it should be dictionaryKey.

XML Documentation says:

    /// <summary>
    /// Lookup a dictionary item from its dictionary item key.
    /// </summary>
    /// <param name="dictionaryItem">The dictionary item key to retrieve.</param>
    /// <param name="stateRootHash">Hash of the state root.</param>

and it should be:

    /// <summary>
    /// Lookup a dictionary item from its dictionary key.
    /// </summary>
    /// <param name="dictionaryeyK">The dictionary key to retrieve.</param>
    /// <param name="stateRootHash">Hash of the state root.</param>

Introduce changes from Casper Node v1.5.5

Changes from casper-node 1.5.5 that are relevant for the SDK:

  • We have made the state identifier parameter in the query_global_state JSON RPC as optional in v1.5.5. When no state identifier is provided the highest block is then used as an identifier, here.
  • The state_get_account_info RPC method can now handle an account identifier as a public key or account hash, here.

GetDeploy(DeployHash) info_get_deploy_result

What happened?

A StandardTransfer is executed
A block added event with the deploy hash is waited for
The deploy result is then retrieved
The session object of the deploy result is then analysed

The target argument type is ByteArray

What did you expect to happen?

The expected argument type is expected to be of type PublicKey

I can see that it is being stored as an AccountHash, which in turn is being converted to a CLType of ByteArray
It needs to be stored as a PublicKey to bring in line with the other SDK's

Thanks

Carl Norburn

PublicKey is still using checksummed addresses

What happened?
PublicKey - more specifically ToAccountHex() which is also used by ToString() - is using checksummed addresses which were deactivated and postponed to another future version (AFAIK).

Using checksummed addresses causes issues on e. g. cspr.live -> Wallet -> Transfer CSPR -> Casper Signer will error out if using checksummed addresses. casperholders.io has the same issue, too.

I've also used Wireshark to check if the checksummed addresses are returned by RPC calls and saw that RPC responses contain lower-cased addresses which I think is correct -> the Casper .NET SDK is the reason.

Maybe this issue needs to be raised to the Casper Signer and/or cspr.live, too to handle checksummed addresses more carefully and simply lower-case public keys.

Sample code to reproduce:

PublicKey publicKey = PublicKey.FromHexString("0154a4d3a719b76861e56dcd4b5a6ef43814ef3c512346bd6af1d07dc69401c1e9");
Trace.WriteLine(publicKey);

Output (mixed-case):

0154a4d3A719b76861E56DcD4b5A6Ef43814eF3C512346bD6af1D07DC69401C1E9

What did you expect to happen?
Expected output (lower-case):

0154a4d3a719b76861e56dcd4b5a6ef43814ef3c512346bd6af1d07dc69401c1e9

All public keys should be lower case and not using checksummed addresses to avoid confusion and issues as long as it is not officially enabled again.

Are you willing to submit a pull request to fix this bug?
No since I think I would miss something anyway and I'm not sure if this is considered as an issue or not.

An easy and probably hacky fix without running tests etc. could look like this:

Change line 112 in CEP57Checksum.cs:

// Before
return sb.ToString();

// After
return sb.ToString().ToLower();

I didn't run any tests and it is very likely that this breaks something so be warned.

Unwrapping complex CLTypes fails

The following CLTypes can be successfully built and deployed
They can not be unwrapped from the deploy result to be verified:

  • Tuple1
  • Tuple2
  • Tuple3
  • List
  • Map

Thanks

Carl Norburn

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.