Skip to content

Commit d9c7b1a

Browse files
committed
chore_: remove CallBlockHashByTransaction workaround for bad block hash calculation
1 parent 225bf26 commit d9c7b1a

File tree

8 files changed

+3
-114
lines changed

8 files changed

+3
-114
lines changed

rpc/chain/client.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -783,24 +783,6 @@ func (c *ClientWithFallback) GetBaseFeeFromBlock(ctx context.Context, blockNumbe
783783
return baseGasFee, err
784784
}
785785

786-
func (c *ClientWithFallback) CallBlockHashByTransaction(ctx context.Context, blockNumber *big.Int, index uint) (common.Hash, error) {
787-
rpcstats.CountCallWithTag("eth_FullTransactionByBlockNumberAndIndex", c.tag)
788-
789-
res, err := c.makeCall(
790-
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
791-
return client.CallBlockHashByTransaction(ctx, blockNumber, index)
792-
},
793-
)
794-
795-
c.toggleConnectionState(err)
796-
797-
if err != nil {
798-
return common.HexToHash(""), err
799-
}
800-
801-
return res.(common.Hash), nil
802-
}
803-
804786
func (c *ClientWithFallback) GetWalletNotifier() func(chainId uint64, message string) {
805787
return c.WalletNotifier
806788
}

rpc/chain/ethclient/eth_client.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ type EthClientInterface interface {
6262
GetBaseFeeFromBlock(ctx context.Context, blockNumber *big.Int) (string, error)
6363
bind.ContractCaller
6464
bind.ContractBackend
65-
CallBlockHashByTransaction(ctx context.Context, blockNumber *big.Int, index uint) (common.Hash, error)
6665
}
6766

6867
// EthClient implements EthClientInterface
@@ -82,13 +81,6 @@ func (ec *EthClient) BatchCallContext(ctx context.Context, b []rpc.BatchElem) er
8281
return ec.rpcClient.BatchCallContext(ctx, b)
8382
}
8483

85-
// go-ethereum's `Transaction` items drop the blkHash obtained during the RPC call.
86-
// This function preserves the additional data. This is the cheapest way to obtain
87-
// the block hash for a given block number.
88-
func (ec *EthClient) CallBlockHashByTransaction(ctx context.Context, blockNumber *big.Int, index uint) (common.Hash, error) {
89-
return callBlockHashByTransaction(ctx, ec.rpcClient, blockNumber, index)
90-
}
91-
9284
func (ec *EthClient) GetBaseFeeFromBlock(ctx context.Context, blockNumber *big.Int) (string, error) {
9385
feeHistory, err := ec.FeeHistory(ctx, 1, blockNumber, nil)
9486

rpc/chain/ethclient/rpc.go

Lines changed: 0 additions & 66 deletions
This file was deleted.

services/wallet/balance/balance_cache.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ type Reader interface {
1515
BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
1616
NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)
1717
HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
18-
CallBlockHashByTransaction(ctx context.Context, blockNumber *big.Int, index uint) (common.Hash, error)
1918
NetworkID() uint64
2019
}
2120

services/wallet/transfer/commands_sequential_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,6 @@ func (tc *TestClient) HeaderByNumber(ctx context.Context, number *big.Int) (*typ
305305
return header, nil
306306
}
307307

308-
func (tc *TestClient) CallBlockHashByTransaction(ctx context.Context, blockNumber *big.Int, index uint) (common.Hash, error) {
309-
err := tc.countAndlog("CallBlockHashByTransaction")
310-
if err != nil {
311-
return common.Hash{}, err
312-
}
313-
return common.BigToHash(blockNumber), nil
314-
}
315-
316308
func (tc *TestClient) GetBaseFeeFromBlock(ctx context.Context, blockNumber *big.Int) (string, error) {
317309
err := tc.countAndlog("GetBaseFeeFromBlock")
318310
return "", err

services/wallet/transfer/concurrent.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,17 +177,11 @@ func checkRangesWithStartBlock(parent context.Context, client balance.Reader, ca
177177
}
178178
}
179179
if new(big.Int).Sub(to, from).Cmp(one) == 0 {
180-
// WARNING: Block hash calculation from plain header returns a wrong value.
181180
header, err := client.HeaderByNumber(ctx, to)
182181
if err != nil {
183182
return err
184183
}
185-
// Obtain block hash from first transaction
186-
blockHash, err := client.CallBlockHashByTransaction(ctx, to, 0)
187-
if err != nil {
188-
return err
189-
}
190-
c.PushHeader(toDBHeader(header, blockHash, account))
184+
c.PushHeader(toDBHeader(header, account))
191185
return nil
192186
}
193187
mid := new(big.Int).Add(from, to)

services/wallet/transfer/concurrent_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ func (f balancesFixture) NetworkID() uint64 {
8181
return 0
8282
}
8383

84-
func (f balancesFixture) CallBlockHashByTransaction(ctx context.Context, blockNumber *big.Int, index uint) (common.Hash, error) {
85-
return common.HexToHash("0x0"), nil
86-
}
87-
8884
type batchesFixture [][]Transfer
8985

9086
func (f batchesFixture) GetTransfersByNumber(ctx context.Context, number *big.Int) (rst []Transfer, err error) {

services/wallet/transfer/database.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ type DBHeader struct {
3333
Loaded bool
3434
}
3535

36-
func toDBHeader(header *types.Header, blockHash common.Hash, account common.Address) *DBHeader {
36+
func toDBHeader(header *types.Header, account common.Address) *DBHeader {
3737
return &DBHeader{
38-
Hash: blockHash,
38+
Hash: header.Hash(),
3939
Number: header.Number,
4040
Timestamp: header.Time,
4141
Loaded: false,

0 commit comments

Comments
 (0)