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

fix(validator-node): return error if contract_id empty for publish_contract_acceptance grpc #4191

Conversation

sdbondi
Copy link
Member

@sdbondi sdbondi commented Jun 14, 2022

Description

Returns invalid argument if contract id is not provided
Log error if publishing fails

Motivation and Context

If contract_id was not provided, a zero hash would be used and published.

How Has This Been Tested?

Manually

Copy link
Contributor

@brianp brianp left a comment

Choose a reason for hiding this comment

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

So the problem was more the use of unwrap_or_default(); providing a zero hash?

How was it possible to pass an empty argument with grpc. Doesn't it normally validate the request structure. So a contract id needs to be present for the request to be accepted.

@sdbondi
Copy link
Member Author

sdbondi commented Jun 14, 2022

@brianp All fields in protobuf are optional - so if you dont provide the contract_id, it will be, in the base of bytes, an empty vec - since that obviously isnt a 32-byte vec/slice the try_from will fail and the default will be used (i.e. zeros) which would then be passed to create constitution.

This change will error out if the contract_id isnt 32-bytes (e.g was not passed in at all)

@aviator-app aviator-app bot merged commit 8874114 into tari-project:development Jun 15, 2022
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.

3 participants