Skip to content

Commit

Permalink
reject unprotected && unwhitelisted action
Browse files Browse the repository at this point in the history
  • Loading branch information
envestcc committed Dec 3, 2024
1 parent 584f187 commit be137d2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions action/sealedenvelope.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,13 @@ func (sealed *SealedEnvelope) VerifySignature() error {
}
return nil
}

// Protected says whether the transaction is replay-protected.
func (sealed *SealedEnvelope) Protected() bool {
switch sealed.encoding {
case iotextypes.Encoding_TX_CONTAINER:
return sealed.Envelope.(*txContainer).tx.Protected()
default:
return sealed.encoding != iotextypes.Encoding_ETHEREUM_UNPROTECTED
}
}
2 changes: 1 addition & 1 deletion api/coreservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ func (core *coreService) SendAction(ctx context.Context, in *iotextypes.Action)
g = core.Genesis()
deployer = selp.SenderAddress()
)
if selp.Encoding() == uint32(iotextypes.Encoding_ETHEREUM_UNPROTECTED) && !g.IsDeployerWhitelisted(deployer) {
if !selp.Protected() && !g.IsDeployerWhitelisted(deployer) {
return "", status.Errorf(codes.InvalidArgument, "replay deployer %v not whitelisted", deployer.Hex())
}

Expand Down
2 changes: 1 addition & 1 deletion state/factory/workingset.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (ws *workingSet) runAction(
}
// for replay tx, check against deployer whitelist
g := genesis.MustExtractGenesisContext(ctx)
if selp.Encoding() == uint32(iotextypes.Encoding_ETHEREUM_UNPROTECTED) && !g.IsDeployerWhitelisted(selp.SenderAddress()) {
if !selp.Protected() && !g.IsDeployerWhitelisted(selp.SenderAddress()) {
return nil, errors.Wrap(errDeployerNotWhitelisted, selp.SenderAddress().String())
}
// Handle action
Expand Down

0 comments on commit be137d2

Please sign in to comment.