From 0021d2fe5678934595140bd180a395681ec1b5ab Mon Sep 17 00:00:00 2001 From: meywood <105049338+meywood@users.noreply.github.com> Date: Tue, 11 Jun 2024 12:57:31 +0100 Subject: [PATCH 1/2] issues/282 - EraEndV2 --- .../com/casper/sdk/model/era/EraEndV2.java | 3 + .../casper/sdk/model/era/EraEndV2Test.java | 61 +++++++++++++++++++ .../era-info-samples/era_end_v2.json | 57 +++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 src/test/java/com/casper/sdk/model/era/EraEndV2Test.java create mode 100644 src/test/resources/era-info-samples/era_end_v2.json diff --git a/src/main/java/com/casper/sdk/model/era/EraEndV2.java b/src/main/java/com/casper/sdk/model/era/EraEndV2.java index 8f031318c..06588d29b 100644 --- a/src/main/java/com/casper/sdk/model/era/EraEndV2.java +++ b/src/main/java/com/casper/sdk/model/era/EraEndV2.java @@ -17,6 +17,8 @@ import java.util.Map; /** + * Version 2 of the era end data. + * * @author ian@meywood.com */ @AllArgsConstructor @@ -26,6 +28,7 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class EraEndV2 { + @JsonProperty("equivocators") private List equivocators; @JsonProperty("inactive_validators") private List inactiveValidators; diff --git a/src/test/java/com/casper/sdk/model/era/EraEndV2Test.java b/src/test/java/com/casper/sdk/model/era/EraEndV2Test.java new file mode 100644 index 000000000..5fc47c407 --- /dev/null +++ b/src/test/java/com/casper/sdk/model/era/EraEndV2Test.java @@ -0,0 +1,61 @@ +package com.casper.sdk.model.era; + +import com.casper.sdk.model.key.PublicKey; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.io.InputStream; +import java.math.BigInteger; +import java.security.NoSuchAlgorithmException; +import java.util.Objects; + +import static org.hamcrest.CoreMatchers.hasItems; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; + +/** + * Unit tests for {@link EraEndV2}. + * + * @author ian@meywood.com + */ +class EraEndV2Test { + + @Test + void parseEraEndV2() throws IOException, NoSuchAlgorithmException { + + final InputStream jsonIn = Objects.requireNonNull(getClass().getResource("/era-info-samples/era_end_v2.json")).openStream(); + + //noinspection VulnerableCodeUsages + final EraEndV2 eraEndV2 = new ObjectMapper().readValue(jsonIn, EraEndV2.class); + + assertThat(eraEndV2, is(notNullValue())); + + assertThat(eraEndV2.getEquivocators().size(), is(3)); + assertThat(eraEndV2.getEquivocators().get(0), is(PublicKey.fromTaggedHexString("01385e7e800dfcbf0abf1454d8e5300a09a6a42d7ca6d15bf9f45f932f2696bc0d"))); + assertThat(eraEndV2.getEquivocators().get(2), is(PublicKey.fromTaggedHexString("01ca84d8c6ea00653473da0f46642f49e8465c82aa2ff281100e2002a9d70f51d7"))); + + assertThat(eraEndV2.getInactiveValidators().size(), is(3)); + assertThat(eraEndV2.getInactiveValidators().get(1), is(PublicKey.fromTaggedHexString("01aed5e394a3e59b77ca6af6c97d584e0aa8d4ee40c4e51b27b635ec255f9ce1bd"))); + assertThat(eraEndV2.getInactiveValidators().get(2), is(PublicKey.fromTaggedHexString("01e71a498829ab4247d2d48022d95e23374c2138b184ebb1bc0bc4a45c5b24f9d5"))); + + assertThat(eraEndV2.getNextEraValidatorWeights().size(), is(5)); + assertThat(eraEndV2.getNextEraValidatorWeights().get(0).getValidator(), is(PublicKey.fromTaggedHexString("010b277da84a12c8814d5723eeb57123ff287f22466fd13faca1bb1fae57d2679b"))); + assertThat(eraEndV2.getNextEraValidatorWeights().get(0).getWeight(), is(new BigInteger("11823890605832274469"))); + assertThat(eraEndV2.getNextEraValidatorWeights().get(4).getValidator(), is(PublicKey.fromTaggedHexString("01f6e6e82759da039d479900ad1b930320082d1fc00aea6f5e5f7289c7a6c90536"))); + assertThat(eraEndV2.getNextEraValidatorWeights().get(4).getWeight(), is(new BigInteger("11990568590760997935"))); + + assertThat(eraEndV2.getRewards().size(), is(5)); + assertThat( + eraEndV2.getRewards().get(PublicKey.fromTaggedHexString("010b277da84a12c8814d5723eeb57123ff287f22466fd13faca1bb1fae57d2679b")), + hasItems(new BigInteger("4026058477024681"), new BigInteger("402627925137076")) + ); + assertThat( + eraEndV2.getRewards().get(PublicKey.fromTaggedHexString("01f6e6e82759da039d479900ad1b930320082d1fc00aea6f5e5f7289c7a6c90536")), + hasItems(new BigInteger("13081818953982388"), new BigInteger("408309291908807")) + ); + + assertThat(eraEndV2.getNextEraGasPrice(), is(2)); + } +} diff --git a/src/test/resources/era-info-samples/era_end_v2.json b/src/test/resources/era-info-samples/era_end_v2.json new file mode 100644 index 000000000..c0910a40d --- /dev/null +++ b/src/test/resources/era-info-samples/era_end_v2.json @@ -0,0 +1,57 @@ +{ + "equivocators": [ + "01385e7e800dfcbf0abf1454d8e5300a09a6a42d7ca6d15bf9f45f932f2696bc0d", + "0146ca58f053115bf23b096aca22174198ccb54fdeee9657f23b49df111239308e", + "01ca84d8c6ea00653473da0f46642f49e8465c82aa2ff281100e2002a9d70f51d7" + ], + "inactive_validators": [ + "016e1ed42072c14db735e77581db038e99bd5915aee0eb389e7bf36aa75084dded", + "01aed5e394a3e59b77ca6af6c97d584e0aa8d4ee40c4e51b27b635ec255f9ce1bd", + "01e71a498829ab4247d2d48022d95e23374c2138b184ebb1bc0bc4a45c5b24f9d5" + ], + "next_era_validator_weights": [ + { + "validator": "010b277da84a12c8814d5723eeb57123ff287f22466fd13faca1bb1fae57d2679b", + "weight": "11823890605832274469" + }, + { + "validator": "011c275ac5ab55ecb5c2a9ee25f62a5a6993d6782396f22e09f76b5b5bb73fd31d", + "weight": "11493949855380345241" + }, + { + "validator": "013b129419bde15abad56f43061031ea09652224c8161f61b32c17fcbccfafc47c", + "weight": "11748004807318658120" + }, + { + "validator": "01a65a3672126a5da4ac3be39f437c021e6e84e0da89b16c3a9cf2c9bf782b2dab", + "weight": "11683586140707787858" + }, + { + "validator": "01f6e6e82759da039d479900ad1b930320082d1fc00aea6f5e5f7289c7a6c90536", + "weight": "11990568590760997935" + } + ], + "rewards": { + "010b277da84a12c8814d5723eeb57123ff287f22466fd13faca1bb1fae57d2679b": [ + "4026058477024681", + "402627925137076" + ], + "011c275ac5ab55ecb5c2a9ee25f62a5a6993d6782396f22e09f76b5b5bb73fd31d": [ + "9913655386582888", + "391483351804192" + ], + "013b129419bde15abad56f43061031ea09652224c8161f61b32c17fcbccfafc47c": [ + "15500205924303788", + "900041009911612" + ], + "01a65a3672126a5da4ac3be39f437c021e6e84e0da89b16c3a9cf2c9bf782b2dab": [ + "9978261258106387", + "397538421238317" + ], + "01f6e6e82759da039d479900ad1b930320082d1fc00aea6f5e5f7289c7a6c90536": [ + "13081818953982388", + "408309291908807" + ] + }, + "next_era_gas_price": 2 +} From 76286506073e6a18a7124418d7669fe81d50834a Mon Sep 17 00:00:00 2001 From: meywood <105049338+meywood@users.noreply.github.com> Date: Tue, 11 Jun 2024 14:19:12 +0100 Subject: [PATCH 2/2] issues/279 - BlockV1 --- .../com/casper/sdk/model/block/BlockBody.java | 5 +- .../casper/sdk/model/block/BlockBodyV2.java | 3 + .../com/casper/sdk/model/block/BlockV1.java | 6 - .../com/casper/sdk/service/CasperService.java | 9 +- .../sdk/model/block/JsonBlockDataTest.java | 5 +- .../sdk/service/CasperServiceTests.java | 28 ++-- .../sdk/service/CasperServiceTestsNctl.java | 14 +- .../block-samples/block-end-era.json | 130 ++++++++-------- .../block-samples/chain_get_block.json | 146 +++++++++--------- 9 files changed, 173 insertions(+), 173 deletions(-) diff --git a/src/main/java/com/casper/sdk/model/block/BlockBody.java b/src/main/java/com/casper/sdk/model/block/BlockBody.java index 257663071..78a4ee607 100644 --- a/src/main/java/com/casper/sdk/model/block/BlockBody.java +++ b/src/main/java/com/casper/sdk/model/block/BlockBody.java @@ -1,6 +1,5 @@ package com.casper.sdk.model.block; -import com.casper.sdk.model.common.Digest; import com.casper.sdk.model.key.PublicKey; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Getter; @@ -19,8 +18,6 @@ public abstract class BlockBody { @JsonProperty("proposer") private PublicKey proposer; - /** The body's hash. */ - @JsonProperty("hash") - private Digest hash; + } diff --git a/src/main/java/com/casper/sdk/model/block/BlockBodyV2.java b/src/main/java/com/casper/sdk/model/block/BlockBodyV2.java index d7e7f0646..f30787fd8 100644 --- a/src/main/java/com/casper/sdk/model/block/BlockBodyV2.java +++ b/src/main/java/com/casper/sdk/model/block/BlockBodyV2.java @@ -19,6 +19,9 @@ @AllArgsConstructor @NoArgsConstructor public class BlockBodyV2 extends BlockBody { + /** The body's hash. */ + @JsonProperty("hash") + private Digest hash; /** List of Hex-encoded hash digest */ @JsonProperty("deploy_hashes") diff --git a/src/main/java/com/casper/sdk/model/block/BlockV1.java b/src/main/java/com/casper/sdk/model/block/BlockV1.java index e93ef1f93..7cf07481d 100644 --- a/src/main/java/com/casper/sdk/model/block/BlockV1.java +++ b/src/main/java/com/casper/sdk/model/block/BlockV1.java @@ -3,8 +3,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; import lombok.*; -import java.util.List; - /** * A JSON-friendly representation of `Block` * @@ -27,8 +25,4 @@ public class BlockV1 extends Block { /** {@link BlockBodyV1} */ @JsonProperty("body") private BlockBodyV1 body; - - /** List of {@link JsonProof} */ - @JsonProperty("proofs") - private List proofs; } diff --git a/src/main/java/com/casper/sdk/service/CasperService.java b/src/main/java/com/casper/sdk/service/CasperService.java index 0d6ca0c7d..81b3c2ec0 100644 --- a/src/main/java/com/casper/sdk/service/CasperService.java +++ b/src/main/java/com/casper/sdk/service/CasperService.java @@ -10,7 +10,6 @@ import com.casper.sdk.model.balance.GetBalanceData; import com.casper.sdk.model.balance.QueryBalanceData; import com.casper.sdk.model.block.ChainGetBlockResponse; -import com.casper.sdk.model.block.JsonBlockData; import com.casper.sdk.model.deploy.Deploy; import com.casper.sdk.model.deploy.DeployData; import com.casper.sdk.model.deploy.DeployResult; @@ -89,11 +88,7 @@ static CasperService usingPeer(String ip, int port) throws MalformedURLException * @return Object holding the api version and block */ @JsonRpcMethod("chain_get_block") - JsonBlockData getBlock(); - - @JsonRpcMethod("chain_get_block") - ChainGetBlockResponse getBlockV2(); - + ChainGetBlockResponse getBlock(); /** * Retrieve block info by its {@link BlockIdentifier} @@ -102,7 +97,7 @@ static CasperService usingPeer(String ip, int port) throws MalformedURLException * @return Object holding the api version and block */ @JsonRpcMethod("chain_get_block") - JsonBlockData getBlock(@JsonRpcParam("block_identifier") BlockIdentifier blockIdentifier); + ChainGetBlockResponse getBlock(@JsonRpcParam("block_identifier") BlockIdentifier blockIdentifier); /** * Retrieve last block's transfers diff --git a/src/test/java/com/casper/sdk/model/block/JsonBlockDataTest.java b/src/test/java/com/casper/sdk/model/block/JsonBlockDataTest.java index 3bee8db37..8dd4405d3 100644 --- a/src/test/java/com/casper/sdk/model/block/JsonBlockDataTest.java +++ b/src/test/java/com/casper/sdk/model/block/JsonBlockDataTest.java @@ -32,9 +32,10 @@ void validateJsonBlock_EraEndBlock() throws IOException, JSONException { LOGGER.debug("Original JSON: {}", inputJson); - final JsonBlockData block = OBJECT_MAPPER.readValue(inputJson, JsonBlockData.class); + //noinspection VulnerableCodeUsages + final ChainGetBlockResponse block = OBJECT_MAPPER.readValue(inputJson, ChainGetBlockResponse.class); - assertNotNull(block.getBlock()); + assertNotNull(block.getBlockWithSignatures().getBlock()); final String expectedJson = getPrettyJson(block); diff --git a/src/test/java/com/casper/sdk/service/CasperServiceTests.java b/src/test/java/com/casper/sdk/service/CasperServiceTests.java index 2ea2fa709..68ec7e7ed 100644 --- a/src/test/java/com/casper/sdk/service/CasperServiceTests.java +++ b/src/test/java/com/casper/sdk/service/CasperServiceTests.java @@ -89,16 +89,16 @@ void testIfBlockReturnedMatchesRequestedByHash() { .withBody("$.params.block_identifier.Height", "2346915") .thenDispatch(getClass().getResource("/block-samples/chain_get_block.json")); - final JsonBlockData resultByHeight = casperServiceMock.getBlock(new HeightBlockIdentifier(2346915)); - final String hash = resultByHeight.getBlock().getHash().toString(); + final ChainGetBlockResponse resultByHeight = casperServiceMock.getBlock(new HeightBlockIdentifier(2346915)); + final String hash = resultByHeight.getBlockWithSignatures().getBlock().getHash().toString(); when.clear() .withMethod("chain_get_block") .withBody("$.params.block_identifier.Hash", hash) .thenDispatch(getClass().getResource("/block-samples/chain_get_block.json")); - final JsonBlockData resultByHash = casperServiceMock.getBlock(new HashBlockIdentifier(hash)); - assertEquals(resultByHash.getBlock().getHash().toString(), hash); + final ChainGetBlockResponse resultByHash = casperServiceMock.getBlock(new HashBlockIdentifier(hash)); + assertEquals(resultByHash.getBlockWithSignatures().getBlock().getHash().toString(), hash); } /** @@ -112,8 +112,8 @@ void testFirstBlocksPublicKeySerialization() { .withBody("$.params.block_identifier.Height", "23469150") .thenDispatch(getClass().getResource("/block-samples/chain_get_block.json")); - final JsonBlockData result = casperServiceMock.getBlock(new HeightBlockIdentifier(23469150)); - final PublicKey key = result.getBlock().getBody().getProposer(); + final ChainGetBlockResponse result = casperServiceMock.getBlock(new HeightBlockIdentifier(23469150)); + final PublicKey key = result.getBlockWithSignatures().getBlock().getBody().getProposer(); assertEquals(AlgorithmTag.ED25519, key.getTag()); assertEquals("01753af321afc6906fcd9c897e5328f66190b5842671f16b022b69f2ddb7619c32", key.getAlgoTaggedHex()); @@ -142,8 +142,9 @@ void retrieveLastBlock() { .withMethod("chain_get_block") .thenDispatch(getClass().getResource("/block-samples/chain_get_block.json")); - final JsonBlockData blockData = casperServiceMock.getBlock(); + final ChainGetBlockResponse blockData = casperServiceMock.getBlock(); assertNotNull(blockData); + assertThat(blockData.getBlockWithSignatures().getBlock().getHash(), is(new Digest("709a31cbaff23da43995e78d2209e7f5980905cf70ef850f6744b8d3cec9af13"))); } @Test @@ -154,10 +155,11 @@ void getBlockByHash() { .withBody("$.params.block_identifier.Hash", "709a31cbaff23da43995e78d2209e7f5980905cf70ef850f6744b8d3cec9af13") .thenDispatch(getClass().getResource("/block-samples/chain_get_block.json")); - final JsonBlockData blockData = casperServiceMock.getBlock(new HashBlockIdentifier("709a31cbaff23da43995e78d2209e7f5980905cf70ef850f6744b8d3cec9af13")); + final ChainGetBlockResponse blockData = casperServiceMock.getBlock(new HashBlockIdentifier("709a31cbaff23da43995e78d2209e7f5980905cf70ef850f6744b8d3cec9af13")); assertNotNull(blockData); - final BlockV1 block = blockData.getBlock(); + final BlockV1 block = blockData.getBlockWithSignatures().getBlock(); + assertEquals("ee3da162c775f921e836ec6d41dedcb006bb972224d1058738e9413dea61fd5e", block.getHeader().getParentHash().toString()); assertEquals(2346915, block.getHeader().getHeight()); } @@ -170,9 +172,9 @@ void getBlockByHeight() { .withBody("$.params.block_identifier.Height", "2346915") .thenDispatch(getClass().getResource("/block-samples/chain_get_block.json")); - JsonBlockData blockData = casperServiceMock.getBlock(new HeightBlockIdentifier(2346915)); + ChainGetBlockResponse blockData = casperServiceMock.getBlock(new HeightBlockIdentifier(2346915)); assertNotNull(blockData); - BlockV1 block = blockData.getBlock(); + BlockV1 block = blockData.getBlockWithSignatures().getBlock(); assertEquals("ee3da162c775f921e836ec6d41dedcb006bb972224d1058738e9413dea61fd5e", block.getHeader().getParentHash().toString()); assertEquals("709a31cbaff23da43995e78d2209e7f5980905cf70ef850f6744b8d3cec9af13", block.getHash().toString()); } @@ -510,7 +512,7 @@ void chainGetBlockV2() { //.withBody("$.params.deploy_hash", "abc") .thenDispatch(getClass().getResource("/block-samples/chain_get_block_v2.json")); - final ChainGetBlockResponse blockWithSignatures = casperServiceMock.getBlockV2(); + final ChainGetBlockResponse blockWithSignatures = casperServiceMock.getBlock(); assertThat(blockWithSignatures, is(notNullValue())); assertThat(blockWithSignatures.getApiVersion(), is("2.0.0")); assertThat(blockWithSignatures.getBlockWithSignatures(), is(notNullValue())); @@ -551,7 +553,7 @@ void chainGetBlockEraEndV2() throws NoSuchAlgorithmException { //.withBody("$.params.deploy_hash", "abc") .thenDispatch(getClass().getResource("/block-samples/chain_get_block_era_end_v2.json")); - final ChainGetBlockResponse blockWithSignatures = casperServiceMock.getBlockV2(); + final ChainGetBlockResponse blockWithSignatures = casperServiceMock.getBlock(); assertThat(blockWithSignatures, is(notNullValue())); assertThat(blockWithSignatures.getApiVersion(), is("2.0.0")); assertThat(blockWithSignatures.getBlockWithSignatures(), is(notNullValue())); diff --git a/src/test/java/com/casper/sdk/service/CasperServiceTestsNctl.java b/src/test/java/com/casper/sdk/service/CasperServiceTestsNctl.java index 6830f5e44..2a27329b8 100644 --- a/src/test/java/com/casper/sdk/service/CasperServiceTestsNctl.java +++ b/src/test/java/com/casper/sdk/service/CasperServiceTestsNctl.java @@ -8,7 +8,7 @@ import com.casper.sdk.identifier.purse.MainPurseUnderPublickey; import com.casper.sdk.identifier.purse.PurseIdentifier; import com.casper.sdk.model.balance.QueryBalanceData; -import com.casper.sdk.model.block.JsonBlockData; +import com.casper.sdk.model.block.ChainGetBlockResponse; import com.casper.sdk.model.era.EraInfoData; import com.casper.sdk.model.key.PublicKey; import com.casper.sdk.model.status.ChainspecData; @@ -28,7 +28,7 @@ import static org.junit.jupiter.api.Assertions.*; @Disabled -public class CasperServiceTestsNctl extends AbstractJsonRpcTests { +public class CasperServiceTestsNctl extends AbstractJsonRpcTests { /** * Test if get block matches requested by height @@ -37,8 +37,8 @@ public class CasperServiceTestsNctl extends AbstractJsonRpcTests { void testIfBlockReturnedMatchesRequestedByHeight() { int blocks_to_check = 3; for (int i = 0; i < blocks_to_check; i++) { - JsonBlockData result = casperServiceNctl.getBlock(new HeightBlockIdentifier(i)); - assertEquals(result.getBlock().getHeader().getHeight(), i); + ChainGetBlockResponse result = casperServiceNctl.getBlock(new HeightBlockIdentifier(i)); + assertEquals(result.getBlockWithSignatures().getBlock().getHeader().getHeight(), i); } } @@ -52,8 +52,8 @@ void getStatus() { @Test void getEraSummaryByHash() { - JsonBlockData block = casperServiceNctl.getBlock(new HeightBlockIdentifier(10)); - EraInfoData eraInfoData = casperServiceNctl.getEraSummary(new HashBlockIdentifier(block.getBlock().getHash().toString())); + ChainGetBlockResponse block = casperServiceNctl.getBlock(new HeightBlockIdentifier(10)); + EraInfoData eraInfoData = casperServiceNctl.getEraSummary(new HashBlockIdentifier(block.getBlockWithSignatures().getBlock().getHash().toString())); assertNotNull(eraInfoData); assertNotNull(eraInfoData.getEraSummary()); @@ -157,7 +157,7 @@ void getGlobalStateAndSaveAsFile() throws IOException { assertTrue(Files.size(temp) > 0); String fileContent = new String(Files.readAllBytes(temp)); - assertTrue(fileContent.length() > 0); + assertTrue(!fileContent.isEmpty()); } else { assertThrowsExactly(CasperInvalidStateException.class, () -> chainspec.saveGlobalState(temp)); } diff --git a/src/test/resources/block-samples/block-end-era.json b/src/test/resources/block-samples/block-end-era.json index 63482e092..1b6a804b6 100644 --- a/src/test/resources/block-samples/block-end-era.json +++ b/src/test/resources/block-samples/block-end-era.json @@ -1,68 +1,72 @@ { - "api_version" : "1.3.2", - "block" : { - "hash" : "f21dfd6c290d4e3fc6a9fc16471fd734c18d38c2fe5c7c305255f99acb2e3fa3", - "header" : { - "height" : 239119, - "state_root_hash" : "2c6af39cb8bcda66763047ddd424ee2b98f3506af02e2fc3cf5cae2357c8574b", - "random_bit" : true, - "era_end" : { - "era_report" : { - "equivocators" : [], - "rewards" : [ - { - "validator" : "01026ca707c348ed8012ac6a1f28db031fadd6eb67203501a353b867a08c8b9a80", - "amount" : 2426183451049 - }, - { - "validator" : "01031cdce87d5fe53246492f9262932f9eb7421ea54b30da1eca06874fd2a7df60", - "amount" : 265833229 - } - ], - "inactive_validators" : [] - }, - "next_era_validator_weights" : [ - { - "validator" : "01026ca707c348ed8012ac6a1f28db031fadd6eb67203501a353b867a08c8b9a80", - "weight" : "160318940675942026" - }, - { - "validator" : "01031cdce87d5fe53246492f9262932f9eb7421ea54b30da1eca06874fd2a7df60", - "weight" : "17565906011961" - } - ] + "api_version": "1.3.2", + "block_with_signatures": { + "block": { + "Version1": { + "hash": "f21dfd6c290d4e3fc6a9fc16471fd734c18d38c2fe5c7c305255f99acb2e3fa3", + "header": { + "height": 239119, + "state_root_hash": "2c6af39cb8bcda66763047ddd424ee2b98f3506af02e2fc3cf5cae2357c8574b", + "random_bit": true, + "era_end": { + "era_report": { + "equivocators": [], + "rewards": [ + { + "validator": "01026ca707c348ed8012ac6a1f28db031fadd6eb67203501a353b867a08c8b9a80", + "amount": 2426183451049 + }, + { + "validator": "01031cdce87d5fe53246492f9262932f9eb7421ea54b30da1eca06874fd2a7df60", + "amount": 265833229 + } + ], + "inactive_validators": [] }, - "body_hash" : "a35904b9316aa35b30a303077a2a55800d5413d30fb29489a2ad3a16c6fcb268", - "parent_hash" : "f8a21a93b2e51fc3833473fede8d353230c7f820b07e9eb7b0617b82576f3d95", - "accumulated_seed" : "0d4adfd35e846c6a567e99b6b926aca1d9ec3ee3a7bec961edf900a636b17ccb", - "timestamp" : "2021-09-30T14:43:26.336Z", - "era_id" : 2192, - "protocol_version" : "1.3.2" - }, - "body" : { - "proposer" : "011117189c666f81c5160cd610ee383dc9b2d0361f004934754d39752eedc64957", - "deploy_hashes" : [], - "transfer_hashes" : [ - "82c794e4310eda0a39af3f5099c8a533e0b4f9142bd614ee725b6b261e3d9579" + "next_era_validator_weights": [ + { + "validator": "01026ca707c348ed8012ac6a1f28db031fadd6eb67203501a353b867a08c8b9a80", + "weight": "160318940675942026" + }, + { + "validator": "01031cdce87d5fe53246492f9262932f9eb7421ea54b30da1eca06874fd2a7df60", + "weight": "17565906011961" + } ] - }, - "proofs" : [ - { - "signature" : "0110ef8f863dbaed2ce67709e694eb29a14866ad9aff5c55c98948248bd0526b2455941490764c3dfa83052680d552fe8a26e0714b7958bcec219ca75b3d325802", - "public_key" : "01026ca707c348ed8012ac6a1f28db031fadd6eb67203501a353b867a08c8b9a80" - }, - { - "signature" : "013383fa1a734a7edd24b10a944ed69dd97ac528ca1d6559bd69570fa2bad15a5262878eaf4324a67aea47eea8aba5e26661a0f81cc11a4134e3ebaee96c76580d", - "public_key" : "01031cdce87d5fe53246492f9262932f9eb7421ea54b30da1eca06874fd2a7df60" - }, - { - "signature" : "01dfbb12768fc71bc13a792626fc3e5c0ce744bcf2174f55e6a5a5e33d0f6f4e7256bc3c9c09fd9f4dc7b237295842cd10dc5219a1bd662cad157cf7d051364407", - "public_key" : "0103dd8b2b18ef0b9fd5b7c8e340b104ee4d966f2a167eb1a938963f8c8f699a45" - }, - { - "signature" : "01503f8ac5391cbd5900807b46821e0caa7faba18dfdb6cb931625dc2f9b3b3574df84b68aedc3b7b3d7457c47d909c70f8112d41bb2bf816fc6909df07bcd7b01", - "public_key" : "010427c1d1227c9d2aafe8c06c6e6b276da8dcd8fd170ca848b8e3e8e1038a6dc8" - } - ] + }, + "body_hash": "a35904b9316aa35b30a303077a2a55800d5413d30fb29489a2ad3a16c6fcb268", + "parent_hash": "f8a21a93b2e51fc3833473fede8d353230c7f820b07e9eb7b0617b82576f3d95", + "accumulated_seed": "0d4adfd35e846c6a567e99b6b926aca1d9ec3ee3a7bec961edf900a636b17ccb", + "timestamp": "2021-09-30T14:43:26.336Z", + "era_id": 2192, + "protocol_version": "1.3.2" + }, + "body": { + "proposer": "011117189c666f81c5160cd610ee383dc9b2d0361f004934754d39752eedc64957", + "deploy_hashes": [], + "transfer_hashes": [ + "82c794e4310eda0a39af3f5099c8a533e0b4f9142bd614ee725b6b261e3d9579" + ] + } + } + }, + "proofs": [ + { + "signature": "0110ef8f863dbaed2ce67709e694eb29a14866ad9aff5c55c98948248bd0526b2455941490764c3dfa83052680d552fe8a26e0714b7958bcec219ca75b3d325802", + "public_key": "01026ca707c348ed8012ac6a1f28db031fadd6eb67203501a353b867a08c8b9a80" + }, + { + "signature": "013383fa1a734a7edd24b10a944ed69dd97ac528ca1d6559bd69570fa2bad15a5262878eaf4324a67aea47eea8aba5e26661a0f81cc11a4134e3ebaee96c76580d", + "public_key": "01031cdce87d5fe53246492f9262932f9eb7421ea54b30da1eca06874fd2a7df60" + }, + { + "signature": "01dfbb12768fc71bc13a792626fc3e5c0ce744bcf2174f55e6a5a5e33d0f6f4e7256bc3c9c09fd9f4dc7b237295842cd10dc5219a1bd662cad157cf7d051364407", + "public_key": "0103dd8b2b18ef0b9fd5b7c8e340b104ee4d966f2a167eb1a938963f8c8f699a45" + }, + { + "signature": "01503f8ac5391cbd5900807b46821e0caa7faba18dfdb6cb931625dc2f9b3b3574df84b68aedc3b7b3d7457c47d909c70f8112d41bb2bf816fc6909df07bcd7b01", + "public_key": "010427c1d1227c9d2aafe8c06c6e6b276da8dcd8fd170ca848b8e3e8e1038a6dc8" } + ] + } } diff --git a/src/test/resources/block-samples/chain_get_block.json b/src/test/resources/block-samples/chain_get_block.json index 707189302..a3f55fb00 100644 --- a/src/test/resources/block-samples/chain_get_block.json +++ b/src/test/resources/block-samples/chain_get_block.json @@ -3,77 +3,81 @@ "id": "348307860", "result": { "api_version": "1.5.3", - "block": { - "hash": "709a31cbaff23da43995e78d2209e7f5980905cf70ef850f6744b8d3cec9af13", - "header": { - "parent_hash": "ee3da162c775f921e836ec6d41dedcb006bb972224d1058738e9413dea61fd5e", - "state_root_hash": "11603180d5807c983f568347090a05230fb18f60658ff2b459554b4b05b592b8", - "body_hash": "a443461775cb6fe888d0bea24c552b50430099526842664cab6b0f9e66bc10bb", - "random_bit": false, - "accumulated_seed": "427cb1bb76357a6e78273d55deeaa279d5fd2e0f7606a770a3002a1ca72ddca9", - "era_end": null, - "timestamp": "2024-01-03T23:41:23.840Z", - "era_id": 12082, - "height": 2346915, - "protocol_version": "1.5.3" - }, - "body": { - "proposer": "01753af321afc6906fcd9c897e5328f66190b5842671f16b022b69f2ddb7619c32", - "deploy_hashes": [ - "f02d5a0f437bdbb907187ab0a73fa363f8f440ca12a950e04017b61e99f71b89", - "ed698b72ff0e5a8204bc7d224e7de1b2edbc390b0eb8416c3c23f432c5f10540", - "1e369288c4b77147f0057aa5ef00d0e5443f6b8ebccc48841fba30195486eab0", - "4a26cdc660d4de3f2f8688f46f98304a9e86eff3faf3d4ad8b2af0e6100decd8", - "5cbdf2c03c06c15a1e857492906f47cba1f9dd796c99094e4e62170ad27d424f", - "8098707d55177a218d6942ecbdd7434138c5eae953df5a7f301fe3d5967fc23d", - "a1d7a106d19c504785aae4a10ad80971e9b1eea8ffbe87d343f7d34c5bb4b9fb", - "99924ec78a075221c858c674d3c80d52517ba6a6dcdc3f4767bba3375e1a6675", - "104b9758eedb13ee624d7926c52fcb26be34f78162142c522de8be90bdb1f797", - "b5606bfd7aded6c66afd1790728880c42f47a1a7941f333b4fa3a25f7aae15bf", - "5b7ca0bb96348bcd0030beea45c78da89c2ebb6d4efa8cb71997b1b10d942a01", - "6e55210e7f769e6a5dcfbd728b3042f992079ed19b99d66b2f6a7a3784eba8a4", - "e3f522ee4635d4b4ad0dae15a0ffa66f5430dd88cb5f995105667032770d87d4", - "22817ff725e6a2c62e4755be81fb2c45d7b94bbc22162789fff14480e490673a", - "3164c5ae41d7609bde110d632ff86fa27a79802e6fa5c81bb14a32681b9775be", - "dac44b70bf105f8bdd6702120ea573ba506c76a2880d4f5fba666c3bc45d271c", - "bf0ec575f5fea0da8440c3b99f5be51f3d37216b90e359784c75c5c0c9607494", - "d11a52781f9b8993eeaee4c7699c48879c58a7843740d061778007a5a8f0f92e", - "19d79cd566213566eee4b9e42dd35110a01410c00d366c936616bbabe6a9e96a", - "79b0c86f216f6608ccd137fb179bcc2e19862a7b1620ad4c161e2a73e35ce26f", - "1fc7331a55d9701986f34e606ec3bf882eb69248896a53a5b0d13bd4bba4e959", - "bcc3cb215ab417cca7d765a099a16eaaf3502b11ef54cb45c323792df3ae4ddb", - "19b04f716d23d9cd7d905b6d25374f4483926d5d1e366ab3b2f03b1a071bfd4f", - "cbd6d7492501ce13a934e13c28dce09518c9fa624215c9f05bce16abc2828b98", - "6bf19f74540ebe65b8c2aa24231672ee4fa3bd5387c4827a6f5c9dc78a6d3544", - "4295625a1153a46e3669f1dc68ea4df2a6579561e583976c223a8d0ab123d207", - "b902486bab5c75a33e50e8222e4b4812faa61246d18f73ffeec1403177dcec60", - "ccfaf6152f3e409064845c7e0842baa22635afc7e6f554ca653a8840eea2dc17", - "1bc67f9c2d768a907ced9d12df61215cab347fa4aadf87d4ba14ed929027e16e", - "00dc4e531ade3d33a0a6207695e77fd8fe6cfc434c323768122c1fe6ffe1e57a", - "3a04839d1087ac27452f59eea258003863153995fdb43a4d1abdb4312a136752", - "94ae073dc4d5ef0ac27203d699b02818211db43ca48915b1883a37d5846798e4", - "fb73ee1393062a525bcdb9ca182325a861a45e025c3746166811a66bcd67d152", - "8d7b077f65667811cc7501b02df9a2efac1926aafb42fc9c87fe4df41b110bfc", - "c8df5bf2846bf719817696aceab3e65414535fda4a98a298e8475a02d9d21a8e", - "4dbd1ef261871e21e944e2e0f85699e016b33ed10c44be86aaf9512ab8f9bfa2", - "3dd8caf4f2059ad3dd77ec3acedd167722dc8952ee3a9ab0ac3a25248ea20091", - "39189d27ec06beb29cf1c62652119491a85731981942397fd40c9324f1afe075", - "2428d2f33fed931f042d56a3d72663f27d4c7084fc3f274458a3c543e5cd8ce0", - "a169ef423fe0e00cd80f440cea3881f8a5195631faf113ac88e4e18356502504", - "2eb3f176c5015cd86d6b5e3d0c1bcdf3ccda698c709abccf06b3095d8287b3cf", - "c5783255f1302f997b2eee1e98dbb2891824aa9c2ed640b8a174c057bb03e838", - "bda73b469b464931df94ed7871f4ff9679bfceb2cc6f44e5feac65b9439e0dd6", - "6315adb791df54e7909e2c2610b5600a1232ab9d7e0000888ebd5fcebb881394", - "595cae14298baeee70e086dcb9692cdea6e113f8d2a9c923f46e5cf5c2105862", - "4733c13c08ed53f7fc4dd50d2f6c34fbe2bc07af059facf045feff8881cf9007", - "ade8103fbe62ca8680887c7a08b392eb6c73b757fb77059951a75188b78bfdd0", - "02a08922ceb8c91fe08c1133f761ef6dfd1a78dda633a87be2ee85a17d08f310", - "002c266be7ba35f691eb328de1dbfec7f4d5cb9f6c7e4085ee2847b1e3538b99", - "ce3850ff2318fa414ef9b4d40eb08f962a6d5b5a21dc8d82f575bf6275c8168f" - ], - "transfer_hashes": [ - "8739fff75029b8da4f8984845aca278cd60b566275886754fb8d75673d8eb889" - ] + "block_with_signatures": { + "block": { + "Version1": { + "hash": "709a31cbaff23da43995e78d2209e7f5980905cf70ef850f6744b8d3cec9af13", + "header": { + "parent_hash": "ee3da162c775f921e836ec6d41dedcb006bb972224d1058738e9413dea61fd5e", + "state_root_hash": "11603180d5807c983f568347090a05230fb18f60658ff2b459554b4b05b592b8", + "body_hash": "a443461775cb6fe888d0bea24c552b50430099526842664cab6b0f9e66bc10bb", + "random_bit": false, + "accumulated_seed": "427cb1bb76357a6e78273d55deeaa279d5fd2e0f7606a770a3002a1ca72ddca9", + "era_end": null, + "timestamp": "2024-01-03T23:41:23.840Z", + "era_id": 12082, + "height": 2346915, + "protocol_version": "1.5.3" + }, + "body": { + "proposer": "01753af321afc6906fcd9c897e5328f66190b5842671f16b022b69f2ddb7619c32", + "deploy_hashes": [ + "f02d5a0f437bdbb907187ab0a73fa363f8f440ca12a950e04017b61e99f71b89", + "ed698b72ff0e5a8204bc7d224e7de1b2edbc390b0eb8416c3c23f432c5f10540", + "1e369288c4b77147f0057aa5ef00d0e5443f6b8ebccc48841fba30195486eab0", + "4a26cdc660d4de3f2f8688f46f98304a9e86eff3faf3d4ad8b2af0e6100decd8", + "5cbdf2c03c06c15a1e857492906f47cba1f9dd796c99094e4e62170ad27d424f", + "8098707d55177a218d6942ecbdd7434138c5eae953df5a7f301fe3d5967fc23d", + "a1d7a106d19c504785aae4a10ad80971e9b1eea8ffbe87d343f7d34c5bb4b9fb", + "99924ec78a075221c858c674d3c80d52517ba6a6dcdc3f4767bba3375e1a6675", + "104b9758eedb13ee624d7926c52fcb26be34f78162142c522de8be90bdb1f797", + "b5606bfd7aded6c66afd1790728880c42f47a1a7941f333b4fa3a25f7aae15bf", + "5b7ca0bb96348bcd0030beea45c78da89c2ebb6d4efa8cb71997b1b10d942a01", + "6e55210e7f769e6a5dcfbd728b3042f992079ed19b99d66b2f6a7a3784eba8a4", + "e3f522ee4635d4b4ad0dae15a0ffa66f5430dd88cb5f995105667032770d87d4", + "22817ff725e6a2c62e4755be81fb2c45d7b94bbc22162789fff14480e490673a", + "3164c5ae41d7609bde110d632ff86fa27a79802e6fa5c81bb14a32681b9775be", + "dac44b70bf105f8bdd6702120ea573ba506c76a2880d4f5fba666c3bc45d271c", + "bf0ec575f5fea0da8440c3b99f5be51f3d37216b90e359784c75c5c0c9607494", + "d11a52781f9b8993eeaee4c7699c48879c58a7843740d061778007a5a8f0f92e", + "19d79cd566213566eee4b9e42dd35110a01410c00d366c936616bbabe6a9e96a", + "79b0c86f216f6608ccd137fb179bcc2e19862a7b1620ad4c161e2a73e35ce26f", + "1fc7331a55d9701986f34e606ec3bf882eb69248896a53a5b0d13bd4bba4e959", + "bcc3cb215ab417cca7d765a099a16eaaf3502b11ef54cb45c323792df3ae4ddb", + "19b04f716d23d9cd7d905b6d25374f4483926d5d1e366ab3b2f03b1a071bfd4f", + "cbd6d7492501ce13a934e13c28dce09518c9fa624215c9f05bce16abc2828b98", + "6bf19f74540ebe65b8c2aa24231672ee4fa3bd5387c4827a6f5c9dc78a6d3544", + "4295625a1153a46e3669f1dc68ea4df2a6579561e583976c223a8d0ab123d207", + "b902486bab5c75a33e50e8222e4b4812faa61246d18f73ffeec1403177dcec60", + "ccfaf6152f3e409064845c7e0842baa22635afc7e6f554ca653a8840eea2dc17", + "1bc67f9c2d768a907ced9d12df61215cab347fa4aadf87d4ba14ed929027e16e", + "00dc4e531ade3d33a0a6207695e77fd8fe6cfc434c323768122c1fe6ffe1e57a", + "3a04839d1087ac27452f59eea258003863153995fdb43a4d1abdb4312a136752", + "94ae073dc4d5ef0ac27203d699b02818211db43ca48915b1883a37d5846798e4", + "fb73ee1393062a525bcdb9ca182325a861a45e025c3746166811a66bcd67d152", + "8d7b077f65667811cc7501b02df9a2efac1926aafb42fc9c87fe4df41b110bfc", + "c8df5bf2846bf719817696aceab3e65414535fda4a98a298e8475a02d9d21a8e", + "4dbd1ef261871e21e944e2e0f85699e016b33ed10c44be86aaf9512ab8f9bfa2", + "3dd8caf4f2059ad3dd77ec3acedd167722dc8952ee3a9ab0ac3a25248ea20091", + "39189d27ec06beb29cf1c62652119491a85731981942397fd40c9324f1afe075", + "2428d2f33fed931f042d56a3d72663f27d4c7084fc3f274458a3c543e5cd8ce0", + "a169ef423fe0e00cd80f440cea3881f8a5195631faf113ac88e4e18356502504", + "2eb3f176c5015cd86d6b5e3d0c1bcdf3ccda698c709abccf06b3095d8287b3cf", + "c5783255f1302f997b2eee1e98dbb2891824aa9c2ed640b8a174c057bb03e838", + "bda73b469b464931df94ed7871f4ff9679bfceb2cc6f44e5feac65b9439e0dd6", + "6315adb791df54e7909e2c2610b5600a1232ab9d7e0000888ebd5fcebb881394", + "595cae14298baeee70e086dcb9692cdea6e113f8d2a9c923f46e5cf5c2105862", + "4733c13c08ed53f7fc4dd50d2f6c34fbe2bc07af059facf045feff8881cf9007", + "ade8103fbe62ca8680887c7a08b392eb6c73b757fb77059951a75188b78bfdd0", + "02a08922ceb8c91fe08c1133f761ef6dfd1a78dda633a87be2ee85a17d08f310", + "002c266be7ba35f691eb328de1dbfec7f4d5cb9f6c7e4085ee2847b1e3538b99", + "ce3850ff2318fa414ef9b4d40eb08f962a6d5b5a21dc8d82f575bf6275c8168f" + ], + "transfer_hashes": [ + "8739fff75029b8da4f8984845aca278cd60b566275886754fb8d75673d8eb889" + ] + } + } }, "proofs": [ {