Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetSize implementation for SubmitSolutionJd is incomplete #1018

Closed
plebhash opened this issue Jun 28, 2024 · 1 comment · Fixed by #1019
Closed

GetSize implementation for SubmitSolutionJd is incomplete #1018

plebhash opened this issue Jun 28, 2024 · 1 comment · Fixed by #1019
Labels
binary-sv2 bug Something isn't working codec-sv2

Comments

@plebhash
Copy link
Collaborator

while working on #1003 I got stuck.

I kept getting FramingSv2Error(BinarySv2Error(WriteError)) even though my SubmitSolution message was perfectly defined on the MG test.

After a few hours of debugging, I found the root cause:

pub struct SubmitSolutionJd<'decoder> {
#[cfg_attr(feature = "with_serde", serde(borrow))]
pub extranonce: B032<'decoder>,
#[cfg_attr(feature = "with_serde", serde(borrow))]
pub prev_hash: U256<'decoder>,
pub ntime: u32,
pub nonce: u32,
pub nbits: u32,
pub version: u32,
}
#[cfg(feature = "with_serde")]
use binary_sv2::GetSize;
#[cfg(feature = "with_serde")]
impl<'d> GetSize for SubmitSolutionJd<'d> {
fn get_size(&self) -> usize {
self.extranonce.get_size()
+ self.prev_hash.get_size()
+ self.ntime.get_size()
+ self.nonce.get_size()
+ self.nbits.get_size()
}
}

the GetSize implementation is not accounting for self.version.get_size()!

that is causing NoiseEncoder to allocate a buffer that's smaller than what is actually needed, which eventually triggers FramingSv2Error(BinarySv2Error(WriteError)) during encoding

@GitGab19
Copy link
Collaborator

Closed by #1019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binary-sv2 bug Something isn't working codec-sv2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants