-
Notifications
You must be signed in to change notification settings - Fork 112
all:bzzaddr instead of just overlay for logging #2000
Conversation
Thanks Petar.
I would assume that
I believe that this would improve information that are relevant for debugging. |
Thanks Janos. Cool, I will leave the short address in the |
storage/netstore.go
Outdated
@@ -92,14 +94,14 @@ type NetStore struct { | |||
} | |||
|
|||
// NewNetStore creates a new NetStore using the provided chunk.Store and localID of the node. | |||
func NewNetStore(store chunk.Store, baseAddr []byte, localID enode.ID) *NetStore { | |||
func NewNetStore(store chunk.Store, baseAddr *network.BzzAddr, localID enode.ID) *NetStore { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BzzAddr already provides enode.ID with its ID() method, so localID should not be needed.
network/stream/peer.go
Outdated
// NewPeer is the constructor for Peer | ||
func NewPeer(peer *network.BzzPeer, baseKey []byte, i state.Store, providers map[string]StreamProvider) *Peer { | ||
// newPeer is the constructor for Peer | ||
func newPeer(peer *network.BzzPeer, address *network.BzzAddr, i state.Store, providers map[string]StreamProvider) *Peer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BzzPeer already has BzzAddr. Maybe it is possible to remove address argument?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I am not mistaken, peer has a BzzAddr for a peer, and address is a base address. I will rename the argument to baseAddress
to avoid the confusion.
network/retrieval/retrieve_test.go
Outdated
@@ -621,7 +621,7 @@ func newRetrievalTester(t *testing.T, prvkey *ecdsa.PrivateKey, netStore *storag | |||
prvkey = key | |||
} | |||
|
|||
r := New(kad, netStore, kad.BaseAddr(), nil) | |||
r := New(kad, netStore, network.NewBzzAddr(kad.BaseAddr(), network.PrivateKeyToBzzKey(prvkey)), nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PrivateKeyToBzzKey is creating an Overlay address, but here is used in place of Underlay address. Is it correct to set it to nil as it is not available in this function and not used in these tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I think we can set it to nil as well.
@@ -33,16 +32,17 @@ func TestInspectorPeerStreams(t *testing.T) { | |||
t.Fatal(err) | |||
} | |||
|
|||
baseAddress := network.NewBzzAddr(baseKey, baseKey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an idea, for the underlay address, to use nil
instead, not to present an example where overlay address is used as a value from underlay?
The same question stands for other places where NewBzzAddr is used with identical value for arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I started to change this on the whole project but did not push yet :) Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this concrete case needs underlay address because of the PeerInfo()
function, so I have decided to create another rand key for peer base address. I know it's not needed, but I think it gives more info in tests about the nature of address. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe just to add a comment justifying the usage of baseKey in this particular case. That would be also good, at least for me.
api/inspector_test.go
Outdated
|
||
i := NewInspector(nil, nil, netStore, stream.New(state.NewInmemoryStore(), baseKey, stream.NewSyncProvider(netStore, network.NewKademlia( | ||
i := NewInspector(nil, nil, netStore, stream.New(state.NewInmemoryStore(), network.NewBzzAddr(baseKey, baseKey), stream.NewSyncProvider(netStore, network.NewKademlia( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
baseAddress instead NewBzzAddr?
swarm.go
Outdated
self.netStore = storage.NewNetStore(lstore, bzzconfig.OverlayAddr, nodeID) | ||
self.retrieval = retrieval.New(to, self.netStore, bzzconfig.OverlayAddr, self.swap) // nodeID.Bytes()) | ||
self.netStore = storage.NewNetStore(lstore, bzzconfig.Address) | ||
self.retrieval = retrieval.New(to, self.netStore, bzzconfig.Address, self.swap) // nodeID.Bytes()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove commented code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, it was there before, so I did not erase it yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I did not notice it, thanks.
return fmt.Sprintf("%s:%s", a.ShortOver(), a.ShortUnder()) | ||
} | ||
|
||
func (a *BzzAddr) ShortOver() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment exported functions
network/network.go
Outdated
return fmt.Sprintf("%s:%s", a.ShortOver(), a.ShortUnder()) | ||
} | ||
|
||
// ShortOver prints shortened version of Overlay address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prints -> returns
Trying to improve logs by printing the
bzzaddr
, with both overlay and underlay address, instead of just printing the overlay address, or node-id. This is attempt to solve this: #1961. It is covering mainly the network module, but there are also minor changes in the other modules as well.In most modules, the logger is initialized with
base
and/orpeer
prefix that are used to log info about the node performing the action.base
logger:I tried to cover all the instances of base logger and use
BzzAddr
here so we get both overlay/underlay pair in logs.peer
logger:The same rationale is used as for
base
, however since the overlay address is not accurate for peers without the bzz-handshake I don't see a way to log this information correctly outside of the, mostly, network package.Questions:
base
?r.logger.Trace("findpeer skip peer", "peer", id, "ref", req.Addr.String())
)Improvement:
base
logs in production and include it only in tests.