-
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
feat: redelegate, undelegate on StakingAccountKit #9331
Conversation
Deploying agoric-sdk with Cloudflare Pages
|
const response = tryDecodeResponse( | ||
result, | ||
MsgDelegateResponse.fromProtoMsg, | ||
); | ||
mustMatch(harden(response), harden({})); // TODO: ignore response?? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we're not returning anything, is decoding the response worthwhile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think so. if it does start returning something this code can continue to ignore it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @turadg, but have wondered if it makes sense to make some of these (empty) response values constants for a quick sanity check - we know that the result string will always be Ei0KKy9jb3Ntb3Muc3Rha2luZy52MWJldGExLk1zZ0RlbGVnYXRlUmVzcG9uc2U=
in the happy path.
trace('MsgBeginRedelegateResponse', response); | ||
// TODO? return completionTime? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spec says to return void
. Do we really want to throw away completionTime
?
product question
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a Cosmos staking kit, I think we can return the Cosmos type. The higher level APIs can be more abstract. They might want to return void or a TimeRecord.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh. based on discussion above, I just re-worked it to ignore the return value altogether.
I hope that's ok.
/** check holder facet against StakingAccountActions interface. FIXME: unused */ | ||
const typeCheck = () => { | ||
/** @import {Guarded, Methods} from '@endo/exo'; */ | ||
/** @type {any} */ | ||
const arg = null; | ||
/** @satisfies { StakingAccountActions } */ | ||
const kit = makeStakingAccountKit(arg, arg, arg, arg, arg).holder; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@turadg do you have any better idea than to keep this and silence the unused warnings?
@@ -18,3 +20,9 @@ export const Proto3Shape = { | |||
}; | |||
|
|||
export const CoinShape = { value: M.bigint(), denom: M.string() }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait... Coin.value
is a bigint? I see strings in a lot of places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the AnyJson
version of Coin
, bigints are cast to strings. It seems this can be removed as we are now returning ChainAmount
. The interface guard for getBalance
should return ChainAmountShape
.
fbe2f1f
to
db56eca
Compare
#9069 says:
Since undelegate returns a completionTime, I didn't need any polling, so I didn't need anything special such as #9067. I presume "redelegate" should be "undelegate" there. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff. @0xpatrickdev and I made some of the same API changes in #9356. Let's consider how to align them.
storageNode, | ||
icqConnection, | ||
// @ts-expect-error only for undelegate, which we do not use | ||
timer: harden({}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it be optional then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems worthwhile to include ChainTimerService
in start-stakeAtom.js
? makeAccount
in StakeAtom
returns a StakingAccountKit
, so it does seem to be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops... missed this one; tending to it now...
* @param {AmountArg} amount | ||
* @returns {Coin} | ||
*/ | ||
amountToCoin(amount) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good enough for now
* @param {CosmosValidatorAddress} dstValidator | ||
* @param {AmountArg} amount | ||
*/ | ||
Redelegate(srcValidator, dstValidator, amount) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since all these makers just map the methods from the holder
, I wonder if we should have some method on the holder to create invitation makers given a zcf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not clear on what you're suggesting.
Making another exoKit seems awkward.
const response = tryDecodeResponse( | ||
result, | ||
MsgDelegateResponse.fromProtoMsg, | ||
); | ||
mustMatch(harden(response), harden({})); // TODO: ignore response?? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think so. if it does start returning something this code can continue to ignore it
trace('MsgBeginRedelegateResponse', response); | ||
// TODO? return completionTime? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a Cosmos staking kit, I think we can return the Cosmos type. The higher level APIs can be more abstract. They might want to return void or a TimeRecord.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
const result = await E(account).executeEncodedTx([ | ||
const result = await E(helper.owned()).executeEncodedTx([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
const response = tryDecodeResponse( | ||
result, | ||
MsgDelegateResponse.fromProtoMsg, | ||
); | ||
mustMatch(harden(response), harden({})); // TODO: ignore response?? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @turadg, but have wondered if it makes sense to make some of these (empty) response values constants for a quick sanity check - we know that the result string will always be Ei0KKy9jb3Ntb3Muc3Rha2luZy52MWJldGExLk1zZ0RlbGVnYXRlUmVzcG9uc2U=
in the happy path.
); | ||
trace('undelegate response', response); | ||
const { completionTime } = response; | ||
const endTime = BigInt(completionTime.valueOf() / 1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is completionTime
a Date
object? Came here to see if there was any nuance in handling this in Jessie
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
completionTime
aDate
object?
yes. I suppose getTime()
would be more clear than valueOf()
.
Came here to see if there was any nuance in handling this in Jessie
only in constructing them, which our code doesn't do.
storageNode, | ||
icqConnection, | ||
// @ts-expect-error only for undelegate, which we do not use | ||
timer: harden({}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems worthwhile to include ChainTimerService
in start-stakeAtom.js
? makeAccount
in StakeAtom
returns a StakingAccountKit
, so it does seem to be used.
|
||
const expect = (actual, expected, message) => { | ||
if (actual !== expected) { | ||
console.log(message, { actual, expected }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not throw an error here?
spec called for no cosmjs types
- stakingAccountKit: - undelegate waits for unbonding time - max clock skew: 10min - factor out helper.amountToCoin - uniform idiom for state, facets - sync types, guards with spec - disable unused-vars on code only for typechecking - avoid decoding discarded responses - staking-ops.test.js: rename from withdraw... - refine test config constant names - WithdrawReward test doesn't depend on Delegate
closes #9069
closes #9070
Description
on StakingAccountHolder, add Redelegate, Undelegate on
invitatationMakers
andredelegate()
,undelegate()
onholder
.refactor to get the
holder
facet to be checked against the orch API:StakingAccountActions
out ofBaseOrchestrationAccount
was DRAFT until:
undelegate()
waits for the unbonding periodDelegation
is cleared upSecurity Considerations
adds a
TimerService
capabilty to each staking account kit.Scaling Considerations
E(timer).wakeAt()
consumes resources in the timer vat for the ~21 day unbonding period.Documentation Considerations
orch API change, already discussed with product:
Promise<void>
(or: widen, depending on how you look at it)Testing Considerations
unit test coverage is reasonable.
I'd like to do more end-to-end testing; should closing #9069 wait for that?
Upgrade Considerations
doesn't use vows. Do we have plans to do that later? Which issue?