Skip to content

Commit

Permalink
bump reindex id
Browse files Browse the repository at this point in the history
  • Loading branch information
vaultec81 committed Mar 8, 2024
1 parent c2969dc commit ccf286f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/services/new/witness/electionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ export class ElectionManager {
return witnesses.map(e => {
return {
account: e.account,
key: e.keys.find(b => b.t === 'consensus').key
key: e.keys.find(b => b.t === 'consensus')?.key
}
})
}).filter(e => !!e.key)
}
}

Expand Down Expand Up @@ -367,7 +367,7 @@ export class ElectionManager {

//Don't require 2/3 consensus for initial startup.
const voteMajority = 2/3
if(isValid && (((pubKeys.length / members.length) < voteMajority) || json.epoch === 0)) {
if(isValid && (((pubKeys.length / members.length) > voteMajority) || json.epoch === 0)) {
//Must be valid
const fullContent = (await this.self.ipfs.dag.get(CID.parse(json.data))).value

Expand Down Expand Up @@ -486,7 +486,7 @@ export class ElectionManager {

const members = await this.getMembersOfBlock(blk)
const voteMajority = calcVotingWeight(0); //Hardcode for 0 until the future
if((((circuit.aggPubKeys.size / members.length) < voteMajority) || electionHeader.epoch < 200)) {
if((((circuit.aggPubKeys.size / members.length) > voteMajority) || electionHeader.epoch < 200)) {
//Must be valid

const electionResult = {
Expand Down Expand Up @@ -533,7 +533,7 @@ export class ElectionManager {

//Don't require 2/3 consensus for initial startup.
const voteMajority = 2/3
if(isValid && (((pubKeys.length / members.length) < voteMajority) || electionResult.epoch === 0)) {
if(isValid && (((pubKeys.length / members.length) > voteMajority) || electionResult.epoch === 0)) {
//Must be valid
const fullContent = (await this.self.ipfs.dag.get(CID.parse(electionResult.data))).value

Expand Down
8 changes: 6 additions & 2 deletions src/services/new/witness/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,8 @@ export class WitnessServiceV2 {
const circuit = new BlsCircuit({
hash: blockHash.bytes
})
const keysMap = (await this.self.electionManager.getMembersOfBlock(block_height)).map(e => e.key)
const membersOfBlock = (await this.self.electionManager.getMembersOfBlock(block_height))
const keysMap = membersOfBlock.map(e => e.key)

const signedData = await this.self.consensusKey.signRaw(blockHash.bytes);
console.log('signedData', signedData)
Expand All @@ -559,6 +560,7 @@ export class WitnessServiceV2 {
// console.log('witness.sign', blockHeader)
// console.log(keysMap)


let voteMajority = 0.67
for await(let sigMsg of drain) {
const from = sigMsg.from
Expand Down Expand Up @@ -587,7 +589,9 @@ export class WitnessServiceV2 {
sig,
did: pub,
})


const signerNode = membersOfBlock.find(e => e.key === pub)
console.log('signerNode', signerNode, pub)

// console.log('result', pub)
// console.log('aggregated DID', circuit.did.id)
Expand Down
2 changes: 1 addition & 1 deletion src/services/new/witness/versionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Collection } from "mongodb";


export const VersionConfig = {
index_reset_id: 5,
index_reset_id: 6,
//Match with package.json and tag
version_id: 'v0.1.1'
}
Expand Down

0 comments on commit ccf286f

Please sign in to comment.