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

[api] Fix not reject unprotected && unwhitelisted action #4510

Merged
merged 2 commits into from
Dec 3, 2024
Merged
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
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()) {
Copy link
Member Author

Choose a reason for hiding this comment

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

The behavior has not actually changed because the encoding here will not be the Encoding_TX_CONTAINER, so a hardfork is not needed.

return nil, errors.Wrap(errDeployerNotWhitelisted, selp.SenderAddress().String())
}
// Handle action
Expand Down
Loading