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@byzantine-lab.io>2019-06-12 17:27:18 +0800
commitc5206f748e1a4a57707cffc8f867386f0d84f7be (patch)
tree7e840c9a4b686718f4bcb31b9f64d6330bbbd470 /dex/protocol.go
parent91d3c571ef5e5628917c5a27d16bc0d8d7083224 (diff)
downloadgo-tangerine-c5206f748e1a4a57707cffc8f867386f0d84f7be.tar
go-tangerine-c5206f748e1a4a57707cffc8f867386f0d84f7be.tar.gz
go-tangerine-c5206f748e1a4a57707cffc8f867386f0d84f7be.tar.bz2
go-tangerine-c5206f748e1a4a57707cffc8f867386f0d84f7be.tar.lz
go-tangerine-c5206f748e1a4a57707cffc8f867386f0d84f7be.tar.xz
go-tangerine-c5206f748e1a4a57707cffc8f867386f0d84f7be.tar.zst
go-tangerine-c5206f748e1a4a57707cffc8f867386f0d84f7be.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.