Skip to content

Commit d9a7db2

Browse files
envestccdustinxie
authored andcommitted
reject unprotected && unwhitelisted action (#4510)
1 parent f22febe commit d9a7db2

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

action/sealedenvelope.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,13 @@ func (sealed *SealedEnvelope) VerifySignature() error {
242242
}
243243
return nil
244244
}
245+
246+
// Protected says whether the transaction is replay-protected.
247+
func (sealed *SealedEnvelope) Protected() bool {
248+
switch sealed.encoding {
249+
case iotextypes.Encoding_TX_CONTAINER:
250+
return sealed.Envelope.(*txContainer).tx.Protected()
251+
default:
252+
return sealed.encoding != iotextypes.Encoding_ETHEREUM_UNPROTECTED
253+
}
254+
}

api/coreservice.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ func (core *coreService) SendAction(ctx context.Context, in *iotextypes.Action)
462462
g = core.Genesis()
463463
deployer = selp.SenderAddress()
464464
)
465-
if selp.Encoding() == uint32(iotextypes.Encoding_ETHEREUM_UNPROTECTED) && !g.IsDeployerWhitelisted(deployer) {
465+
if !selp.Protected() && !g.IsDeployerWhitelisted(deployer) {
466466
return "", status.Errorf(codes.InvalidArgument, "replay deployer %v not whitelisted", deployer.Hex())
467467
}
468468

state/factory/workingset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func (ws *workingSet) runAction(
194194
}
195195
// for replay tx, check against deployer whitelist
196196
g := genesis.MustExtractGenesisContext(ctx)
197-
if selp.Encoding() == uint32(iotextypes.Encoding_ETHEREUM_UNPROTECTED) && !g.IsDeployerWhitelisted(selp.SenderAddress()) {
197+
if !selp.Protected() && !g.IsDeployerWhitelisted(selp.SenderAddress()) {
198198
return nil, errors.Wrap(errDeployerNotWhitelisted, selp.SenderAddress().String())
199199
}
200200
// Handle action

0 commit comments

Comments
 (0)