Skip to content

Commit

Permalink
update v1.4.21-p1
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzhi committed Oct 11, 2024
1 parent 53ff2ca commit fd30b59
Show file tree
Hide file tree
Showing 13 changed files with 61,126 additions and 701 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:v1.4.21-signed
image: eth2dev/quilibrium:v1.4.21-p1-signed
container_name: "quil"
restart: unless-stopped
# command: ["--signature-check=false"]
Expand Down
6 changes: 4 additions & 2 deletions node/app/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func (n *Node) VerifyProofIntegrity() {
if e != nil {
panic(e)
}

dataProver := crypto.NewKZGInclusionProver(n.logger)
wesoProver := crypto.NewWesolowskiFrameProver(n.logger)

Expand All @@ -79,6 +80,7 @@ func (n *Node) VerifyProofIntegrity() {
if err != nil {
panic(err)
}

idx, idxProof, idxCommit, idxKP := master.GetOutputs(o)

ip := sha3.Sum512(idxProof)
Expand All @@ -89,15 +91,15 @@ func (n *Node) VerifyProofIntegrity() {
}

if !v {
panic(fmt.Sprintf("bad kzg proof at increment %d", i))
panic(fmt.Sprintf("bad kzg proof at increment %d", j))
}
wp := []byte{}
wp = append(wp, n.pubSub.GetPeerID()...)
wp = append(wp, input...)
fmt.Printf("%x\n", wp)
v = wesoProver.VerifyChallengeProof(wp, uint32(j), idx, idxProof)
if !v {
panic(fmt.Sprintf("bad weso proof at increment %d", i))
panic(fmt.Sprintf("bad weso proof at increment %d", j))
}
}
}
Expand Down
51,764 changes: 51,764 additions & 0 deletions node/bridged.json

Large diffs are not rendered by default.

19 changes: 17 additions & 2 deletions node/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,27 @@ var BootstrapPeers = []string{
"/dns/quidditch.quilibrium.com/udp/8336/quic-v1/p2p/QmbZEGuinaCndj4XLb6fteZmjmP3C1Tsgijmc5BGuUk8Ma",
"/dns/quagmire.quilibrium.com/udp/8336/quic-v1/p2p/QmaQ9KAaKtqXhYSQ5ARQNnn8B8474cWGvvD6PgJ4gAtMrx",
"/ip4/204.186.74.46/udp/8316/quic-v1/p2p/QmeqBjm3iX7sdTieyto1gys5ruQrQNPKfaTGcVQQWJPYDV",
"/ip4/103.219.170.9/udp/8336/quic-v1/p2p/QmfEdMfmdhNoYuGVhhw5LBApHHG1rbVAHXwGWpW8s9bXeg",
"/ip4/185.143.102.84/udp/8336/quic-v1/p2p/Qmce68gLLq9eMdwCcmd1ptfoC2nVoe861LF1cjdVHC2DwK",
"/ip4/65.109.17.13/udp/8336/quic-v1/p2p/Qmc35n99eojSvW3PkbfBczJoSX92WmnnKh3Fg114ok3oo4",
"/ip4/65.108.194.84/udp/8336/quic-v1/p2p/QmP8C7g9ZRiWzhqN2AgFu5onS6HwHzR6Vv1TCHxAhnCSnq",
"/dns/quil.dfcnodes.eu/udp/8336/quic-v1/p2p/QmQaFmbYVrKSwoen5UQdaqyDq4QhXfSSLDVnYpYD4SF9tX",
"/ip4/87.98.167.207/udp/8336/quic-v1/p2p/QmafiAXLu1JWktyfzDtD67i78GRBYCfQ4doTfq7pp7wfQ1",
"/ip4/15.204.100.222/udp/8336/quic-v1/p2p/Qmef3Z3RvGg49ZpDPcf2shWtJNgPJNpXrowjUcfz23YQ3V",
"/ip4/69.197.174.35/udp/8336/quic-v1/p2p/QmeprCaZKiymofPJgnp2ANR3F4pRus9PHHaxnJDh1Jwr1p",
"/ip4/70.36.102.32/udp/8336/quic-v1/p2p/QmYriGRXCUiwFodqSoS4GgEcD7UVyxXPeCgQKmYne3iLSF",
"/ip4/204.12.220.2/udp/8336/quic-v1/p2p/QmRw5Tw4p5v2vLPvVSAkQEiRPQGnWk9HM4xiSvgxF82CCw",
"/ip4/209.159.149.14/udp/8336/quic-v1/p2p/Qmcq4Lmw45tbodvdRWZ8iGgy3rUcR3dikHTj1fBXP8VJqv",
"/ip4/148.251.9.90/udp/8336/quic-v1/p2p/QmRpKmQ1W83s6moBFpG6D6nrttkqdQSbdCJpvfxDVGcs38",
"/ip4/35.232.113.144/udp/8336/quic-v1/p2p/QmWxkBc7a17ZsLHhszLyTvKsoHMKvKae2XwfQXymiU66md",
"/ip4/34.87.85.78/udp/8336/quic-v1/p2p/QmTGguT5XhtvZZwTLnNQTN8Bg9eUm1THWEneXXHGhMDPrz",
"/ip4/34.81.199.27/udp/8336/quic-v1/p2p/QmTMMKpzCKJCwrnUzNu6tNj4P1nL7hVqz251245wsVpGNg",
"/ip4/34.143.255.235/udp/8336/quic-v1/p2p/QmeifsP6Kvq8A3yabQs6CBg7prSpDSqdee8P2BDQm9EpP8",
"/ip4/34.34.125.238/udp/8336/quic-v1/p2p/QmZdSyBJLm9UiDaPZ4XDkgRGXUwPcHJCmKoH6fS9Qjyko4",
"/ip4/34.80.245.52/udp/8336/quic-v1/p2p/QmNmbqobt82Vre5JxUGVNGEWn2HsztQQ1xfeg6mx7X5u3f",
"/dns/bravo-1.qcommander.sh/udp/8336/quic-v1/p2p/QmWFK1gVuhEqZdr8phTo3QbyLwjYmyivx31Zubqt7oR4XB",
"/ip4/109.199.100.108/udp/8336/quic-v1/p2p/Qma9fgugQc17MDu4YRSvnhfhVre6AYZ3nZdW8dSUYbsWvm",
"/ip4/47.251.49.193/udp/8336/quic-v1/p2p/QmP6ADPmMCsB8y82oFbrKTrwYWXt1CTMJ3jGNDXRHyYJgR",
"/ip4/138.201.203.208/udp/8336/quic-v1/p2p/QmbNhSTd4Y64ZCbV2gAXYR4ZFDdfRBMfrgWsNg99JHxsJo",
"/ip4/63.141.228.58/udp/8336/quic-v1/p2p/QmezARggdWKa1sw3LqE3LfZwVvtuCpXpK8WVo8EEdfakJV",
// purged peers (keep your node online to return to this list)
// "/ip4/204.186.74.47/udp/8317/quic-v1/p2p/Qmd233pLUDvcDW3ama27usfbG1HxKNh1V9dmWVW1SXp1pd",
// "/ip4/186.233.184.181/udp/8336/quic-v1/p2p/QmW6QDvKuYqJYYMP5tMZSp12X3nexywK28tZNgqtqNpEDL",
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 0x00
return 0x01
}
14 changes: 12 additions & 2 deletions node/crypto/wesolowski_frame_prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,12 +579,22 @@ func (w *WesolowskiFrameProver) VerifyWeakRecursiveProof(
}
}

