Skip to content

Commit a7083a9

Browse files
author
Ivo Georgiev
committed
implement feeAddr, allowing validators to receive fees at a different address
1 parent 72f5be4 commit a7083a9

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

adapter/src/ethereum.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ mod test {
547547
.expect("failed to create id"),
548548
url: "http://localhost:8005".to_string(),
549549
fee: 100.into(),
550+
fee_addr: None,
550551
};
551552

552553
let follower_validator_desc = ValidatorDesc {
@@ -555,6 +556,7 @@ mod test {
555556
.expect("failed to create id"),
556557
url: "http://localhost:8006".to_string(),
557558
fee: 100.into(),
559+
fee_addr: None,
558560
};
559561

560562
let mut valid_channel = Channel {

primitives/src/util/tests/prep_db.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ lazy_static! {
4545
id: ValidatorId::try_from("ce07CbB7e054514D590a0262C93070D838bFBA2e").expect("Failed to parse DUMMY_VALIDATOR_LEADER id "),
4646
url: "http://localhost:8005".to_string(),
4747
fee: 100.into(),
48+
fee_addr: None,
4849
};
4950

5051
pub static ref DUMMY_VALIDATOR_FOLLOWER: ValidatorDesc = ValidatorDesc {
5152
id: ValidatorId::try_from("c91763d7f14ac5c5ddfbcd012e0d2a61ab9bded3").expect("Failed to parse DUMMY_VALIDATOR_FOLLOWER id "),
5253
url: "http://localhost:8006".to_string(),
5354
fee: 100.into(),
55+
fee_addr: None,
5456
};
5557

5658
pub static ref DUMMY_CHANNEL: Channel = {

primitives/src/validator.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ impl fmt::Display for ValidatorId {
8787
#[serde(rename_all = "camelCase")]
8888
pub struct ValidatorDesc {
8989
pub id: ValidatorId,
90+
pub fee_addr: Option<ValidatorId>,
9091
pub url: String,
9192
pub fee: BigNum,
9293
}

validator_worker/src/core/fees.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ fn distribute_fee<'a>(
7676
};
7777

7878
if fee_rounded > 0.into() {
79+
let addr = validator.fee_addr.as_ref().unwrap_or(&validator.id);
7980
let entry = balances
80-
.entry(validator.id.to_string())
81+
.entry(addr.to_string())
8182
.or_insert_with(|| 0.into());
8283

8384
*entry += &fee_rounded;

0 commit comments

Comments
 (0)