Skip to content

Commit

Permalink
fix(collator): total_validator_fees sub
Browse files Browse the repository at this point in the history
  • Loading branch information
drmick committed May 3, 2024
1 parent 708b96b commit bfff28f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions collator/src/collator/build_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use anyhow::{bail, Result};
use everscale_types::merkle::*;
use everscale_types::models::*;
use everscale_types::prelude::*;
use sha2::digest::typenum::private::IsGreaterPrivate;
use sha2::Digest;
use tycho_block_util::config::BlockchainConfigExt;
use tycho_block_util::state::ShardStateStuff;
Expand Down Expand Up @@ -141,13 +142,25 @@ impl CollatorStdImpl {
shard_block_refs: None,
};

new_state
.total_validator_fees
.checked_add(&value_flow.fees_collected)?;

new_state
.total_balance
.try_add_assign(&value_flow.fees_collected)?;

new_state
// TODO got error 'result error! underlying integer is too large to fit in target type' without checking
if let Err(err) = new_state
.total_validator_fees
.checked_sub(&value_flow.recovered)?;
.checked_sub(&value_flow.recovered)
{
tracing::warn!("Error: {}", err);

new_state
.total_validator_fees
.checked_sub(&new_state.total_validator_fees)?;
}

if self.shard_id.is_masterchain() {
new_state.libraries =
Expand Down
2 changes: 1 addition & 1 deletion collator/src/validator/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ use everscale_types::models::{BlockId, BlockIdShort, Signature};
use tokio::sync::{Mutex, RwLock};
use tracing::{debug, trace, warn};

use crate::tracing_targets;
use crate::types::{BlockSignatures, OnValidatedBlockEvent};
use crate::validator::types::{
BlockValidationCandidate, ValidationResult, ValidationSessionInfo, ValidatorInfo,
};
use crate::validator::ValidatorEventListener;
use tycho_network::PrivateOverlay;
use tycho_util::{FastDashMap, FastHashMap};
use crate::tracing_targets;

struct SignatureMaps {
valid_signatures: FastHashMap<HashBytes, Signature>,
Expand Down

0 comments on commit bfff28f

Please sign in to comment.