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

ChainID adjustment #185

Merged
merged 2 commits into from
Aug 8, 2022
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
6 changes: 3 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
BUILD_KEY: ${{ secrets.BUILD_KEY }}
#strategy:
# matrix:
# go-version: [1.16.x, 1.17.x]
# go-version: [1.16.x, 1.17.x, 1.18.x]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
run: mkdir -p /tmp/go
- uses: actions/setup-go@v3
with:
go-version: ">=1.18.0"
go-version: "1.18.x"
check-latest: true
- uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -157,7 +157,7 @@ jobs:
run: mkdir -p /tmp/go
- uses: actions/setup-go@v3
with:
go-version: ">=1.18.0"
go-version: "1.18.x"
check-latest: true
- uses: actions/checkout@v2
with:
Expand Down
11 changes: 5 additions & 6 deletions pkg/eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ type PublicEthAPI struct {

// NewPublicEthAPI creates a new PublicEthAPI with the provided underlying Backend
func NewPublicEthAPI(b *Backend, client *rpc.Client, supportsStateDiff, forwardEthCalls, proxyOnError bool) (*PublicEthAPI, error) {
if b == nil {
return nil, errors.New("ipld-eth-server must be configured with an ethereum backend")
}
if forwardEthCalls && client == nil {
return nil, errors.New("ipld-eth-server is configured to forward eth_calls to proxy node but no proxy node is configured")
}
Expand Down Expand Up @@ -191,8 +194,7 @@ func (pea *PublicEthAPI) GetBlockByHash(ctx context.Context, hash common.Hash, f

// ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config.
func (pea *PublicEthAPI) ChainId() *hexutil.Big {
block, err := pea.B.CurrentBlock()
if err != nil {
if pea.B.Config.ChainConfig.ChainID == nil || pea.B.Config.ChainConfig.ChainID.Cmp(big.NewInt(0)) <= 0 {
if pea.proxyOnError {
if id, err := pea.ethClient.ChainID(context.Background()); err == nil {
return (*hexutil.Big)(id)
Expand All @@ -201,10 +203,7 @@ func (pea *PublicEthAPI) ChainId() *hexutil.Big {
return nil
}

if config := pea.B.Config.ChainConfig; config.IsEIP155(block.Number()) {
return (*hexutil.Big)(config.ChainID)
}
return nil
return (*hexutil.Big)(pea.B.Config.ChainConfig.ChainID)
}

/*
Expand Down