Skip to content
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
24 changes: 24 additions & 0 deletions action/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,27 @@ func CheckTransferAddress(act Action) error {
}
return nil
}

func CheckSpecialAddress(act Action) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to ContainsSpecialAddress. Add comment

switch act := act.(type) {
case *Transfer:
return address.IsAddrV1Special(act.recipient)
case *Execution:
return address.IsAddrV1Special(act.contract)
case *CandidateRegister:
return address.IsAddrV1Special(act.rewardAddress.String()) ||
address.IsAddrV1Special(act.operatorAddress.String()) ||
(act.ownerAddress != nil && address.IsAddrV1Special(act.ownerAddress.String()))
case *CandidateUpdate:
return (act.rewardAddress != nil && address.IsAddrV1Special(act.rewardAddress.String())) ||
(act.operatorAddress != nil && address.IsAddrV1Special(act.operatorAddress.String()))
case *CandidateTransferOwnership:
return address.IsAddrV1Special(act.newOwner.String())
case *TransferStake:
return address.IsAddrV1Special(act.voterAddress.String())
case *ClaimFromRewardingFund:
return act.address != nil && address.IsAddrV1Special(act.address.String())
default:
return false
}
}
1 change: 1 addition & 0 deletions action/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var (
ErrGasTipOverFeeCap = errors.New("tip cap is greater than fee cap")
ErrMissRequiredField = errors.New("missing required field")
ErrValueVeryHigh = errors.New("value is very high")
ErrSpecialAddress = errors.New("special address not allowed")
)

// LoadErrorDescription loads corresponding description related to the error
Expand Down
2 changes: 2 additions & 0 deletions action/protocol/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ type (
VerifyNotContainerBeforeRun bool
ValidateActionWithState bool
CheckStakingDurationUpperLimit bool
DisallowSpecialAddressInTx bool
FixRevertSnapshot bool
}

Expand Down Expand Up @@ -316,6 +317,7 @@ func WithFeatureCtx(ctx context.Context) context.Context {
VerifyNotContainerBeforeRun: g.IsVanuatu(height),
ValidateActionWithState: g.IsVanuatu(height),
CheckStakingDurationUpperLimit: g.IsVanuatu(height),
DisallowSpecialAddressInTx: g.IsVanuatu(height),
FixRevertSnapshot: g.IsVanuatu(height),
},
)
Expand Down
3 changes: 3 additions & 0 deletions action/protocol/generic_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ func (v *GenericValidator) Validate(ctx context.Context, selp *action.SealedEnve
return action.ErrNonceTooLow
}
}
if featureCtx.DisallowSpecialAddressInTx && action.CheckSpecialAddress(selp.Action()) {
return action.ErrSpecialAddress
}
if !featureCtx.EnableAccessListTx && selp.TxType() == action.AccessListTxType {
return errors.Wrap(action.ErrInvalidAct, "access list tx is not enabled")
}
Expand Down
10 changes: 10 additions & 0 deletions e2etest/blobtx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ func TestBlobTx(t *testing.T) {
r.Equal(act.BlobTxSidecar(), blobs[0].BlobSidecar)
}}},
},
{
name: "reject special address",
act: &actionWithTime{
mustNoErr(action.Sign(action.NewEnvelope(newBlobTx(test.nonceMgr[(sender)], nil, []common.Hash{{}}), action.NewTransfer(big.NewInt(1), address.StakingBucketPoolAddr, nil)), senderSK)),
time.Now(),
},
expect: []actionExpect{&functionExpect{func(test *e2etest, act *action.SealedEnvelope, receipt *action.Receipt, err error) {
r.ErrorIs(err, action.ErrSpecialAddress)
}}},
},
{
name: "6 blobs per block at most",
acts: []*actionWithTime{
Expand Down
Loading