-
Notifications
You must be signed in to change notification settings - Fork 214
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
[Merged by Bors] - Allow vaults to spend received funds #5840
Conversation
999682f
to
5edb642
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #5840 +/- ##
=======================================
Coverage 80.4% 80.4%
=======================================
Files 285 285
Lines 29510 29514 +4
=======================================
+ Hits 23750 23756 +6
+ Misses 4161 4159 -2
Partials 1599 1599 ☔ View full report in Codecov by Sentry. |
thanks @fasmat. let's get a second review on this one since the code path is pretty critical. |
@dshulyak pointed out that there's nothing currently preventing a misconfigured vault (with, say, an actual balance less than the This however raises the question - do we want to allow Spawning of misconfigured/invalid Vaults in the first place? Examples would be an insufficient balance, or If |
b72b7be
to
e2c579a
Compare
I prefer when objects in invalid state cannot exist in the first place rather than have to have checks around in the logic because the checks are easy to miss or get wrong.
I think go-spacemesh/genvm/templates/vault/handler.go Lines 42 to 45 in e2c579a
However,
|
Makes sense. But the question is orthogonal to the fixes in this PR. Let's get this merged and then address that question separately.
Actually division by zero is impossible here. If go-spacemesh/genvm/templates/vault/vault.go Lines 41 to 46 in e2c579a
Note that there's already a test for this: go-spacemesh/genvm/templates/vault/vault_test.go Lines 304 to 312 in e2c579a
I'll add a comment in the code to this effect. |
e2c579a
to
0a6be48
Compare
Host context must return remote account balance
Ensure that vault can spend received coins, and that coins are spent out of vault (remote) wallet not principal wallet
Adds a new error type and allows these txs to be failed rather than crashing the node with a panic
It doesn't make sense to configure a vault this way but there's no harm in doing so and we don't forbid Spawn, so allow Spend here
h/t @poszu Remove unused DrainedSoFar property Make comment clearer
0a6be48
to
9a26373
Compare
bors merge |
## Motivation Fixes an oversight in genvm implementation: vesting vaults are unable to spend received coins.
Build failed:
|
bors merge |
## Motivation Fixes an oversight in genvm implementation: vesting vaults are unable to spend received coins.
Build failed: |
bors merge |
## Motivation Fixes an oversight in genvm implementation: vesting vaults are unable to spend received coins.
Pull request successfully merged into develop. Build succeeded: |
Motivation
Fixes an oversight in genvm implementation: vesting vaults are unable to spend received coins.
Description
Adds a
Balance()
method to host/context to allow genvm templates to read current account balance, then updates vault spending arithmetic accordingly.Test Plan
Added tests in
genvm/templates/vault/vault_test.go
TODO