func (w *WesolowskiFrameProver) CalculateChallengeProofDifficulty(
increment uint32,
) uint32 {
if increment >= 700000 {
return 25000
}

return 200000 - (increment / 4)
}

func (w *WesolowskiFrameProver) CalculateChallengeProof(
challenge []byte,
core uint32,
increment uint32,
) ([]byte, error) {
difficulty := 200000 - (increment / 4)
difficulty := w.CalculateChallengeProofDifficulty(increment)

instanceInput := binary.BigEndian.AppendUint32([]byte{}, core)
instanceInput = append(instanceInput, challenge...)
Expand All @@ -603,7 +613,7 @@ func (w *WesolowskiFrameProver) VerifyChallengeProof(
core uint32,
proof []byte,
) bool {
difficulty := 200000 - (increment / 4)
difficulty := w.CalculateChallengeProofDifficulty(increment)

if len(proof) != 516 {
return false
Expand Down
21 changes: 21 additions & 0 deletions node/crypto/wesolowski_frame_prover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,24 @@ func TestChallengeProof(t *testing.T) {
assert.NoError(t, err)
assert.True(t, w.VerifyChallengeProof([]byte{0x01, 0x02, 0x03}, 1, 0, proofs))
}

func TestCalculateChallengeProofDifficulty(t *testing.T) {
l, _ := zap.NewProduction()
w := crypto.NewWesolowskiFrameProver(l)

// At 0 increments, the difficulty should be 200,000
difficulty0 := w.CalculateChallengeProofDifficulty(0)
assert.Equal(t, 200000, difficulty0)

// At 100,000 increments, the difficulty should be 175,000
difficulty100k := w.CalculateChallengeProofDifficulty(100000)
assert.Equal(t, 175000, difficulty100k)

// At 700,000 increments, the difficulty should be 25,000
difficulty700k := w.CalculateChallengeProofDifficulty(700000)
assert.Equal(t, 25000, difficulty700k)

// At 800,000 increments, the difficulty should stay at 25,000
difficulty800k := w.CalculateChallengeProofDifficulty(800000)
assert.Equal(t, 25000, difficulty800k)
}
77 changes: 67 additions & 10 deletions node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"golang.org/x/crypto/sha3"
"google.golang.org/protobuf/proto"
"source.quilibrium.com/quilibrium/monorepo/node/protobufs"
"source.quilibrium.com/quilibrium/monorepo/node/store"
"source.quilibrium.com/quilibrium/monorepo/node/utils"

"github.com/cloudflare/circl/sign/ed448"
Expand Down Expand Up @@ -532,32 +533,48 @@ func RunMigrationIfNeeded(
configDir string,
nodeConfig *config.Config,
) {
shouldMigrate := false
shouldMigrate13 := false
shouldMigrate15 := false
migrationInfo := []byte{0x00, 0x00, 0x00}
_, err := os.Stat(filepath.Join(configDir, "MIGRATIONS"))
if err != nil && os.IsNotExist(err) {
fmt.Println("Migrations file not found, will perform migration...")
shouldMigrate = true
shouldMigrate13 = true
shouldMigrate15 = true
}

if !shouldMigrate {
if !shouldMigrate13 {
migrationInfo, err = os.ReadFile(filepath.Join(configDir, "MIGRATIONS"))
if err != nil {
panic(err)
}

if len(migrationInfo) < 3 ||
!bytes.Equal(migrationInfo, []byte{0x01, 0x04, 0x013}) {
(!bytes.Equal(migrationInfo, []byte{0x01, 0x04, 0x013}) &&
!bytes.Equal(migrationInfo, []byte{0x01, 0x04, 0x15})) {
fmt.Println("Migrations file outdated, will perform migration...")
shouldMigrate = true
shouldMigrate13 = true
shouldMigrate15 = true
}
}

// If subsequent migrations arise, we will need to distinguish by version
if shouldMigrate {
fmt.Println("Running migration...")
if !shouldMigrate15 {
migrationInfo, err = os.ReadFile(filepath.Join(configDir, "MIGRATIONS"))
if err != nil {
panic(err)
}

if len(migrationInfo) < 3 ||
!bytes.Equal(migrationInfo, []byte{0x01, 0x04, 0x15}) {
fmt.Println("Migrations file outdated, will perform migration...")
shouldMigrate13 = false
shouldMigrate15 = true
}
}

if shouldMigrate13 {
fmt.Println("Running 1.4.19 migration...")

// Easiest migration in the world.
err := os.RemoveAll(filepath.Join(configDir, "store"))
if err != nil {
fmt.Println("ERROR: Could not remove store, please be sure to do this before restarting the node.")
Expand All @@ -576,6 +593,40 @@ func RunMigrationIfNeeded(

fmt.Println("Migration completed.")
}

if shouldMigrate15 {
fmt.Println("Running 1.4.21.1 migration...")

db := store.NewPebbleDB(nodeConfig.DB)
logger, _ := zap.NewProduction()
proofStore := store.NewPebbleDataProofStore(db, logger)
peerId := getPeerID(nodeConfig.P2P)
increment, _, _, err := proofStore.GetLatestDataTimeProof([]byte(peerId))
if err != nil && (!errors.Is(err, store.ErrNotFound) || increment != 0) {
panic(err)
}

if increment > 699999 {
err := proofStore.RewindToIncrement([]byte(peerId), 699999)
if err != nil {
panic(err)
}
}

db.Close()

err = os.WriteFile(
filepath.Join(configDir, "MIGRATIONS"),
[]byte{0x01, 0x04, 0x15},
fs.FileMode(0600),
)
if err != nil {
fmt.Println("ERROR: Could not save migration file.")
panic(err)
}

fmt.Println("Migration completed.")
}
}

func RunSelfTestIfNeeded(
Expand Down Expand Up @@ -843,7 +894,7 @@ func printBalance(config *config.Config) {
fmt.Println("Unclaimed balance:", r.FloatString(12), "QUIL")
}

func printPeerID(p2pConfig *config.P2PConfig) {
func getPeerID(p2pConfig *config.P2PConfig) peer.ID {
peerPrivKey, err := hex.DecodeString(p2pConfig.PeerPrivKey)
if err != nil {
panic(errors.Wrap(err, "error unmarshaling peerkey"))
Expand All @@ -860,6 +911,12 @@ func printPeerID(p2pConfig *config.P2PConfig) {
panic(errors.Wrap(err, "error getting peer id"))
}

return id
}

func printPeerID(p2pConfig *config.P2PConfig) {
id := getPeerID(p2pConfig)

fmt.Println("Peer ID: " + id.String())
}

Expand Down
Loading

0 comments on commit fd30b59

Please sign in to comment.