Skip to content

Commit

Permalink
update v2.0.0-p6
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzhi committed Oct 17, 2024
1 parent e6a6266 commit d9b205d
Show file tree
Hide file tree
Showing 22 changed files with 846 additions and 581 deletions.
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: quilibrium
services:
node:
# image: ${QUILIBRIUM_IMAGE_NAME:-quilibrium}
image: eth2dev/quilibrium:v2.0.0-p3-signed
image: eth2dev/quilibrium:v2.0.0-p6-signed
container_name: "quil"
restart: unless-stopped
# command: ["--signature-check=false"]
Expand Down
6 changes: 5 additions & 1 deletion node/app/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"source.quilibrium.com/quilibrium/monorepo/node/consensus/master"
"source.quilibrium.com/quilibrium/monorepo/node/crypto"
"source.quilibrium.com/quilibrium/monorepo/node/execution"
"source.quilibrium.com/quilibrium/monorepo/node/execution/intrinsics/token"
"source.quilibrium.com/quilibrium/monorepo/node/keys"
"source.quilibrium.com/quilibrium/monorepo/node/p2p"
"source.quilibrium.com/quilibrium/monorepo/node/store"
Expand Down Expand Up @@ -48,14 +49,17 @@ func newNode(
coinStore store.CoinStore,
keyManager keys.KeyManager,
pubSub p2p.PubSub,
// execution engines wire in here
tokenExecutionEngine *token.TokenExecutionEngine,
engine consensus.ConsensusEngine,
) (*Node, error) {
if engine == nil {
return nil, errors.New("engine must not be nil")
}

execEngines := make(map[string]execution.ExecutionEngine)
if tokenExecutionEngine != nil {
execEngines[tokenExecutionEngine.GetName()] = tokenExecutionEngine
}

return &Node{
logger,
Expand Down
12 changes: 8 additions & 4 deletions node/app/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 14 additions & 8 deletions node/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ type Signature struct {
PublicKeyHex string `json:"publicKeyHex"`
SignatureHex string `json:"signatureHex"`
}

type SignedGenesisUnlock struct {
GenesisSeedHex string `json:"genesisSeedHex"`
Signatures []Signature `json:"signatures"`
Expand Down Expand Up @@ -131,12 +132,12 @@ var Signatories = []string{

var unlock *SignedGenesisUnlock

func DownloadAndVerifyGenesis() (*SignedGenesisUnlock, error) {
func DownloadAndVerifyGenesis(network uint) (*SignedGenesisUnlock, error) {
if unlock != nil {
return unlock, nil
}

resp, err := http.Get("https://releases.quilibrium.com/stasis")
resp, err := http.Get("https://releases.quilibrium.com/genesisunlock")
if err != nil || resp.StatusCode != 200 {
fmt.Println("Stasis lock not yet released.")
return nil, errors.New("stasis lock not yet released")
Expand Down Expand Up @@ -167,7 +168,7 @@ func DownloadAndVerifyGenesis() (*SignedGenesisUnlock, error) {
checksig := ""
for _, sig := range checkUnlock.Signatures {
if sig.PublicKeyHex == Signatories[i-1] {
checksig = sig.PublicKeyHex
checksig = sig.SignatureHex
break
}
}
Expand All @@ -176,28 +177,33 @@ func DownloadAndVerifyGenesis() (*SignedGenesisUnlock, error) {
continue
}

sig, err := hex.DecodeString(Signatories[i-1])
sig, err := hex.DecodeString(checksig)
if err != nil {
return nil, err
}

if !ed448.Verify(pubkey, digest[:], sig, "") {
opensslMsg := "SHA3-256(genesis)= " + hex.EncodeToString(digest[:])
if !ed448.Verify(pubkey, append([]byte(opensslMsg), 0x0a), sig, "") {
fmt.Printf("Failed signature check for signatory #%d\n", i)
return nil, err
return nil, errors.New("failed signature check")
}
count++
}

if count < len(Signatories)/2+len(Signatories)%2 {
fmt.Printf("Quorum on signatures not met")
return nil, err
return nil, errors.New("quorum on signatures not met")
}

fmt.Println("Stasis lock released. Welcome to 2.0.")
unlock = checkUnlock
return unlock, err
}

func GetGenesis() *SignedGenesisUnlock {
return unlock
}

var StasisSeed = "737461736973"

func LoadConfig(configPath string, proverKey string, skipGenesisCheck bool) (
Expand Down Expand Up @@ -233,7 +239,7 @@ func LoadConfig(configPath string, proverKey string, skipGenesisCheck bool) (
genesisSeed := StasisSeed

if !skipGenesisCheck {
output, err := DownloadAndVerifyGenesis()
output, err := DownloadAndVerifyGenesis(0)
if err == nil {
genesisSeed = output.GenesisSeedHex
}
Expand Down
2 changes: 1 addition & 1 deletion node/config/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ func FormatVersion(version []byte) string {
}

func GetPatchNumber() byte {
return 0x03
return 0x06
}
16 changes: 0 additions & 16 deletions node/consensus/data/consensus_frames.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,22 +283,6 @@ func (e *DataClockConsensusEngine) collect(
e.logger.Info("no peers available for sync, waiting")
time.Sleep(5 * time.Second)
} else if maxFrame > latest.FrameNumber {
masterHead, err := e.masterTimeReel.Head()
if err != nil {
panic(err)
}

if masterHead.FrameNumber < maxFrame {
e.logger.Info(
"master frame synchronization needed to continue, waiting",
zap.Uint64("master_frame_head", masterHead.FrameNumber),
zap.Uint64("max_data_frame_target", maxFrame),
)

time.Sleep(30 * time.Second)
continue
}

latest, err = e.sync(latest, maxFrame, peerId)
if err == nil {
break
Expand Down
Loading

0 comments on commit d9b205d

Please sign in to comment.