Skip to content

GH-598: fixes driven from debugging - review 2#743

Open
bertllll wants to merge 3 commits into
GH-598-cosmetics-1-review-1from
GH-598-some-cosmetics-2
Open

GH-598: fixes driven from debugging - review 2#743
bertllll wants to merge 3 commits into
GH-598-cosmetics-1-review-1from
GH-598-some-cosmetics-2

Conversation

@bertllll
Copy link
Copy Markdown
Contributor

No description provided.

@cursor
Copy link
Copy Markdown

cursor Bot commented Nov 11, 2025

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on November 14.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Comment thread node/src/accountant/logging_utils/accounting_msgs_debug.rs
Comment thread node/src/accountant/logging_utils/msg_id_generator.rs
Comment thread node/src/accountant/logging_utils/msg_id_generator.rs
Copy link
Copy Markdown
Collaborator

@utkarshg6 utkarshg6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Continue at node/src/sub_lib/accountant.rs:136

Comment thread node/src/accountant/test_utils.rs
Comment thread node/src/hopper/routing_service.rs
pub payload_size: usize,
pub service_rate: u64,
pub byte_rate: u64,
pub trait AccountableServiceWithTraceLog {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be additional complexity while searching for logs in the production code. I personally prefer a direct print of log using macros. Introducing a layer of abstraction here apparently can make it harder to search for logs.

fn trace_log_msg(&self, msg_id: u32) -> String;
}

pub trait MessageWithServicesProvided {
Copy link
Copy Markdown
Collaborator

@utkarshg6 utkarshg6 Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer enum based approach here

#[derive(Clone, PartialEq, Eq, Debug, Message)]
pub struct ReportServiceProvidedMessage {
    pub service: ServiceProvided,
    pub service_type: ServiceType,
}

#[derive(Clone, PartialEq, Eq, Debug)]
pub enum ServiceType {
    Exit,
    Routing,
}

impl ReportServiceProvidedMessage {
    pub fn new_exit_service(service: ServiceProvided) -> Self {
        Self {
            service,
            service_type: ServiceType::Exit,
        }
    }
    
    pub fn new_routing_service(service: ServiceProvided) -> Self {
        Self {
            service,
            service_type: ServiceType::Routing,
        }
    }
}

impl ReportServiceProvidedMessage {
    fn services_provided(&self) -> &ServiceProvided {
        &self.service
    }

    fn service_type(&self) -> ServiceType {
        self.service_type
    }
}

pub routing: RoutingServicesConsumed,
}

impl AccountableServiceWithTraceLog for ExitServiceConsumed {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 219...234 could be replaced by a single log message which just prints the service type similar to other values in the trace log message.

pub byte_rate: u64,
}

pub enum ServiceProvidedTraceLogWrapper<'a> {
Copy link
Copy Markdown
Collaborator

@utkarshg6 utkarshg6 Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again it should be done other way around. You should use the enum ServiceType here. Refer to this comment - https://github.com/MASQ-Project/Node/pull/743/files#r2533460766

let exit_service_msg = ReportExitServiceProvidedMessage {
service: service.clone(),
};
let routing_service_msg = ReportRoutingServiceProvidedMessage { service };
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test will change slightly. You should consider a test with 2 cases along with a helper function.

Copy link
Copy Markdown
Collaborator

@utkarshg6 utkarshg6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Continue at node/src/accountant/logging_utils/accounting_msgs_debug.rs

Comment thread node/src/accountant/logging_utils/accounting_msgs_debug.rs
Comment thread node/src/accountant/logging_utils/accounting_msgs_debug.rs
Comment thread node/src/accountant/logging_utils/accounting_msgs_debug.rs
Comment thread node/src/accountant/logging_utils/accounting_msgs_debug.rs
Comment thread node/src/accountant/logging_utils/accounting_msgs_debug.rs
Copy link
Copy Markdown
Collaborator

@utkarshg6 utkarshg6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Continue at node/src/accountant/mod.rs

Comment thread node/src/accountant/mod.rs
}
fn handle_report_service_provided_message<AccountingMessage>(&mut self, msg: AccountingMessage)
where
AccountingMessage: MessageWithServicesProvided,
Copy link
Copy Markdown
Collaborator

@utkarshg6 utkarshg6 Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go away once you decide to use the structure instead of the trait implementation. The enum based approach will make things easier for you here. You can thank me later.

msg.payload_size,
&msg.paying_wallet,
);
trace_log_wrapper.log_trace(self.logging_kit(MsgIdRequested::New));
Copy link
Copy Markdown
Collaborator

@utkarshg6 utkarshg6 Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is worrisome. I think if we had to find the log once we have the log file with us, then at that time, it'll be difficult for us to find this.

This layer of abstraction is the issue, if it wasn't for a use case like logging, I'd appreciate it and here, I'm concerned.

Copy link
Copy Markdown
Collaborator

@utkarshg6 utkarshg6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants