Rename StateReplay to StateTransplant

This commit is contained in:
Aayush Rajasekaran 2020-10-15 19:14:53 -04:00
parent cb801d47c7
commit 7826cc0bab
5 changed files with 15 additions and 26 deletions

View File

@ -320,8 +320,8 @@ type FullNode interface {
// StateCall runs the given message and returns its result without any persisted changes.
StateCall(context.Context, *types.Message, types.TipSetKey) (*InvocResult, error)
// StateReplay returns the result of executing the indicated message, assuming it was executed in the indicated tipset.
StateReplay(context.Context, types.TipSetKey, cid.Cid) (*InvocResult, error)
// StateTransplant returns the result of executing the indicated message, assuming it was executed in the indicated tipset.
StateTransplant(context.Context, types.TipSetKey, cid.Cid) (*InvocResult, error)
// StateGetActor returns the indicated actor's nonce and balance.
StateGetActor(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.Actor, error)
// StateReadState returns the indicated actor's state.

View File

@ -188,7 +188,7 @@ type FullNodeStruct struct {
StateSectorExpiration func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorExpiration, error) `perm:"read"`
StateSectorPartition func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorLocation, error) `perm:"read"`
StateCall func(context.Context, *types.Message, types.TipSetKey) (*api.InvocResult, error) `perm:"read"`
StateReplay func(context.Context, types.TipSetKey, cid.Cid) (*api.InvocResult, error) `perm:"read"`
StateTransplant func(context.Context, types.TipSetKey, cid.Cid) (*api.InvocResult, error) `perm:"read"`
StateGetActor func(context.Context, address.Address, types.TipSetKey) (*types.Actor, error) `perm:"read"`
StateReadState func(context.Context, address.Address, types.TipSetKey) (*api.ActorState, error) `perm:"read"`
StateMsgGasCost func(context.Context, cid.Cid, types.TipSetKey) (*api.MsgGasCost, error) `perm:"read"`
@ -880,8 +880,8 @@ func (c *FullNodeStruct) StateCall(ctx context.Context, msg *types.Message, tsk
return c.Internal.StateCall(ctx, msg, tsk)
}
func (c *FullNodeStruct) StateReplay(ctx context.Context, tsk types.TipSetKey, mc cid.Cid) (*api.InvocResult, error) {
return c.Internal.StateReplay(ctx, tsk, mc)
func (c *FullNodeStruct) StateTransplant(ctx context.Context, tsk types.TipSetKey, mc cid.Cid) (*api.InvocResult, error) {
return c.Internal.StateTransplant(ctx, tsk, mc)
}
func (c *FullNodeStruct) StateGetActor(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.Actor, error) {

View File

@ -60,7 +60,7 @@ var stateCmd = &cli.Command{
stateSectorCmd,
stateGetActorCmd,
stateLookupIDCmd,
stateReplaySetCmd,
stateTransplantCmd,
stateSectorSizeCmd,
stateReadStateCmd,
stateListMessagesCmd,
@ -384,9 +384,9 @@ var stateExecTraceCmd = &cli.Command{
},
}
var stateReplaySetCmd = &cli.Command{
Name: "replay",
Usage: "Replay a particular message within a tipset",
var stateTransplantCmd = &cli.Command{
Name: "transplant",
Usage: "Play a particular message within a tipset",
ArgsUsage: "[tipsetKey messageCid]",
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() < 1 {
@ -437,30 +437,19 @@ var stateReplaySetCmd = &cli.Command{
return err
}
} else {
var r *api.MsgLookup
r, err = fapi.StateWaitMsg(ctx, mcid, build.MessageConfidence)
if err != nil {
return xerrors.Errorf("finding message in chain: %w", err)
}
childTs, err := fapi.ChainGetTipSet(ctx, r.TipSet)
if err != nil {
return xerrors.Errorf("loading tipset: %w", err)
}
ts, err = fapi.ChainGetTipSet(ctx, childTs.Parents())
ts, err = fapi.ChainHead(ctx)
if err != nil {
return err
}
}
}
res, err := fapi.StateReplay(ctx, ts.Key(), mcid)
res, err := fapi.StateTransplant(ctx, ts.Key(), mcid)
if err != nil {
return xerrors.Errorf("replay call failed: %w", err)
return xerrors.Errorf("transplant call failed: %w", err)
}
fmt.Println("Replay receipt:")
fmt.Println("Transplant receipt:")
fmt.Printf("Exit code: %d\n", res.MsgRct.ExitCode)
fmt.Printf("Return: %x\n", res.MsgRct.Return)
fmt.Printf("Gas Used: %d\n", res.MsgRct.GasUsed)

View File

@ -26,7 +26,7 @@ class Block extends React.Component {
messages = await Promise.all(messages.map(async (msg, i) => {
if (msg.receipt.ExitCode !== 0) {
let reply = await this.props.conn.call('Filecoin.StateReplay', [{Cids: [this.props.cid], Blocks: [header], Height: header.Height}, msg.Cid])
let reply = await this.props.conn.call('Filecoin.StateTransplant', [{Cids: [this.props.cid], Blocks: [header], Height: header.Height}, msg.Cid])
if(!reply.Error) {
reply.Error = "reply: no error"
}

View File

@ -346,7 +346,7 @@ func (a *StateAPI) StateCall(ctx context.Context, msg *types.Message, tsk types.
return res, err
}
func (a *StateAPI) StateReplay(ctx context.Context, tsk types.TipSetKey, mc cid.Cid) (*api.InvocResult, error) {
func (a *StateAPI) StateTransplant(ctx context.Context, tsk types.TipSetKey, mc cid.Cid) (*api.InvocResult, error) {
ts, err := a.Chain.GetTipSetFromKey(tsk)
if err != nil {
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)