aboutsummaryrefslogtreecommitdiffstats
path: root/dex/protocol.go
diff options
context:
space:
mode:
authorSonic <sonic@dexon.org>2018-11-20 14:13:53 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:53 +0800
commitafc01df41cafd3a8b56db9f32e23da3bf0e6b7ef (patch)
tree28013bb14a19611adecda49d1dfbeb0a34dad66a /dex/protocol.go
parent2113837c006aad6af75c09d37514591fd6863dbc (diff)
downloaddexon-afc01df41cafd3a8b56db9f32e23da3bf0e6b7ef.tar.gz
dexon-afc01df41cafd3a8b56db9f32e23da3bf0e6b7ef.tar.zst
dexon-afc01df41cafd3a8b56db9f32e23da3bf0e6b7ef.zip
dex: implement downloader for dex
We need governance state to verify block's signature (randomness), but in ethereum fast sync mode, eth downloader only downloads the whole state of pivot block, so we don't have governance state to verify the downloaded block that is before pivot block if we don't processing transaction. To avoid running transactions, dex downloader also downloads the governance state (merkle proof and storage) at snapshot height of each round, so that we can verify blocks in fast sync mode.
Diffstat (limited to 'dex/protocol.go')
-rw-r--r--dex/protocol.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/dex/protocol.go b/dex/protocol.go
index 04928d2b2..0c271248e 100644
--- a/dex/protocol.go
+++ b/dex/protocol.go
@@ -34,6 +34,7 @@
package dex
import (
+ "context"
"crypto/ecdsa"
"fmt"
"io"
@@ -60,7 +61,7 @@ var ProtocolName = "dex"
var ProtocolVersions = []uint{dex64}
// ProtocolLengths are the number of implemented message corresponding to different protocol versions.
-var ProtocolLengths = []uint64{40}
+var ProtocolLengths = []uint64{42}
const ProtocolMaxMsgSize = 10 * 1024 * 1024 // Maximum cap on the size of a protocol message
@@ -93,6 +94,9 @@ const (
DKGPartialSignatureMsg = 0x25
PullBlocksMsg = 0x26
PullVotesMsg = 0x27
+
+ GetGovStateMsg = 0x28
+ GovStateMsg = 0x29
)
type errCode int
@@ -140,6 +144,8 @@ type txPool interface {
}
type governance interface {
+ GetRoundHeight(context.Context, uint64) (uint64, error)
+
GetNumChains(uint64) uint32
LenCRS() uint64
@@ -184,6 +190,8 @@ type getBlockHeadersData struct {
Amount uint64 // Maximum number of headers to retrieve
Skip uint64 // Blocks to skip between consecutive headers
Reverse bool // Query direction (false = rising towards latest, true = falling towards genesis)
+
+ WithGov bool
}
// hashOrNumber is a combined field for specifying an origin block.