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

Trim leading zeros for expected value #42

Merged
merged 2 commits into from
Feb 27, 2024
Merged

Trim leading zeros for expected value #42

merged 2 commits into from
Feb 27, 2024

Conversation

yoshidan
Copy link
Contributor

@yoshidan yoshidan commented Feb 25, 2024

In BSC / ethereum, the leading zeros in the proof value is trimmed, so ELC also trims leading zeros.

Signed-off-by: Naohiro Yoshida <[email protected]>
@yoshidan yoshidan requested a review from bluele February 25, 2024 11:13
@yoshidan yoshidan changed the title Trim left zero for expected value Trim leading zeros for expected value Feb 25, 2024
let expected_value = expected_value.as_ref().map(|e| rlp::encode(e).to_vec());
let expected_value = expected_value
.as_ref()
.map(|e| rlp::encode(&trim_left_zero(e).to_vec()).to_vec());
Copy link
Member

Choose a reason for hiding this comment

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

You can remove .to_vec()

.map(|e| rlp::encode(&trim_left_zero(e)).to_vec());

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I fixed it.

let expected_value = expected_value.as_ref().map(|e| rlp::encode(e).to_vec());
let expected_value = expected_value
.as_ref()
.map(|e| rlp::encode(&trim_left_zero(e).to_vec()).to_vec());
if value != expected_value {
return Err(Error::UnexpectedStateValue(
Copy link
Member

Choose a reason for hiding this comment

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

Can you add value to UnexpectedStateValue error? It would be helpful for debug.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

fix
Signed-off-by: Naohiro Yoshida <[email protected]>
@bluele bluele self-requested a review February 27, 2024 00:40
Copy link
Member

@bluele bluele left a comment

Choose a reason for hiding this comment

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

@yoshidan LGTM👍

@yoshidan yoshidan merged commit 4bdc29f into main Feb 27, 2024
1 check passed
@yoshidan yoshidan deleted the trim_0 branch February 27, 2024 02:20
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