Skip to content

Commit 326adf9

Browse files
committed
[context] tolerate empty candidate name
1 parent 7c868d1 commit 326adf9

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

action/protocol/context.go

+11
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ import (
1313
"github.com/ethereum/go-ethereum/core/vm"
1414
"github.com/iotexproject/go-pkgs/hash"
1515
"github.com/iotexproject/iotex-address/address"
16+
"github.com/pkg/errors"
1617

18+
"github.com/iotexproject/iotex-core/v2/action"
1719
"github.com/iotexproject/iotex-core/v2/blockchain/genesis"
1820
"github.com/iotexproject/iotex-core/v2/pkg/log"
1921
)
@@ -123,6 +125,7 @@ type (
123125
FixUnproductiveDelegates bool
124126
CorrectGasRefund bool
125127
SufficentBalanceGuarantee bool
128+
TolerateEmptyCandidateName bool
126129
SkipSystemActionNonce bool
127130
ValidateSystemAction bool
128131
AllowCorrectChainIDOnly bool
@@ -280,6 +283,7 @@ func WithFeatureCtx(ctx context.Context) context.Context {
280283
FixUnproductiveDelegates: g.IsOkhotsk(height),
281284
CorrectGasRefund: g.IsOkhotsk(height),
282285
SufficentBalanceGuarantee: g.IsOkhotsk(height),
286+
TolerateEmptyCandidateName: !g.IsPalau(height),
283287
SkipSystemActionNonce: g.IsPalau(height),
284288
ValidateSystemAction: g.IsQuebec(height),
285289
AllowCorrectChainIDOnly: g.IsQuebec(height),
@@ -307,6 +311,13 @@ func WithFeatureCtx(ctx context.Context) context.Context {
307311
)
308312
}
309313

314+
func (fCtx *FeatureCtx) Tolerate(err error) bool {
315+
if fCtx.TolerateEmptyCandidateName && errors.Cause(err) == action.ErrInvalidCanName {
316+
return true
317+
}
318+
return false
319+
}
320+
310321
// GetFeatureCtx gets FeatureCtx.
311322
func GetFeatureCtx(ctx context.Context) (FeatureCtx, bool) {
312323
fc, ok := ctx.Value(featureContextKey{}).(FeatureCtx)

action/protocol/generic_validator.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ func (v *GenericValidator) Validate(ctx context.Context, selp *action.SealedEnve
5858
if caller == nil {
5959
return errors.New("failed to get address")
6060
}
61-
if err = selp.Envelope.SanityCheck(); err != nil {
61+
featureCtx := MustGetFeatureCtx(ctx)
62+
if err = selp.Envelope.SanityCheck(); err != nil && !featureCtx.Tolerate(err) {
6263
return err
6364
}
6465
// Reject action if nonce is too low
@@ -67,10 +68,7 @@ func (v *GenericValidator) Validate(ctx context.Context, selp *action.SealedEnve
6768
return action.ErrSystemActionNonce
6869
}
6970
} else {
70-
var (
71-
nonce uint64
72-
featureCtx = MustGetFeatureCtx(ctx)
73-
)
71+
var nonce uint64
7472
if featureCtx.FixGasAndNonceUpdate || selp.Nonce() != 0 {
7573
confirmedState, err := v.accountState(ctx, v.sr, caller)
7674
if err != nil {

0 commit comments

Comments
 (0)