This repository has been archived by the owner on Aug 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
test: actor abort #118
Merged
Merged
test: actor abort #118
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c90e874
test: wip actor abort
alanshaw 0bdf53e
feat: wip actor abort with different error codes
7ff4dbd
feat: test all system codes
9235f52
feat: null receipts
522e15f
fix: dependencies
8061144
fix: fallout from chaos move
4d5f398
fix: not always have result
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,7 +103,7 @@ func (b *MessageVectorBuilder) CommitApplies() { | |
|
||
for _, am := range b.Messages.All() { | ||
// apply all messages that are pending application. | ||
if am.Result == nil { | ||
if !am.Applied { | ||
b.StateTracker.ApplyMessage(am) | ||
} | ||
|
||
|
@@ -112,19 +112,24 @@ func (b *MessageVectorBuilder) CommitApplies() { | |
Bytes: MustSerialize(am.Message), | ||
Epoch: &epoch, | ||
}) | ||
b.vector.Post.Receipts = append(b.vector.Post.Receipts, &schema.Receipt{ | ||
ExitCode: int64(am.Result.ExitCode), | ||
ReturnValue: am.Result.Return, | ||
GasUsed: am.Result.GasUsed, | ||
}) | ||
|
||
// am.Result may still be nil if the message failed to be applied | ||
if am.Result != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe a more idiomatic way of doing this would be: var receipt *schema.Receipt
if am.Result != nil {
receipt = &schema.Receipt{
ExitCode: int64(am.Result.ExitCode),
ReturnValue: am.Result.Return,
GasUsed: am.Result.GasUsed,
}
}
b.vector.Post.Receipts = append(b.vector.Post.Receipts, receipt) |
||
b.vector.Post.Receipts = append(b.vector.Post.Receipts, &schema.Receipt{ | ||
ExitCode: int64(am.Result.ExitCode), | ||
ReturnValue: am.Result.Return, | ||
GasUsed: am.Result.GasUsed, | ||
}) | ||
} else { | ||
b.vector.Post.Receipts = append(b.vector.Post.Receipts, nil) | ||
} | ||
} | ||
|
||
// update the internal state. | ||
b.PostRoot = b.StateTracker.CurrRoot | ||
b.vector.Post.StateTree = &schema.StateTree{RootCID: b.PostRoot} | ||
b.Stage = StageChecks | ||
b.Assert.enterStage(StageChecks) | ||
|
||
} | ||
|
||
// Finish signals to the builder that the checks stage is complete and that the | ||
|
@@ -146,8 +151,10 @@ func (b *MessageVectorBuilder) Finish(w io.Writer) { | |
|
||
msgs := b.Messages.All() | ||
traces := make([]types.ExecutionTrace, 0, len(msgs)) | ||
for _, msgs := range msgs { | ||
traces = append(traces, msgs.Result.ExecutionTrace) | ||
for _, msg := range msgs { | ||
if msg.Result != nil { | ||
traces = append(traces, msg.Result.ExecutionTrace) | ||
} | ||
Comment on lines
153
to
+157
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we want to make the traces a slice of pointers |
||
} | ||
b.vector.Diagnostics = EncodeTraces(traces) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/filecoin-project/go-address" | ||
"github.com/filecoin-project/go-state-types/abi" | ||
"github.com/filecoin-project/go-state-types/big" | ||
"github.com/filecoin-project/go-state-types/exitcode" | ||
"github.com/filecoin-project/lotus/conformance/chaos" | ||
|
||
. "github.com/filecoin-project/test-vectors/gen/builders" | ||
) | ||
|
||
func actorAbort(abortCode exitcode.ExitCode, msg string, expectedCode exitcode.ExitCode) func(*MessageVectorBuilder) { | ||
return func(v *MessageVectorBuilder) { | ||
v.Messages.SetDefaults(GasLimit(1_000_000_000), GasPremium(1), GasFeeCap(200)) | ||
|
||
sender := v.Actors.Account(address.SECP256K1, abi.NewTokenAmount(1_000_000_000_000)) | ||
v.CommitPreconditions() | ||
|
||
v.Messages.Raw( | ||
sender.ID, | ||
chaos.Address, | ||
chaos.MethodAbort, | ||
MustSerialize(&chaos.AbortArgs{Code: abortCode, Message: msg}), | ||
Value(big.Zero()), | ||
Nonce(0), | ||
) | ||
v.CommitApplies() | ||
|
||
v.Assert.LastMessageResultSatisfies(ExitCode(expectedCode)) | ||
} | ||
} | ||
|
||
func actorPanic(msg string) func(*MessageVectorBuilder) { | ||
return func(v *MessageVectorBuilder) { | ||
v.Messages.SetDefaults(GasLimit(1_000_000_000), GasPremium(1), GasFeeCap(200)) | ||
|
||
sender := v.Actors.Account(address.SECP256K1, abi.NewTokenAmount(1_000_000_000_000)) | ||
v.CommitPreconditions() | ||
|
||
v.Messages.Raw( | ||
sender.ID, | ||
chaos.Address, | ||
chaos.MethodAbort, | ||
MustSerialize(&chaos.AbortArgs{NoCode: true, Message: msg}), | ||
Value(big.Zero()), | ||
Nonce(0), | ||
) | ||
v.CommitApplies() | ||
|
||
v.Assert.LastMessageResultSatisfies(Nil()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nice, this is a lot more explicit.