Skip to content

Commit

Permalink
Merge pull request #1925 from PlatONnetwork/feature/double-chainid-2
Browse files Browse the repository at this point in the history
Feature/double chainid 2
  • Loading branch information
benbaley authored Apr 8, 2022
2 parents c5aa0ec + 4349192 commit 890ac8f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"context"
"errors"
"fmt"
"github.com/PlatONnetwork/PlatON-Go/x/gov"
"math/big"
"time"

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -1492,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
Expand Down
2 changes: 1 addition & 1 deletion params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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!!!
Expand Down

0 comments on commit 890ac8f

Please sign in to comment.