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

api: disable construction API if spend policy is unset #232

Merged
merged 3 commits into from
Feb 14, 2025

Conversation

n8maninger
Copy link
Member

@n8maninger n8maninger commented Feb 12, 2025

There was a change in coreutils that makes it so the zero value of spend policy cannot be encoded or decoded. This changes the construction API to return an error if one of the funding addresses does not have a policy set.

api/server.go Outdated Show resolved Hide resolved
peterjan
peterjan previously approved these changes Feb 12, 2025
Copy link
Member

@ChrisSchinnerl ChrisSchinnerl left a comment

Choose a reason for hiding this comment

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

No integration 🧪 ?

api/server.go Outdated Show resolved Hide resolved
@lukechampine
Copy link
Member

I would rather omit the SpendPolicy entirely rather than return something that is almost certainly incorrect. If there's a possibility that we don't know what the SpendPolicy is, we shouldn't be returning it.

@n8maninger
Copy link
Member Author

n8maninger commented Feb 12, 2025

I would rather omit the SpendPolicy entirely rather than return something that is almost certainly incorrect. If there's a possibility that we don't know what the SpendPolicy is, we shouldn't be returning it.

@lukechampine SiaFoundation/core#268 (comment)

I'm fine with that, but we have to reconcile with this change since the API client can no longer unmarshal a transaction with an unset policy. From my perspective, we have two options: we can either reconsider SiaFoundation/core#268 or we can force the spend policy to a default here.

api/server.go Outdated Show resolved Hide resolved
@n8maninger n8maninger force-pushed the nate/default-spend-policy branch from e3a0caf to 71be43b Compare February 13, 2025 17:25
@n8maninger n8maninger changed the title api: default to anyone can spend api: disable construction API if spend policy is unset Feb 13, 2025
api/server.go Outdated Show resolved Hide resolved
@lukechampine
Copy link
Member

IIUC this means that you'll get an API error if s.wm.SelectSiacoinElements happens to select an address without a spend policy, even if there is some other combination of addresses that would work. Perhaps s.wm.SelectSiacoinElements could only return elements with known spend policies? (What else is s.wm.SelectSiacoinElements used for?)

@n8maninger
Copy link
Member Author

IIUC this means that you'll get an API error if s.wm.SelectSiacoinElements happens to select an address without a spend policy, even if there is some other combination of addresses that would work. Perhaps s.wm.SelectSiacoinElements could only return elements with known spend policies? (What else is s.wm.SelectSiacoinElements used for?)

It's also used in the legacy /fund endpoints and I don't want to change behavior there. I'd probably add a separate method for it.

@lukechampine
Copy link
Member

Ok. As-is, this is not great, not terrible. I'd be ok merging now and following up later.

ChrisSchinnerl
ChrisSchinnerl previously approved these changes Feb 14, 2025
api/server.go Outdated Show resolved Hide resolved
peterjan
peterjan previously approved these changes Feb 14, 2025
lukechampine
lukechampine previously approved these changes Feb 14, 2025
@n8maninger n8maninger force-pushed the nate/default-spend-policy branch from efe6fcb to 65021ca Compare February 14, 2025 22:55
@n8maninger n8maninger merged commit bbf2d00 into master Feb 14, 2025
7 checks passed
@n8maninger n8maninger deleted the nate/default-spend-policy branch February 14, 2025 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants