From 1d313ffe2d70587f04c749b79dec409532e7a0f2 Mon Sep 17 00:00:00 2001 From: niuxiaojie81 <85773309@qq.com> Date: Thu, 7 Apr 2022 10:56:10 +0800 Subject: [PATCH 1/3] ChainId is the PIP-7 replay-protection chain id for the current chain config --- internal/ethapi/api.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index bb7e53687d..a9a16649ec 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -21,6 +21,7 @@ import ( "context" "errors" "fmt" + "github.com/PlatONnetwork/PlatON-Go/x/gov" "math/big" "time" @@ -522,13 +523,17 @@ func NewPublicBlockChainAPI(b Backend) *PublicBlockChainAPI { // return nil //} -// ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config. +// ChainId is the PIP-7 replay-protection chain id for the current chain config. func (s *PublicBlockChainAPI) ChainId() (*hexutil.Big, error) { - // if current block is at or past the EIP-155 replay-protection fork block, return chainID from config - if config := s.b.ChainConfig(); config.IsEIP155(s.b.CurrentBlock().Number()) { - return (*hexutil.Big)(config.ChainID), nil + stateDB, _, err := s.b.StateAndHeaderByNumber(context.Background(), rpc.BlockNumber(s.b.CurrentBlock().Number().Uint64())) + config := s.b.ChainConfig() + if err == nil { + pip7 := gov.Gte120VersionState(stateDB) + if pip7 { + return (*hexutil.Big)(config.PIP7ChainID), nil + } } - return nil, fmt.Errorf("chain not synced beyond EIP-155 replay-protection fork block") + return (*hexutil.Big)(config.ChainID), nil } // BlockNumber returns the block number of the chain head. From 0d91966bebd1ac1264a3074e82be0273ebe0e357 Mon Sep 17 00:00:00 2001 From: niuxiaojie81 <85773309@qq.com> Date: Thu, 7 Apr 2022 11:02:52 +0800 Subject: [PATCH 2/3] update versionPatch --- params/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/params/version.go b/params/version.go index 4df77e9ca9..0aa0450659 100644 --- a/params/version.go +++ b/params/version.go @@ -24,7 +24,7 @@ const ( //These versions are meaning the current code version. VersionMajor = 1 // Major version component of the current release VersionMinor = 2 // Minor version component of the current release - VersionPatch = 0 // Patch version component of the current release + VersionPatch = 1 // Patch version component of the current release VersionMeta = "unstable" // Version metadata to append to the version string //CAUTION: DO NOT MODIFY THIS ONCE THE CHAIN HAS BEEN INITIALIZED!!! From 5b181421484fde518d498fa1314017a7ed2703cf Mon Sep 17 00:00:00 2001 From: niuxiaojie81 <85773309@qq.com> Date: Thu, 7 Apr 2022 18:19:42 +0800 Subject: [PATCH 3/3] fixed error with ErrInvalidChainId when creating contract --- internal/ethapi/api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index a9a16649ec..f072c4435c 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1497,7 +1497,7 @@ func SubmitTransaction(ctx context.Context, b Backend, tx *types.Transaction) (c return common.Hash{}, err } if tx.To() == nil { - signer := types.NewEIP155Signer(b.ChainConfig().ChainID) + signer := types.MakeSigner(b.ChainConfig(), true) from, err := types.Sender(signer, tx) if err != nil { return common.Hash{}, err