Skip to content

Commit

Permalink
feat(shed): gas-sim compact-sectors
Browse files Browse the repository at this point in the history
* simulate a CompactSectors prior to a miner message
* improve gas table printing and handling
  • Loading branch information
rvagg committed Jan 21, 2025
1 parent 30ca496 commit 254daf0
Show file tree
Hide file tree
Showing 7 changed files with 400 additions and 133 deletions.
16 changes: 11 additions & 5 deletions chain/stmgr/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
type execMessageStrategy int

const (
execNoMessages execMessageStrategy = iota // apply no prior or current tipset messages
execNoMessages execMessageStrategy = iota // apply no prior or current tipset messages unless supplied
execAllMessages // apply all prior and current tipset messages
execSameSenderMessages // apply all prior messages and any current tipset messages from the same sender
)
Expand Down Expand Up @@ -60,8 +60,8 @@ func (sm *StateManager) Call(ctx context.Context, msg *types.Message, ts *types.
}

// ApplyOnStateWithGas applies the given message on top of the given state root with gas tracing enabled
func (sm *StateManager) ApplyOnStateWithGas(ctx context.Context, stateCid cid.Cid, msg *types.Message, ts *types.TipSet) (*api.InvocResult, error) {
return sm.callInternal(ctx, msg, nil, ts, stateCid, sm.GetNetworkVersion, true, execNoMessages)
func (sm *StateManager) ApplyOnStateWithGas(ctx context.Context, stateCid cid.Cid, msg *types.Message, priorMsgs []types.ChainMsg, ts *types.TipSet) (*api.InvocResult, error) {
return sm.callInternal(ctx, msg, priorMsgs, ts, stateCid, sm.GetNetworkVersion, true, execNoMessages)
}

// CallWithGas calculates the state for a given tipset, and then applies the given message on top of that state.
Expand Down Expand Up @@ -174,7 +174,7 @@ func (sm *StateManager) callInternal(ctx context.Context, msg *types.Message, pr

switch strategy {
case execNoMessages:
// Do nothing
// Do nothing, unless we have prior messages to apply
case execAllMessages, execSameSenderMessages:
tsMsgs, err := sm.cs.MessagesForTipset(ctx, ts)
if err != nil {
Expand All @@ -190,13 +190,19 @@ func (sm *StateManager) callInternal(ctx context.Context, msg *types.Message, pr
filteredTsMsgs = append(filteredTsMsgs, tsMsg)
}
}
log.Debugf("applying %d additional messages from same sender", len(filteredTsMsgs))
priorMsgs = append(filteredTsMsgs, priorMsgs...)
}
}

if len(priorMsgs) > 0 {
for i, m := range priorMsgs {
_, err = vmi.ApplyMessage(ctx, m)
ret, err := vmi.ApplyMessage(ctx, m)
if err != nil {
return nil, xerrors.Errorf("applying prior message (%d, %s): %w", i, m.Cid(), err)
}
// TODO: return this information to the caller
log.Debugf("applied prior message %s: %d [%x]: %s", m.Cid(), ret.MessageReceipt.ExitCode, ret.MessageReceipt.Return, ret.ActorErr)
}

// We flush to get the VM's view of the state tree after applying the above messages
Expand Down
Loading

0 comments on commit 254daf0

Please sign in to comment.