Skip to content

Commit

Permalink
Merge pull request #2903 from Taraxa-project/master_develop
Browse files Browse the repository at this point in the history
Master -> develop
  • Loading branch information
MatusKysel authored Dec 2, 2024
2 parents b4a09bc + dec30a8 commit 3ebcd12
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 10 deletions.
2 changes: 1 addition & 1 deletion charts/taraxa-node/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
appVersion: "1.0"
description: Kubernetes helm chart for Taraxa blockchain full node implementation.
name: taraxa-node
version: 0.3.13
version: 0.3.14
keywords:
- blockchain
- taraxa
Expand Down
6 changes: 6 additions & 0 deletions charts/taraxa-node/templates/consensus-node-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ data:
{{- end }}
{{- end }}
{{ if .Values.config.snapshots.enabled }}
cat $CONFIG_PATH | jq '.db_config.db_max_snapshots = 1' | jq '.db_config.db_snapshot_each_n_pbft_block = 10000' > $CONFIG_PATH.tmp && mv $CONFIG_PATH.tmp $CONFIG_PATH
{{- else }}
cat $CONFIG_PATH | jq '.db_config.db_max_snapshots = 0' | jq '.db_config.db_snapshot_each_n_pbft_block = 0' > $CONFIG_PATH.tmp && mv $CONFIG_PATH.tmp $CONFIG_PATH
{{- end }}
echo "***** $CONFIG_PATH *****"
cat $CONFIG_PATH
echo "***** $CONFIG_PATH *****"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ data:
{{- end }}
{{- end }}
{{ if .Values.config.snapshots.enabled }}
cat $CONFIG_PATH | jq '.db_config.db_max_snapshots = 1' | jq '.db_config.db_snapshot_each_n_pbft_block = 10000' > $CONFIG_PATH.tmp && mv $CONFIG_PATH.tmp $CONFIG_PATH
{{- else }}
cat $CONFIG_PATH | jq '.db_config.db_max_snapshots = 0' | jq '.db_config.db_snapshot_each_n_pbft_block = 0' > $CONFIG_PATH.tmp && mv $CONFIG_PATH.tmp $CONFIG_PATH
{{- end }}
echo "***** $CONFIG_PATH *****"
cat $CONFIG_PATH
echo "***** $CONFIG_PATH *****"
Expand Down
6 changes: 6 additions & 0 deletions charts/taraxa-node/templates/taraxa-node-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ data:
{{- end }}
{{- end }}
{{ if .Values.config.snapshots.enabled }}
cat $CONFIG_PATH | jq '.db_config.db_max_snapshots = 1' | jq '.db_config.db_snapshot_each_n_pbft_block = 10000' > $CONFIG_PATH.tmp && mv $CONFIG_PATH.tmp $CONFIG_PATH
{{- else }}
cat $CONFIG_PATH | jq '.db_config.db_max_snapshots = 0' | jq '.db_config.db_snapshot_each_n_pbft_block = 0' > $CONFIG_PATH.tmp && mv $CONFIG_PATH.tmp $CONFIG_PATH
{{- end }}
echo "***** $CONFIG_PATH *****"
cat $CONFIG_PATH
echo "***** $CONFIG_PATH *****"
Expand Down
2 changes: 2 additions & 0 deletions charts/taraxa-node/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ config:
# 100 for default helm test
network: "100"
extraArgs: []
snapshots:
enabled: true

# Default keys, VRFs and address for kube testing
node:
Expand Down
10 changes: 8 additions & 2 deletions libraries/core_libs/consensus/include/final_chain/data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct BlockHeaderData {
LogBloom log_bloom;
uint64_t gas_used = 0;
u256 total_reward;
uint64_t size = 0;

dev::bytes serializeForDB() const;

Expand All @@ -46,12 +47,15 @@ struct BlockHeader : BlockHeaderData {

static h256 const& unclesHash();

static Nonce const& nonce();
static const Nonce& nonce();

static u256 const& difficulty();
static const u256& difficulty();

static h256 const& mixHash();

static std::shared_ptr<BlockHeader> fromRLP(const dev::RLP& rlp);

void ethereumRlp(dev::RLPStream& encoding) const;
dev::bytes ethereumRlp() const;

h256 hash;
Expand All @@ -60,6 +64,8 @@ struct BlockHeader : BlockHeaderData {
uint64_t timestamp = 0;
EthBlockNumber number = 0;
bytes extra_data;

HAS_RLP_FIELDS
};

static constexpr auto c_bloomIndexSize = 16;
Expand Down
31 changes: 24 additions & 7 deletions libraries/core_libs/consensus/src/final_chain/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,37 @@ void BlockHeader::setFromPbft(const PbftBlock& pbft) {

h256 const& BlockHeader::unclesHash() { return EmptyRLPListSHA3(); }

Nonce const& BlockHeader::nonce() { return EmptyNonce(); }
const Nonce& BlockHeader::nonce() { return EmptyNonce(); }

u256 const& BlockHeader::difficulty() { return ZeroU256(); }
const u256& BlockHeader::difficulty() { return ZeroU256(); }

h256 const& BlockHeader::mixHash() { return ZeroHash(); }
const h256& BlockHeader::mixHash() { return ZeroHash(); }

dev::bytes BlockHeader::ethereumRlp() const {
dev::RLPStream rlp_strm;
util::rlp_tuple(rlp_strm, parent_hash, BlockHeader::unclesHash(), author, state_root, transactions_root,
std::shared_ptr<BlockHeader> BlockHeader::fromRLP(const dev::RLP& rlp) {
auto ret = std::make_shared<BlockHeader>();
ret->rlp(rlp);
dev::RLPStream encoding;
ret->ethereumRlp(encoding);
ret->size = encoding.out().size();
return ret;
}

void BlockHeader::ethereumRlp(dev::RLPStream& encoding) const {
util::rlp_tuple(encoding, parent_hash, BlockHeader::unclesHash(), author, state_root, transactions_root,
receipts_root, log_bloom, BlockHeader::difficulty(), number, gas_limit, gas_used, timestamp,
extra_data, BlockHeader::mixHash(), BlockHeader::nonce());
return rlp_strm.invalidate();
}

dev::bytes BlockHeader::ethereumRlp() const {
dev::RLPStream encoding;
ethereumRlp(encoding);
return encoding.invalidate();
}

// TODO[2888]: remove hash field to not store it in the db
RLP_FIELDS_DEFINE(BlockHeader, hash, parent_hash, author, state_root, transactions_root, receipts_root, log_bloom,
number, gas_limit, gas_used, timestamp, total_reward, extra_data)

RLP_FIELDS_DEFINE(LogEntry, address, topics, data)

LogBloom LogEntry::bloom() const {
Expand Down
1 change: 1 addition & 0 deletions libraries/core_libs/network/rpc/eth/Eth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Json::Value toJson(const BlockHeader& obj) {
res["difficulty"] = "0x0";
res["totalDifficulty"] = "0x0";
res["totalReward"] = toJS(obj.total_reward);
res["size"] = toJS(obj.size);
return res;
}

Expand Down

0 comments on commit 3ebcd12

Please sign in to comment.