Skip to content

Commit 90d64a2

Browse files
Merge pull request #94 from make-software/casper-2.0.0
Merge Casper 2.0.0 branch into master
2 parents f9f4497 + 0a0f347 commit 90d64a2

File tree

179 files changed

+15427
-996
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+15427
-996
lines changed

.github/workflows/push-to-github-registry.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Setup .NET
1414
uses: actions/setup-dotnet@v1
1515
with:
16-
dotnet-version: 7.0.x
16+
dotnet-version: 8.0.x
1717
- name: Create nuget package
1818
run: dotnet pack --configuration Release -o out
1919
- name: Publish Nuget to GitHub registry

CHANGELOG.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,94 @@ All notable changes to this project will be documented in this file. The format
99
[comment]: <> (Fixed: any bug fixes)
1010
[comment]: <> (Security: in case of vulnerabilities)
1111

12+
## [3.0.0-beta3]
13+
14+
### Added
15+
16+
* The `TransactionBuilder` now accepts amount as `ulong` type for the `Payment()` method.
17+
* New `GlobalStateKey.FromValidatorKey()` to get the bid address key of a validator.
18+
* New `GetNodeVersion()` in the main client class as a convenient method to check node version.
19+
* New `GetValidatorBid()` method to recover the bid information of a validator.
20+
21+
### Changed
22+
23+
* `MessageKey` contains an `AddressableEntity` property instead of a `HashAddr` to represent the related contract entity.
24+
* `GetAuctionInfo()` now uses the new `state_get_auction_info_v2` RPC method in Casper 2.0.
25+
26+
### Fixed
27+
28+
* [#99](https://github.com/make-software/casper-net-sdk/issues/99) SSE Listener emits the same event 3 times when listening to EventType.All
29+
* Fixed the `TransactionV1.ValidateHashes()` method to properly verify the hashes.
30+
31+
## [3.0.0-beta2]
32+
33+
### Added
34+
35+
* Added `GetDelegatorReward` and `GetValidatorReward` methods to the RPC client. [PR#76](https://github.com/make-software/casper-net-sdk/pull/76) and [PR#80](https://github.com/make-software/casper-net-sdk/pull/80).
36+
* Added `GetStatePackage` method to the RPC client. [PR#82](https://github.com/make-software/casper-net-sdk/pull/82).
37+
* Added `ProtocolVersion` to Get Node Status RPC response. [PR#77](https://github.com/make-software/casper-net-sdk/pull/77).
38+
* Added a `TransactionBuilder` to build `TransactionV1` transactions for the different type of invocations ( to mint/auction system contracts, user stored contracts) and session deployments. [PR#79](https://github.com/make-software/casper-net-sdk/pull/79).
39+
40+
### Changed
41+
42+
* The `Transaction` type is now an abstraction for `TransactionV1` and `Deploy` transaction models. [PR#79](https://github.com/make-software/casper-net-sdk/pull/79).
43+
* Updated `TransactionV1` JSON and bytes serialization in alignment to `casper-node v2.0.0-rc5`. [PR-84](https://github.com/make-software/casper-net-sdk/pull/84) and [PR-85](https://github.com/make-software/casper-net-sdk/pull/85)
44+
* Updated `MessageKey` key type in alignment to `casper-node v2.0.0-rc5`. [PR-86](https://github.com/make-software/casper-net-sdk/pull/86)
45+
* `EntryPointPayment.SelfOnly` constant replaced with `EntryPointPayment.DirectInvocationOnly`.[PR#87](https://github.com/make-software/casper-net-sdk/pull/87).
46+
47+
### Fixed
48+
49+
* Fixed a multi-thread bug when using the RPCLoggingHandler in the RPC client class. [PR#81](https://github.com/make-software/casper-net-sdk/pull/81).
50+
* v3.0.0-beta1 did not parse correctly `Step` event emmitted by nodes in Casper v1.x. [PR#78](https://github.com/make-software/casper-net-sdk/pull/78).
51+
52+
## [3.0.0-beta1]
53+
54+
This version is compatible with Casper node v2.0.0-rc3 and Casper node v1.5.6.
55+
56+
### Added
57+
58+
* New `GetEntity()` method added to the RPC client.
59+
* New `QueryBalanceDetails()` method added to the RPC client.
60+
* New `PutTransaction()` and `GetTransaction()` methods added to the RPC client.
61+
* New `TransactionV1` class to model the new type of transactions in Condor.
62+
* New global state keys added to the SDK: `AddressableEntityKey`, `BalanceHoldKey`, `BidAddrKey`, `BlockGlobalAddrKey`, `ByteCodeKey`, `EntryPointKey`, `MessageKey`, `NamedKeyKey` and `PackageKey`.
63+
* New `AddressableEntity` class added. It may represent an account, a stored smart contract, or a system smart contract.
64+
* New properties in the `StoredValue` class that can be retrieved with `QueryGlobalState()` method: `BidKind`, `Unbonding`, `AddressableEntity`, `Package`, `ByteCode`, `MessageTopicSummary`, `Message`, `NamedKey`, `Reservation`, and `EntryPoint`.
65+
* New classes to represent data from the global state: `BidKind`, `UnbondingPurse`, `Package` and `ByteCode`.
66+
* New `Message` class to contain data for native events included in the `TransactionAccepted` event from the SSE channel.
67+
* Added `TransactionAccepted`, `TransactionProcessed`, and `TransactionExpired` events to the list of events emitted by a node through the SSE interface.
68+
69+
### Changed
70+
71+
* The `Block` class has changed to abstract the developer from the versioned block records returned from the network in Condor version. Refer to the migration guide for more information.
72+
* For blocks produced in Casper 2.0, the `Block` instance contains the previous switch block hash in the `LastSwitchBlockHash` property.
73+
* Ther `EraEnd` class has changed to abstract the developer from the versioned records returned from the network. More info in the migration guide.
74+
* The `Transfer` class contained in the response for a `GetBlockTransfers()` call or in a `ExecutionResult` object has changed to abstract from the versioned transfer records returned from the network. Refer to the migration guide for more information.
75+
* The input argument for the `QueryBalance()` method in the RPC client is any object from a class implementing the `IPurseIdentifier` interface. `PublicKey`, `AccountHashKey`, `URef`, and `AddressableEntity` classes implement this interface.
76+
* The type to refer to block heights is now `ulong` across all the SDK. In previous version there was a mix of `ulong` and `int`.
77+
* When using the `GetNodeStatus()` method with a Casper 2.0 node, the response contains the hash for the latest switch block in the `LatestSwitchBlockHash` property.
78+
* `GetDeploy()` response has changed and now contains a `ExecutionInfo`object when the deploy has been processed instead a list of `ExecutionResult` objects. The execution info itself contains block information and a result object.
79+
* Starting with this version of the SDK, only public keys are checksummed with the CEP-57 standard. The rest of the keys and hashes are not checksummed anymore.
80+
* In the `StoredValue` class, `Transfer` has been renamed to `LegacyTransfer`.
81+
* `DeployApproval` class has been renamed to `Approval` and is used for `Deploy` as well as for the new `TransactionV1` model.
82+
* `ActionThresholds` class has now new `UpgradeManagement` property.
83+
* The `EntryPoint` class has new entry point types and a new property `EntryPointPayment`. Both apply when working with Casper 2.0 only.
84+
* `Step` event from SSE contains a list of `Transform` objects instead of a `ExecutionEffect` instance.
85+
* `FinalitySignature` event contains `BlockHeight` and `ChainNameHash` value when connected to a Casper 2.0 node.
86+
* `DeployProcessed` event from SSE contains a `ExecutionResultV1` object instead of a `ExecutionResult` object.
87+
88+
### Deprecated
89+
90+
* `Proposer.isSystem` property is marked as Obsolete. Use `IsSystem` with capital `I` instead.
91+
92+
### Removed
93+
94+
* `GetAccountBalance()` method in the RPC client has been removed. Use `QueryBalance()` instead. `GetBalance()` method exists to use `state_get_balance` from the RPC interface if needed.
95+
96+
### Security
97+
98+
* BouncyCastle package updated to 2.4.0 version.
99+
12100
## [2.4.0]
13101

14102
### Changed
@@ -94,6 +182,9 @@ This new type permits to parse correctly the value `"00"` used for system blocks
94182
### Added
95183
* Initial release of Casper .NET SDK.
96184

185+
[3.0.0-beta3]: https://github.com/make-software/casper-net-sdk/releases/tag/v3.0.0-beta3
186+
[3.0.0-beta2]: https://github.com/make-software/casper-net-sdk/releases/tag/v3.0.0-beta2
187+
[3.0.0-beta1]: https://github.com/make-software/casper-net-sdk/releases/tag/v3.0.0-beta1
97188
[2.3.0]: https://github.com/make-software/casper-net-sdk/releases/tag/v2.3.0
98189
[2.2.0]: https://github.com/make-software/casper-net-sdk/releases/tag/v2.2.0
99190
[2.1.0]: https://github.com/make-software/casper-net-sdk/releases/tag/v2.1.0
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using NUnit.Framework;
2+
using Org.BouncyCastle.Utilities.Encoders;
3+
4+
namespace NetCasperTest
5+
{
6+
public static class AssertExtensions
7+
{
8+
public static void IsHash(string maybeHash)
9+
{
10+
try
11+
{
12+
Assert.AreEqual(32, Hex.Decode(maybeHash).Length);
13+
}
14+
catch
15+
{
16+
Assert.Fail($"Cannot decode a hash from '{maybeHash}'");
17+
}
18+
}
19+
20+
public static void IsValidHex(string maybeHex, uint bytesLength = 0)
21+
{
22+
try
23+
{
24+
var bytes = Hex.Decode(maybeHex);
25+
if(bytesLength > 0)
26+
Assert.AreEqual(bytesLength, bytes.Length);
27+
}
28+
catch
29+
{
30+
Assert.Fail($"Cannot decode hex bytes from '{maybeHex}'");
31+
}
32+
}
33+
}
34+
}

Casper.Network.SDK.Test/CEP57ChecksumTest.cs

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -24,59 +24,6 @@ public void CEP57LongByteArray()
2424
Assert.AreEqual(longHex.ToLower(), encodedHex);
2525
}
2626

27-
[Test]
28-
public void CEP57DecodeEncode()
29-
{
30-
int result;
31-
32-
var hash = "66B754c5E2981B41D41af39B88C8583bD08EF176eB1a81F56b8F395685805968";
33-
var bytes = CEP57Checksum.Decode(hash, out result);
34-
Assert.AreEqual(CEP57Checksum.ValidChecksum, result);
35-
36-
GlobalStateKey key = new HashKey(bytes);
37-
Assert.AreEqual($"hash-{hash}", key.ToString());
38-
39-
hash = "eA1D6C19ccAeb35Ae717065c250E0F7F6Dc64AC3c6494a797E0b33A23CA1f1b9";
40-
bytes = CEP57Checksum.Decode(hash, out result);
41-
Assert.AreEqual(CEP57Checksum.ValidChecksum, result);
42-
Assert.AreEqual(hash, CEP57Checksum.Encode(bytes));
43-
44-
key = new TransferKey(bytes);
45-
Assert.AreEqual($"transfer-{hash}", key.ToString());
46-
47-
hash = "98d945f5324F865243B7c02C0417AB6eaC361c5c56602FD42ced834a1Ba201B6";
48-
bytes = CEP57Checksum.Decode(hash, out result);
49-
Assert.AreEqual(CEP57Checksum.ValidChecksum, result);
50-
Assert.AreEqual(hash, CEP57Checksum.Encode(bytes));
51-
52-
key = new DeployInfoKey(bytes);
53-
Assert.AreEqual($"deploy-{hash}", key.ToString());
54-
55-
hash = "8cf5E4aCF51f54Eb59291599187838Dc3BC234089c46fc6cA8AD17e762aE4401";
56-
bytes = CEP57Checksum.Decode(hash, out result);
57-
Assert.AreEqual(CEP57Checksum.ValidChecksum, result);
58-
Assert.AreEqual(hash, CEP57Checksum.Encode(bytes));
59-
60-
key = new BalanceKey(bytes);
61-
Assert.AreEqual($"balance-{hash}", key.ToString());
62-
63-
hash = "010c3Fe81B7b862E50C77EF9A958a05BfA98444F26f96f23d37A13c96244cFB7";
64-
bytes = CEP57Checksum.Decode(hash, out result);
65-
Assert.AreEqual(CEP57Checksum.ValidChecksum, result);
66-
Assert.AreEqual(hash, CEP57Checksum.Encode(bytes));
67-
68-
key = new BidKey(bytes);
69-
Assert.AreEqual($"bid-{hash}", key.ToString());
70-
71-
hash = "98d945f5324F865243B7c02C0417AB6eaC361c5c56602FD42ced834a1Ba201B6";
72-
bytes = CEP57Checksum.Decode(hash, out result);
73-
Assert.AreEqual(CEP57Checksum.ValidChecksum, result);
74-
Assert.AreEqual(hash, CEP57Checksum.Encode(bytes));
75-
76-
key = new WithdrawKey(bytes);
77-
Assert.AreEqual($"withdraw-{hash}", key.ToString());
78-
}
79-
8027
[Test]
8128
public void CEP57HasChecksum()
8229
{

Casper.Network.SDK.Test/CLValueJsonDeserializerTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public void SerializeU512CLValue()
191191
var doc = System.Text.Json.JsonDocument.Parse(json);
192192
Assert.AreEqual(3, doc.RootElement.EnumerateObject().Count());
193193
Assert.AreEqual("U512", doc.RootElement.GetProperty("cl_type").GetString());
194-
Assert.AreEqual("05005550B405", doc.RootElement.GetProperty("bytes").GetString());
194+
Assert.AreEqual("05005550b405", doc.RootElement.GetProperty("bytes").GetString().ToLower());
195195
Assert.AreEqual("24500000000", doc.RootElement.GetProperty("parsed").GetString());
196196

197197
clValue = CLValue.U512(15000000000);
@@ -541,7 +541,7 @@ public void SerializeKeyCLValue()
541541
Assert.IsNotEmpty(json);
542542
Assert.IsTrue(json.Contains(@"""cl_type"":""Key"""));
543543
Assert.IsTrue(json.Contains(@"""bytes"":""08b192"));
544-
Assert.IsTrue(json.Contains(@"""parsed"":{""Withdraw"":""withdraw-B192"));
544+
Assert.IsTrue(json.Contains(@"""parsed"":{""Withdraw"":""withdraw-b192"));
545545

546546
gsKey = GlobalStateKey.FromString(
547547
"uref-e48935c79e96c490c01e1e8800de5ec5f4a857a57db0dcffed1e1e2b5d29b5e4-007");
@@ -550,9 +550,9 @@ public void SerializeKeyCLValue()
550550
Assert.IsNotEmpty(json);
551551
Assert.IsTrue(json.Contains(@"""cl_type"":""Key"""));
552552
Assert.IsTrue(
553-
json.Contains(@"""bytes"":""02e48935c79E96C490c01e1E8800dE5Ec5F4A857A57dB0DcFfED1e1E2b5d29b5E407"));
553+
json.Contains(@"""bytes"":""02e48935c79e96c490c01e1e8800de5ec5f4a857a57db0dcffed1e1e2b5d29b5e407"));
554554
Assert.IsTrue(json.Contains(
555-
@"""parsed"":{""URef"":""uref-E48935C79E96c490c01e1E8800de5Ec5F4A857A57db0dcffEd1E1E2B5D29b5E4-007"));
555+
@"""parsed"":{""URef"":""uref-e48935c79e96c490c01e1e8800de5ec5f4a857a57db0dcffed1e1e2b5d29b5e4-007"));
556556

557557
gsKey = GlobalStateKey.FromString("era-2685");
558558
clValue = CLValue.Key(gsKey);

Casper.Network.SDK.Test/Casper.Network.SDK.Test.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,7 @@
3232
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3333
</Content>
3434
</ItemGroup>
35+
<ItemGroup>
36+
</ItemGroup>
3537

3638
</Project>

Casper.Network.SDK.Test/DeployItemByteSerializerTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void StoredContractByHashSerialization()
4040
new StoredContractByHashDeployItem(hash.ToHexString(),
4141
"counter_inc");
4242

43-
Assert.AreEqual(CEP57Checksum.Encode(hash.RawBytes), storedContract.Hash);
43+
Assert.AreEqual(Hex.ToHexString(hash.RawBytes), storedContract.Hash);
4444
Assert.AreEqual("counter_inc", storedContract.EntryPoint);
4545
Assert.IsNotNull(storedContract.RuntimeArgs);
4646
Assert.AreEqual(0, storedContract.RuntimeArgs.Count);
@@ -71,7 +71,7 @@ public void StoredVersionedContractByHashSerialization()
7171
var storedContract =
7272
new StoredVersionedContractByHashDeployItem(hash.ToHexString(), 1, "counter_inc");
7373

74-
Assert.AreEqual(CEP57Checksum.Encode(hash.RawBytes), storedContract.Hash);
74+
Assert.AreEqual(Hex.ToHexString(hash.RawBytes), storedContract.Hash);
7575
Assert.AreEqual(1, storedContract.Version);
7676
Assert.AreEqual("counter_inc", storedContract.EntryPoint);
7777
Assert.IsNotNull(storedContract.RuntimeArgs);

Casper.Network.SDK.Test/DeployJsonSerializerTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class DeployJsonSerializer
1212
private string deploy1 = TestContext.CurrentContext.TestDirectory + "/TestData/transfer-deploy.json";
1313
private string signer1 = "017b8058863Aad49c7b89c77019ceF3a4D863BDf1c0c61499776F94b18465810F7";
1414
private string signature1 =
15-
"012a0c5896aB9D6Cf029268Cf454Ba9D42bcD40Bd909C984890F326739EeF13201d1d2a9a95938B2a966F2E650D1bDd80931F0374e3A92403e025B806Aa1065109";
15+
"012a0c5896ab9d6cf029268cf454ba9d42bcd40bd909c984890f326739eef13201d1d2a9a95938b2a966f2e650d1bdd80931f0374e3a92403e025b806aa1065109";
1616

1717
[Test]
1818
public void LoadDeployFromFileTest()

0 commit comments

Comments
 (0)