mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
fix: panic
This commit is contained in:
parent
e660629a78
commit
bb0714d9a5
3 changed files with 34 additions and 4 deletions
15
README.md
15
README.md
|
|
@ -3,7 +3,7 @@
|
|||

|
||||
[](https://discord.gg/HBAgaHCBuY)
|
||||
|
||||
Shisui is an [Ethereum portal client](https://github.com/ethereum/portal-network-specs) written in Go language based [go-ethereum](https://github.com/ethereum/go-ethereum) and [erigon](https://github.com/ledgerwatch/erigon).
|
||||
Shisui is an [Ethereum portal client](https://github.com/ethereum/portal-network-specs) written in Go language based on [go-ethereum](https://github.com/ethereum/go-ethereum).
|
||||
The name is inspired by Uchiha Shisui from the anime Naruto, who is renowned as "Shisui of the Body Flicker".
|
||||
|
||||
> **Note:** Shisui is still **under heavy development** and is not yet ready for production use.
|
||||
|
|
@ -39,6 +39,19 @@ Alternatively, you can run the docker image by running
|
|||
docker run -d -p 8545:8545 -p 9009:9009/udp ghcr.io/optimism-java/shisui:latest
|
||||
```
|
||||
|
||||
### supported options
|
||||
|
||||
* `--rpc.addr` HTTP-RPC server listening addr
|
||||
* `--rpc.port` HTTP-RPC server listening port(default: `8545`)
|
||||
* `--data.dir` data dir of where the data file located(default: `./`)
|
||||
* `--data.capacity` the capacity of the data stored, the unit is MB(default: `10GB`)
|
||||
* `--udp.addr` protocol UDP server listening interface(default: local ip)
|
||||
* `--udp.addr` protocol UDP server listening port(default: `9009`)
|
||||
* `--loglevel` loglevel of portal network, `1` to `5`, from `error` to `trace`(default: `1`)
|
||||
* `--private.key` private key of p2p node, hex format without `0x` prifix
|
||||
* `--bootnodes` bootnode of p2p network with ENR format
|
||||
* `--networks` portal sub networks: history, beacon, state
|
||||
|
||||
### Hardware Requirements
|
||||
|
||||
Minimum:
|
||||
|
|
|
|||
|
|
@ -1006,7 +1006,7 @@ Please note that --` + MetricsHTTPFlag.Name + ` must be set to start the server.
|
|||
|
||||
PortalPrivateKeyFlag = &cli.StringFlag{
|
||||
Name: "private.key",
|
||||
Usage: "private key of p2p node, hex format",
|
||||
Usage: "private key of p2p node, hex format without 0x prifix",
|
||||
Category: flags.PortalNetworkCategory,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -88,6 +88,8 @@ var ErrNilContentKey = errors.New("content key cannot be nil")
|
|||
|
||||
var ContentNotFound = storage.ErrContentNotFound
|
||||
|
||||
var ErrEmptyResp = errors.New("empty resp")
|
||||
|
||||
var MaxDistance = hexutil.MustDecode("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
|
||||
|
||||
type ContentElement struct {
|
||||
|
|
@ -309,7 +311,11 @@ func (p *PortalProtocol) setupUDPListening() error {
|
|||
}
|
||||
}
|
||||
|
||||
p.Log.Trace("send to target data", "ip", target.IP().String(), "port", target.UDP(), "bufLength", len(buf))
|
||||
if target == nil {
|
||||
p.Log.Warn("not fount target node info", "ip", addr.IP.To4().String(), "port", addr.Port, "bufLength", len(buf))
|
||||
return 0, fmt.Errorf("not found target node info")
|
||||
}
|
||||
p.Log.Trace("send to target data", "ip", addr.IP.To4().String(), "port", addr.Port, "bufLength", len(buf))
|
||||
_, err := p.DiscV5.TalkRequest(target, string(portalwire.UTPNetwork), buf)
|
||||
return len(buf), err
|
||||
})
|
||||
|
|
@ -494,6 +500,9 @@ func (p *PortalProtocol) offer(node *enode.Node, offerRequest *OfferRequest) ([]
|
|||
|
||||
func (p *PortalProtocol) processOffer(target *enode.Node, resp []byte, request *OfferRequest) ([]byte, error) {
|
||||
var err error
|
||||
if len(resp) == 0 {
|
||||
return nil, ErrEmptyResp
|
||||
}
|
||||
if resp[0] != portalwire.ACCEPT {
|
||||
return nil, fmt.Errorf("invalid accept response")
|
||||
}
|
||||
|
|
@ -613,6 +622,10 @@ func (p *PortalProtocol) processOffer(target *enode.Node, resp []byte, request *
|
|||
}
|
||||
|
||||
func (p *PortalProtocol) processContent(target *enode.Node, resp []byte) (byte, interface{}, error) {
|
||||
if len(resp) == 0 {
|
||||
return 0x00, nil, ErrEmptyResp
|
||||
}
|
||||
|
||||
if resp[0] != portalwire.CONTENT {
|
||||
return 0xff, nil, fmt.Errorf("invalid content response")
|
||||
}
|
||||
|
|
@ -678,6 +691,10 @@ func (p *PortalProtocol) processContent(target *enode.Node, resp []byte) (byte,
|
|||
}
|
||||
|
||||
func (p *PortalProtocol) processNodes(target *enode.Node, resp []byte, distances []uint) ([]*enode.Node, error) {
|
||||
if len(resp) == 0 {
|
||||
return nil, ErrEmptyResp
|
||||
}
|
||||
|
||||
if resp[0] != portalwire.NODES {
|
||||
return nil, fmt.Errorf("invalid nodes response")
|
||||
}
|
||||
|
|
@ -731,7 +748,7 @@ func (p *PortalProtocol) filterNodes(target *enode.Node, enrs [][]byte, distance
|
|||
|
||||
func (p *PortalProtocol) processPong(target *enode.Node, resp []byte) (*portalwire.Pong, error) {
|
||||
if len(resp) == 0 {
|
||||
return nil, fmt.Errorf("empty resp")
|
||||
return nil, ErrEmptyResp
|
||||
}
|
||||
if resp[0] != portalwire.PONG {
|
||||
return nil, fmt.Errorf("invalid pong response")
|
||||
|
|
|
|||
Loading…
Reference in a new issue