Skip to content
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

[protocol] verify container format always #4542

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions action/protocol/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,14 @@ type (
SuicideTxLogMismatchPanic bool
PanicUnrecoverableError bool
CandidateIdentifiedByOwner bool
UseTxContainer bool
LimitedStakingContract bool
MigrateNativeStake bool
AddClaimRewardAddress bool
EnforceLegacyEndorsement bool
EnableDynamicFeeTx bool
EnableBlobTransaction bool
EnableCancunEVM bool
UnfoldContainerBeforeValidate bool
UnstakedButNotClearSelfStakeAmount bool
VerifyNotContainerBeforeRun bool
CheckStakingDurationUpperLimit bool
FixRevertSnapshot bool
}
Expand Down Expand Up @@ -294,17 +291,14 @@ func WithFeatureCtx(ctx context.Context) context.Context {
SuicideTxLogMismatchPanic: g.IsUpernavik(height),
PanicUnrecoverableError: g.IsUpernavik(height),
CandidateIdentifiedByOwner: !g.IsUpernavik(height),
UseTxContainer: g.IsUpernavik(height),
LimitedStakingContract: !g.IsUpernavik(height),
MigrateNativeStake: g.IsUpernavik(height),
AddClaimRewardAddress: g.IsUpernavik(height),
EnforceLegacyEndorsement: !g.IsUpernavik(height),
EnableDynamicFeeTx: g.IsVanuatu(height),
EnableBlobTransaction: g.IsVanuatu(height),
EnableCancunEVM: g.IsVanuatu(height),
UnfoldContainerBeforeValidate: g.IsVanuatu(height),
UnstakedButNotClearSelfStakeAmount: !g.IsVanuatu(height),
VerifyNotContainerBeforeRun: g.IsVanuatu(height),
CheckStakingDurationUpperLimit: g.IsVanuatu(height),
FixRevertSnapshot: g.IsVanuatu(height),
},
Expand Down
26 changes: 8 additions & 18 deletions state/factory/workingset.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,8 @@ func (ws *workingSet) runAction(
return nil, err
}
}
fCtx := protocol.MustGetFeatureCtx(ctx)
// if it's a tx container, unfold the tx inside
if fCtx.UseTxContainer && !fCtx.UnfoldContainerBeforeValidate {
if container, ok := selp.Envelope.(action.TxContainer); ok {
if err := container.Unfold(selp, ctx, ws.checkContract); err != nil {
return nil, errors.Wrap(errUnfoldTxContainer, err.Error())
}
}
}
// verify the tx is not container format (unfolded correctly)
if fCtx.VerifyNotContainerBeforeRun && selp.Encoding() == uint32(iotextypes.Encoding_TX_CONTAINER) {
if selp.Encoding() == uint32(iotextypes.Encoding_TX_CONTAINER) {
return nil, errors.Wrap(action.ErrInvalidAct, "cannot run tx container without unfolding")
}
// for replay tx, check against deployer whitelist
Expand All @@ -182,6 +173,7 @@ func (ws *workingSet) runAction(
if err := ws.freshAccountConversion(ctx, &actCtx); err != nil {
return nil, err
}
fCtx := protocol.MustGetFeatureCtx(ctx)
for _, actionHandler := range reg.All() {
receipt, err := actionHandler.Handle(ctx, selp.Envelope, ws)
if err != nil {
Expand Down Expand Up @@ -630,14 +622,12 @@ func (ws *workingSet) pickAndRunActions(
actionIterator.PopAccount()
continue
}
if fCtx.UnfoldContainerBeforeValidate {
if container, ok := nextAction.Envelope.(action.TxContainer); ok {
if err := container.Unfold(nextAction, ctx, ws.checkContract); err != nil {
log.L().Debug("failed to unfold tx container", zap.Uint64("height", ws.height), zap.Error(err))
ap.DeleteAction(nextAction.SenderAddress())
actionIterator.PopAccount()
continue
}
if container, ok := nextAction.Envelope.(action.TxContainer); ok {
if err := container.Unfold(nextAction, ctx, ws.checkContract); err != nil {
log.L().Debug("failed to unfold tx container", zap.Uint64("height", ws.height), zap.Error(err))
ap.DeleteAction(nextAction.SenderAddress())
actionIterator.PopAccount()
continue
}
}
if err := ws.txValidator.ValidateWithState(ctxWithBlockContext, nextAction); err != nil {
Expand Down
Loading