-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
vdn: impl msg specs, support block/vote biz logic #2940
base: develop_vdn
Are you sure you want to change the base?
Conversation
handler: add vdn msg handler;
handler: add vdn msg handler;
handler: fix some block/vote msg handle issues;
package vdn | ||
|
||
import ( | ||
"bytes" | ||
"io" | ||
|
||
"github.com/ethereum/go-ethereum/rlp" | ||
) | ||
|
||
// EncodeToStream encode any msg by rlp | ||
func EncodeToStream(msg interface{}, writer io.Writer) error { | ||
return rlp.Encode(writer, msg) | ||
} | ||
|
||
// DecodeFromStream msg must be a pointer | ||
func DecodeFromStream(msg interface{}, reader io.Reader) error { | ||
return rlp.Decode(reader, msg) | ||
} | ||
|
||
// EncodeToBytes encode any msg by rlp | ||
func EncodeToBytes(msg interface{}) ([]byte, error) { | ||
buf := new(bytes.Buffer) | ||
if err := rlp.Encode(buf, msg); err != nil { | ||
return nil, err | ||
} | ||
return buf.Bytes(), nil | ||
} | ||
|
||
// DecodeFromBytes msg must be a pointer | ||
func DecodeFromBytes(msg interface{}, data []byte) error { | ||
return rlp.DecodeBytes(data, msg) | ||
} |
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.
can we use ssz? as this is complete new netwrok ssz is much better candidate encoding, if you need help with this let me know
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.
Yeah, it's a new network, but introducing ssz encoding is a big thing, I prefer to use current RLP encoding now. May be we can discuss this more~
func defaultTopicParams() *pubsub.TopicScoreParams { | ||
decayEpoch := 5 | ||
decayEpochDuration := 5 * oneEpochDuration() | ||
blocksInEpoch := blocksPerEpoch() | ||
meshWeight := -0.717 | ||
invalidDecayPeriod := 50 * oneEpochDuration() | ||
if !meshDeliveryIsScored { | ||
// Set the mesh weight as zero as a temporary measure, so as to prevent | ||
// the average nodes from being penalised. | ||
meshWeight = 0 | ||
} | ||
return &pubsub.TopicScoreParams{ | ||
TopicWeight: defaultTopicWeight, | ||
TimeInMeshWeight: maxInMeshScore / inMeshCap(), | ||
TimeInMeshQuantum: inMeshTime(), | ||
TimeInMeshCap: inMeshCap(), | ||
FirstMessageDeliveriesWeight: 1, | ||
FirstMessageDeliveriesDecay: scoreDecay(20 * oneEpochDuration()), | ||
FirstMessageDeliveriesCap: 23, | ||
MeshMessageDeliveriesWeight: meshWeight, | ||
MeshMessageDeliveriesDecay: scoreDecay(decayEpochDuration), | ||
MeshMessageDeliveriesCap: float64(blocksInEpoch * uint64(decayEpoch)), | ||
MeshMessageDeliveriesThreshold: float64(blocksInEpoch*uint64(decayEpoch)) / 10, | ||
MeshMessageDeliveriesWindow: 2 * time.Second, | ||
MeshMessageDeliveriesActivation: 4 * oneEpochDuration(), | ||
MeshFailurePenaltyWeight: meshWeight, | ||
MeshFailurePenaltyDecay: scoreDecay(decayEpochDuration), | ||
InvalidMessageDeliveriesWeight: -140.4475, | ||
InvalidMessageDeliveriesDecay: scoreDecay(invalidDecayPeriod), | ||
} | ||
} |
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.
how did you get this values? maybe some comment would be beneficial
Description
This PR implements all BEP-525 msg specs, and support basic block/vote gossip msg business logic. The VDN can sync new blocks, and aggregate votes successfully now.
It also adds some abstract for gossip/RPC msg handler. see
vdn/interfaces.go
.Now, you can use https://github.com/bnb-chain/node-deploy/tree/support-vdnp2p to setup a vdn-only cluster in local for testing.
Changes
Notable changes: