Skip to content

Commit

Permalink
remove block binary data from taraxa_getPillarBlockData rpc call
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubFornadel committed Apr 22, 2024
1 parent 2b8dbcc commit 8bf610a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 18 deletions.
31 changes: 20 additions & 11 deletions doc/RPC.md
Original file line number Diff line number Diff line change
Expand Up @@ -573,14 +573,15 @@ Returns finalized pillar block + pillar votes for specified bock number
#### Parameters

1. `QUANTITY` - pillar block period
2. `Boolean` - If true it returns also solidity encoded binary data for both pillar block and its votes
2. `Boolean` - If true it returns also pillar block signatures

#### Returns

`OBJECT` - pillar block data
* `pillar_block`: `OBJECT` - pillar block object
* `pillar_block_binary_data`: `STRING` - hex string of solidity encoded pillar block binary data
* `votes_binary_data`: `STRING` - hex string of solidity encoded pillar block votes binary data
* `signatures`: `ARRAY` - array of pillar block signatures
* `r`: `DATA`, 32 Bytes
* `vs`: `DATA`, 32 Bytes

`OBJECT` - pillar_block
* `pbft_period`: `QUANTITY` - pillar block PBFT period
Expand All @@ -605,11 +606,11 @@ curl -X POST --data '{"jsonrpc":"2.0","method":"taraxa_getPillarBlockData","para
"result": {
"pillar_block": {
"bridge_root": "0x0000000000000000000000000000000000000000000000000000000000000000",
"hash": "0xa3f55d0095967cf00179a05d5e162ed3b9d6ceaee367f75c3fd6ec1f3bb3c42d",
"hash": "0x95186add2d669c4510e671f41382e64badda65c8ee4a829a763a19b2238b0c00",
"pbft_period": 100,
"previous_pillar_block_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"state_root": "0xe9a2b242efc2f4c59b91f564737d8ac86a4daae6fef78c5d8c245e7adc1123c4",
"validators_votes_count_changes": [
"state_root": "0xf42c616561b668e450c8edcbae3b962df6e49c5f0c7550910c06af78f647caae",
"validators_vote_counts_changes": [
{
"address": "0xa63059ab41333d72b6008258dbedaaa159eacda1",
"value": 100
Expand All @@ -624,11 +625,19 @@ curl -X POST --data '{"jsonrpc":"2.0","method":"taraxa_getPillarBlockData","para
}
]
},
"pillar_block_binary_data": "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000064e9a2b242efc2f4c59b91f564737d8ac86a4daae6fef78c5d8c245e7adc1123c40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000a63059ab41333d72b6008258dbedaaa159eacda1000000000000000000000000000000000000000000000000000000000000006400000000000000000000000007badc44aa26cb163114881adb916b6f094d6ab800000000000000000000000000000000000000000000000000000000000000640000000000000000000000007433ac110692c2f4f9a57bc9fb72c41570246bd70000000000000000000000000000000000000000000000000000000000000064",
"signatures_binary_data": [
"0x0000000000000000000000000000000000000000000000000000000000000064a3f55d0095967cf00179a05d5e162ed3b9d6ceaee367f75c3fd6ec1f3bb3c42d893070c5de1807d1b45e734d388c4b2cfe5c0ea1d1d8d9f30fb410a2e91edc402be042a89f3b0f46cba3160c395435b62f218321a1f2c548fb5a6a30dde0743a",
"0x0000000000000000000000000000000000000000000000000000000000000064a3f55d0095967cf00179a05d5e162ed3b9d6ceaee367f75c3fd6ec1f3bb3c42dc08deeed1fddef5d893f2eb6a5ac3f31d2286d08b2d00457f64964c2de2eb8dbe668ee1320dee463e463f624ce1bfcda6869ba3f42729752a3b9e7e17b852730",
"0x0000000000000000000000000000000000000000000000000000000000000064a3f55d0095967cf00179a05d5e162ed3b9d6ceaee367f75c3fd6ec1f3bb3c42d1c0d7337fd01e6df3f5b0a5aa45f926051b6a181b4eea24a4880b038ffb97fe6df5a4e8605da9c7907ee37069561a691f79fa35aef898f1cbbd15c61ebaa960e"
"signatures": [
{
"r": "0x2ea1808f79f494bac434ba8142a4e3ed6628ec7904c052e83216fc908bf84f12",
"vs": "0x81bf6aceafae5a1174c0438fa594eac7f336d45a39c6f2e91df7abbe783975aa"
},
{
"r": "0xbff7ba259a5d902adcbb6395fe042d40b129b657e828ce13f5d46072d202be9d",
"vs": "0xd1ee5eb2d11e128f9590977e63834908ba5eeb276999bddaadff369aae2c91b5"
},
{
"r": "0x15738b82c00ca4f7590b809517e476fcb6e8c7d26ed6d0eb59c6e691a4b0429c",
"vs": "0xb1859cb960646a6a735f7d75aa383e3faf48c267240f72681791d28122f3b477"
}
]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ struct PillarBlockData {
PillarBlockData(std::shared_ptr<PillarBlock> block, std::vector<std::shared_ptr<PillarVote>>&& pillar_votes);
PillarBlockData(const dev::RLP& rlp);
dev::bytes getRlp() const;
Json::Value getJson(bool include_binary_data) const;
Json::Value getJson(bool include_signatures) const;

const static size_t kRlpItemCount = 2;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,11 @@ dev::bytes PillarBlockData::getRlp() const {
return s.invalidate();
}

Json::Value PillarBlockData::getJson(bool include_binary_data) const {
Json::Value PillarBlockData::getJson(bool include_signatures) const {
Json::Value res;
res["pillar_block"] = block_->getJson();

if (include_binary_data) {
res["pillar_block_binary_data"] = dev::toJS(block_->encodeSolidity());
if (include_signatures) {
res["signatures"] = Json::Value(Json::arrayValue);
for (const auto& vote : pillar_votes_) {
const auto compact = dev::CompactSignatureStruct(vote->getVoteSignature());
Expand Down
4 changes: 2 additions & 2 deletions libraries/core_libs/network/rpc/Taraxa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ std::string Taraxa::taraxa_totalSupply(const std::string& _period) {
}
}

Json::Value Taraxa::taraxa_getPillarBlockData(const std::string& pillar_block_period, bool include_binary_data) {
Json::Value Taraxa::taraxa_getPillarBlockData(const std::string& pillar_block_period, bool include_signatures) {
try {
auto node = full_node_.lock();
if (!node) {
Expand All @@ -195,7 +195,7 @@ Json::Value Taraxa::taraxa_getPillarBlockData(const std::string& pillar_block_pe
}

if (const auto pillar_block_data = node->getDB()->getPillarBlockData(pbft_period); pillar_block_data) {
return pillar_block_data->getJson(include_binary_data);
return pillar_block_data->getJson(include_signatures);
}

return {};
Expand Down
2 changes: 1 addition & 1 deletion libraries/core_libs/network/rpc/Taraxa.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Taraxa : public TaraxaFace {
virtual std::string taraxa_yield(const std::string& _period) override;
virtual std::string taraxa_totalSupply(const std::string& _period) override;
virtual Json::Value taraxa_getPillarBlockData(const std::string& pillar_block_period,
bool include_binary_data) override;
bool include_signatures) override;

protected:
std::weak_ptr<taraxa::FullNode> full_node_;
Expand Down

0 comments on commit 8bf610a

Please sign in to comment.