Skip to content

Commit

Permalink
feat: redelegate, undelegate on StakingAccountKit (#9331)
Browse files Browse the repository at this point in the history
closes #9069
closes #9070

## Description

on StakingAccountHolder, add Redelegate, Undelegate on
`invitatationMakers` and `redelegate()`, `undelegate()` on `holder`.

refactor to get the `holder` facet to be checked against the orch API:
 - factor `StakingAccountActions` out of `BaseOrchestrationAccount`

was DRAFT until:

 - [x] `undelegate()` waits for the unbonding period
- [x] [spec/types use of cosmos types such as `Delegation` is cleared
up](https://github.com/Agoric/agoric-sdk/pull/9331/files#r1592654234)
 - [x] PR template (description etc.) filled out
 - [x] git history clean-up

### Security 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:
- chore: narrow return type for redelegate to `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?
  • Loading branch information
mergify[bot] authored May 14, 2024
2 parents e4a6095 + 67211a0 commit 9553675
Show file tree
Hide file tree
Showing 7 changed files with 680 additions and 316 deletions.
25 changes: 20 additions & 5 deletions packages/orchestration/src/examples/stakeAtom.contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @file Example contract that uses orchestration
*/
import { makeTracer } from '@agoric/internal';
import { makeTracer, StorageNodeShape } from '@agoric/internal';
import { makeDurableZone } from '@agoric/zone/durable.js';
import { V as E } from '@agoric/vow/vat.js';
import { M } from '@endo/patterns';
Expand All @@ -13,9 +13,20 @@ const trace = makeTracer('StakeAtom');
/**
* @import { Baggage } from '@agoric/vat-data';
* @import { IBCConnectionID } from '@agoric/vats';
* @import { TimerService } from '@agoric/time';
* @import { ICQConnection, OrchestrationService } from '../types.js';
*/

export const meta = harden({
privateArgsShape: {
orchestration: M.remotable('orchestration'),
storageNode: StorageNodeShape,
marshaller: M.remotable('Marshaller'),
timer: M.remotable('TimerService'),
},
});
export const privateArgsShape = meta.privateArgsShape;

/**
* @typedef {{
* hostConnectionId: IBCConnectionID;
Expand All @@ -31,14 +42,15 @@ const trace = makeTracer('StakeAtom');
* orchestration: OrchestrationService;
* storageNode: StorageNode;
* marshaller: Marshaller;
* timer: TimerService;
* }} privateArgs
* @param {Baggage} baggage
*/
export const start = async (zcf, privateArgs, baggage) => {
// TODO #9063 this roughly matches what we'll get from Chain<C>.getChainInfo()
const { hostConnectionId, controllerConnectionId, bondDenom } =
zcf.getTerms();
const { orchestration, marshaller, storageNode } = privateArgs;
const { orchestration, marshaller, storageNode, timer } = privateArgs;

const zone = makeDurableZone(baggage);

Expand All @@ -63,11 +75,14 @@ export const start = async (zcf, privateArgs, baggage) => {
const accountAddress = await E(account).getAddress();
trace('account address', accountAddress);
const { holder, invitationMakers } = makeStakingAccountKit(
account,
storageNode,
accountAddress,
icqConnection,
bondDenom,
{
account,
storageNode,
icqConnection,
timer,
},
);
return {
publicSubscribers: holder.getPublicTopics(),
Expand Down
Loading

0 comments on commit 9553675

Please sign in to comment.