mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Add fee burning and blackhole address (#703)
* Fix tlbc crash * Burn specified fraction of fees * Add "blackhole" for burning TONs --------- Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
parent
d5cd548502
commit
ef64b92f08
12 changed files with 187 additions and 57 deletions
|
@ -855,11 +855,12 @@ Ref<McShardHash> McShardHash::from_block(Ref<vm::Cell> block_root, const ton::Fi
|
|||
ton::RootHash rhash = block_root->get_hash().bits();
|
||||
CurrencyCollection fees_collected, funds_created;
|
||||
if (init_fees) {
|
||||
block::gen::ValueFlow::Record flow;
|
||||
if (!(tlb::unpack_cell(rec.value_flow, flow) && fees_collected.unpack(flow.fees_collected) &&
|
||||
funds_created.unpack(flow.r2.created))) {
|
||||
block::ValueFlow flow;
|
||||
if (!flow.unpack(vm::load_cell_slice_ref(rec.value_flow))) {
|
||||
return {};
|
||||
}
|
||||
fees_collected = flow.fees_collected;
|
||||
funds_created = flow.created;
|
||||
}
|
||||
return Ref<McShardHash>(true, ton::BlockId{ton::ShardIdFull(shard), (unsigned)info.seq_no}, info.start_lt,
|
||||
info.end_lt, info.gen_utime, rhash, fhash, fees_collected, funds_created, ~0U,
|
||||
|
@ -909,11 +910,12 @@ Ref<McShardDescr> McShardDescr::from_block(Ref<vm::Cell> block_root, Ref<vm::Cel
|
|||
ton::RootHash rhash = block_root->get_hash().bits();
|
||||
CurrencyCollection fees_collected, funds_created;
|
||||
if (init_fees) {
|
||||
block::gen::ValueFlow::Record flow;
|
||||
if (!(tlb::unpack_cell(rec.value_flow, flow) && fees_collected.unpack(flow.fees_collected) &&
|
||||
funds_created.unpack(flow.r2.created))) {
|
||||
block::ValueFlow flow;
|
||||
if (!flow.unpack(vm::load_cell_slice_ref(rec.value_flow))) {
|
||||
return {};
|
||||
}
|
||||
fees_collected = flow.fees_collected;
|
||||
funds_created = flow.created;
|
||||
}
|
||||
auto res = Ref<McShardDescr>(true, ton::BlockId{ton::ShardIdFull(shard), (unsigned)info.seq_no}, info.start_lt,
|
||||
info.end_lt, info.gen_utime, rhash, fhash, fees_collected, funds_created, ~0U,
|
||||
|
@ -1954,6 +1956,24 @@ std::unique_ptr<vm::Dictionary> Config::get_suspended_addresses(ton::UnixTime no
|
|||
return std::make_unique<vm::Dictionary>(rec.addresses->prefetch_ref(), 288);
|
||||
}
|
||||
|
||||
BurningConfig Config::get_burning_config() const {
|
||||
td::Ref<vm::Cell> param = get_config_param(5);
|
||||
gen::BurningConfig::Record rec;
|
||||
if (param.is_null() || !tlb::unpack_cell(param, rec)) {
|
||||
return {};
|
||||
}
|
||||
BurningConfig c;
|
||||
c.fee_burn_nom = rec.fee_burn_nom;
|
||||
c.fee_burn_denom = rec.fee_burn_denom;
|
||||
vm::CellSlice& addr = rec.blackhole_addr.write();
|
||||
if (addr.fetch_long(1)) {
|
||||
td::Bits256 x;
|
||||
addr.fetch_bits_to(x.bits(), 256);
|
||||
c.blackhole_addr = x;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
td::Result<std::pair<ton::UnixTime, ton::UnixTime>> Config::unpack_validator_set_start_stop(Ref<vm::Cell> vset_root) {
|
||||
if (vset_root.is_null()) {
|
||||
return td::Status::Error("validator set absent");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue