From 7fecaf4b4d4e11eeabd8fb1849822d1ad162bddc Mon Sep 17 00:00:00 2001 From: jiangpeng <11565373+bysomeone@users.noreply.github.com> Date: Tue, 29 Nov 2022 15:07:57 +0800 Subject: [PATCH] [[FIX]] add evm mix address fork --- chain33.fork.toml | 2 ++ chain33.para.toml | 2 ++ chain33.para.toml.readme | 1 + plugin/dapp/evm/executor/exec.go | 10 +++++++--- plugin/dapp/evm/types/evm.go | 1 + plugin/dapp/evm/types/types.go | 2 ++ 6 files changed, 15 insertions(+), 3 deletions(-) diff --git a/chain33.fork.toml b/chain33.fork.toml index b33f6b98ca..a282671e05 100644 --- a/chain33.fork.toml +++ b/chain33.fork.toml @@ -77,6 +77,8 @@ ForkEVMFrozen=1300000 ForkEVMYoloV1=9500000 # EVM合约支持交易组 ForkEVMTxGroup=0 +# EVM兼容base58及16进制地址混合调用处理 +ForkEVMMixAddress=0 [fork.sub.evmxgo] Enable=0 diff --git a/chain33.para.toml b/chain33.para.toml index 5dfd9c7b88..ba90eababb 100644 --- a/chain33.para.toml +++ b/chain33.para.toml @@ -360,6 +360,8 @@ ForkEVMFrozen=0 ForkEVMKVHash=0 ForkEVMYoloV1=0 ForkEVMTxGroup=0 +# EVM兼容base58及16进制地址混合调用处理 +ForkEVMMixAddress=0 [fork.sub.blackwhite] Enable=0 diff --git a/chain33.para.toml.readme b/chain33.para.toml.readme index 0815b0cbd9..42d3b91c11 100644 --- a/chain33.para.toml.readme +++ b/chain33.para.toml.readme @@ -329,6 +329,7 @@ ForkEVMFrozen=0 ForkEVMKVHash=0 ForkEVMYoloV1=0 ForkEVMTxGroup=0 +ForkEVMMixAddress=0 [fork.sub.blackwhite] Enable=0 diff --git a/plugin/dapp/evm/executor/exec.go b/plugin/dapp/evm/executor/exec.go index 414f5c4ea9..67a1b0d210 100644 --- a/plugin/dapp/evm/executor/exec.go +++ b/plugin/dapp/evm/executor/exec.go @@ -279,7 +279,8 @@ func (evm *EVMExecutor) GetMessage(tx *types.Transaction, index int, fromPtr *co from = *fromPtr } - to := getReceiver(&action) + addressFork := evm.GetAPI().GetConfig().IsDappFork(evm.GetHeight(), "evm", evmtypes.ForkEVMMixAddress) + to := getReceiver(&action, addressFork) if to == nil { return msg, types.ErrInvalidAddress } @@ -365,9 +366,12 @@ func getCaller(tx *types.Transaction) common.Address { } // 从交易信息中获取交易目标地址,在创建合约交易中,此地址为空 -func getReceiver(action *evmtypes.EVMContractAction) *common.Address { +func getReceiver(action *evmtypes.EVMContractAction, addressFork bool) *common.Address { if action.ContractAddr == "" { return nil } - return common.StringToAddress(action.ContractAddr) + if addressFork { + common.StringToAddress(action.ContractAddr) + } + return common.StringToAddressLegacy(action.ContractAddr) } diff --git a/plugin/dapp/evm/types/evm.go b/plugin/dapp/evm/types/evm.go index c502b1e360..92d350454d 100644 --- a/plugin/dapp/evm/types/evm.go +++ b/plugin/dapp/evm/types/evm.go @@ -42,6 +42,7 @@ func InitFork(cfg *types.Chain33Config) { cfg.RegisterDappFork(ExecutorName, ForkEVMYoloV1, 0) // EVM合约支持交易组 cfg.RegisterDappFork(ExecutorName, ForkEVMTxGroup, 0) + cfg.RegisterDappFork(ExecutorName, ForkEVMMixAddress, 0) } //InitExecutor ... diff --git a/plugin/dapp/evm/types/types.go b/plugin/dapp/evm/types/types.go index 6da120ebaf..7f09c2055e 100644 --- a/plugin/dapp/evm/types/types.go +++ b/plugin/dapp/evm/types/types.go @@ -46,6 +46,8 @@ const ( ForkEVMYoloV1 = "ForkEVMYoloV1" //ForkEVMTxGroup 交易组中的交易通过GAS检查 ForkEVMTxGroup = "ForkEVMTxGroup" + // ForkEVMMixAddress evm同时兼容base58及16进制地址混合调用处理 + ForkEVMMixAddress = "ForkEVMMixAddress" ) var (