Skip to content
This repository was archived by the owner on Apr 4, 2024. It is now read-only.

Commit 8e2c652

Browse files
authored
imp(evm): rename RejectUnprotectedTx to AllowUnprotectedTxs (#1142)
* imp(evm): rename RejectUnprotectedTx to AllowUnprotectedTxs * changelog
1 parent 3b852f7 commit 8e2c652

File tree

26 files changed

+947
-2272
lines changed

26 files changed

+947
-2272
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
5050

5151
### Improvements
5252

53+
* (evm) [\#1142](https://github.com/evmos/ethermint/pull/1142) Rename `RejectUnprotectedTx` to `AllowUnprotectedTxs` for consistency with go-ethereum.
5354
* (feemarket) [tharsis#1120](https://github.com/evmos/ethermint/pull/1120) Make `min-gas-multiplier` parameter accept zero value
5455

5556
### Bug Fixes

Makefile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ ETHERMINT_DIR = ethermint
1212
BUILDDIR ?= $(CURDIR)/build
1313
SIMAPP = ./app
1414
HTTPS_GIT := https://github.com/evmos/ethermint.git
15+
PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git)
1516
DOCKER := $(shell which docker)
16-
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
17+
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf:1.0.0-rc8
1718

1819
export GO111MODULE = on
1920

@@ -403,17 +404,18 @@ format-fix:
403404
### Protobuf ###
404405
###############################################################################
405406

406-
containerProtoVer=v0.2
407-
containerProtoImage=tendermintdev/sdk-proto-gen:$(containerProtoVer)
408-
containerProtoGen=cosmos-sdk-proto-gen-$(containerProtoVer)
409-
containerProtoGenSwagger=cosmos-sdk-proto-gen-swagger-$(containerProtoVer)
410-
containerProtoFmt=cosmos-sdk-proto-fmt-$(containerProtoVer)
407+
protoVer=v0.2
408+
protoImageName=tendermintdev/sdk-proto-gen:$(protoVer)
409+
containerProtoGen=$(PROJECT_NAME)-proto-gen-$(protoVer)
410+
containerProtoGenAny=$(PROJECT_NAME)-proto-gen-any-$(protoVer)
411+
containerProtoGenSwagger=$(PROJECT_NAME)-proto-gen-swagger-$(protoVer)
412+
containerProtoFmt=$(PROJECT_NAME)-proto-fmt-$(protoVer)
411413

412414
proto-all: proto-format proto-lint proto-gen
413415

414416
proto-gen:
415417
@echo "Generating Protobuf files"
416-
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGen}$$"; then docker start -a $(containerProtoGen); else docker run --name $(containerProtoGen) -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) \
418+
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGen}$$"; then docker start -a $(containerProtoGen); else docker run --name $(containerProtoGen) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \
417419
sh ./scripts/protocgen.sh; fi
418420

419421
proto-swagger-gen:

app/ante/eth.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ func (esvd EthSigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, s
5151
}
5252

5353
ethTx := msgEthTx.AsTransaction()
54-
if params.RejectUnprotectedTx && !ethTx.Protected() {
55-
return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "eth tx is not replay-protected")
54+
if !params.AllowUnprotectedTxs && !ethTx.Protected() {
55+
return ctx, sdkerrors.Wrapf(
56+
sdkerrors.ErrNotSupported,
57+
"rejected unprotected Ethereum txs. Please EIP155 sign your transaction to protect it against replay-attacks")
5658
}
5759

5860
sender, err := signer.Sender(ethTx)

app/ante/eth_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,28 @@ func (suite AnteTestSuite) TestEthSigVerificationDecorator() {
3030
testCases := []struct {
3131
name string
3232
tx sdk.Tx
33-
rejectUnprotectedTx bool
33+
allowUnprotectedTxs bool
3434
reCheckTx bool
3535
expPass bool
3636
}{
37-
{"ReCheckTx", &invalidTx{}, true, true, false},
38-
{"invalid transaction type", &invalidTx{}, true, false, false},
37+
{"ReCheckTx", &invalidTx{}, false, true, false},
38+
{"invalid transaction type", &invalidTx{}, false, false, false},
3939
{
4040
"invalid sender",
4141
evmtypes.NewTx(suite.app.EvmKeeper.ChainID(), 1, &addr, big.NewInt(10), 1000, big.NewInt(1), nil, nil, nil, nil),
4242
true,
4343
false,
4444
false,
4545
},
46-
{"successful signature verification", signedTx, true, false, true},
47-
{"invalid, not replay-protected", unprotectedTx, true, false, false},
48-
{"successful, don't reject unprotected", unprotectedTx, false, false, true},
46+
{"successful signature verification", signedTx, false, false, true},
47+
{"invalid, reject unprotected txs", unprotectedTx, false, false, false},
48+
{"successful, allow unprotected txs", unprotectedTx, true, false, true},
4949
}
5050

5151
for _, tc := range testCases {
5252
suite.Run(tc.name, func() {
5353
suite.evmParamsOption = func(params *evmtypes.Params) {
54-
params.RejectUnprotectedTx = tc.rejectUnprotectedTx
54+
params.AllowUnprotectedTxs = tc.allowUnprotectedTxs
5555
}
5656
suite.SetupTest()
5757
dec := ante.NewEthSigVerificationDecorator(suite.app.EvmKeeper)

app/ante/utils_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (suite *AnteTestSuite) SetupTest() {
7676
genesis[feemarkettypes.ModuleName] = app.AppCodec().MustMarshalJSON(feemarketGenesis)
7777
}
7878
evmGenesis := evmtypes.DefaultGenesisState()
79-
evmGenesis.Params.RejectUnprotectedTx = true
79+
evmGenesis.Params.AllowUnprotectedTxs = false
8080
if !suite.enableLondonHF {
8181
maxInt := sdk.NewInt(math.MaxInt64)
8282
evmGenesis.Params.ChainConfig.LondonBlock = &maxInt

client/docs/statik/statik.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)