Conversation
| "gopkg.in/mgo.v2/bson" | ||
| ) | ||
|
|
||
| const ( |
There was a problem hiding this comment.
Can we set it to at least 4? so that we can test out the byzantine fault tolerance. Tendermint will continue to produce blocks as long as more than 2/3 of validators are non-malicious.
There was a problem hiding this comment.
yes you are right, that was originally 4 but I've started decreasing it when I struggled to set up nodes locally.
| fmt.Println("user validated!") | ||
|
|
||
| // validate validator exists & update votes | ||
| validatorID := bson.ObjectIdHex(entity["validator"].(string)) |
There was a problem hiding this comment.
It is also possible to retrieve validatorID via the publicKey. This way you won't have to supply validatorID separately for voting from the front-end. Supplying just the publicKey of the person will suffice.
There was a problem hiding this comment.
nice. Didn't realise that. Make sense since NodeId is derived the same way
There was a problem hiding this comment.
i got back to this comment now and realised it doesnt work for me.. let's discuss it in the morning
| // validate validator exists & update votes | ||
| validatorID := bson.ObjectIdHex(entity["validator"].(string)) | ||
| err = db.C("validators").Update(bson.M{"_id": validatorID}, bson.M{"$addToSet": bson.M{"votes": user.ID}}) | ||
| if err != nil { |
There was a problem hiding this comment.
We are doing only $addToSet here. What about the scenario when the user wants to retract the vote assigned to a particular person?
There was a problem hiding this comment.
Thought of that but I didnt implement it as I wanted to test what I had first and was struggling with that at the end.
There was a problem hiding this comment.
I've added scenario to downvote validator.
jsonstore/jsonstore.go
Outdated
| // that could be considered an issue depending on requirements | ||
| project := bson.M{ | ||
| "$project": bson.M{ | ||
| "name": 1, |
There was a problem hiding this comment.
We don't have to use aggregation if we just maintain another property called votes (integer) in the validator documents.
There was a problem hiding this comment.
good point. Could have added "increment" and new field
There was a problem hiding this comment.
added vote count as a part of adding extra collection
mint.go
Outdated
| var app types.Application | ||
|
|
||
| session, err := mgo.Dial("localhost") | ||
| fmt.Println("running aginst mongo: ", os.Getenv("MONGO_URL")) |
There was a problem hiding this comment.
If Mongo_URL env is not set, what does it use by default?
There was a problem hiding this comment.
it uses localhost:27017 but tbh its not obvious from the client library code... When I added it and run it just still worked which surprised me too. (unless there is another bug I missed ;) )
There was a problem hiding this comment.
so turned out i was wrong and it doesn't default to localhost:27017.. must have forgotten i've added it. This way or the other im removing it as well as removing override for the ABCI port. Since you may be merging it there is no point in me forcing code basically added for testing
jsonstore/jsonstore.go
Outdated
| ID bson.ObjectId `bson:"_id" json:"_id"` | ||
| Name string `bson:"name" json:"name"` | ||
| PublicKey []byte `bson:"publicKey" json:"publicKey"` | ||
| Votes []bson.ObjectId `bson:"votes" json:"votes"` |
There was a problem hiding this comment.
Validator documents can quickly grow in size (MongoDB documents have a 16MB size limit) if we store the ObjectIDs of voters in the same document (Votes array). There is no upper limit to the number of voters. I would suggest storing the votes count in the document itself and move the ObjectIDs of voters to a separate junction collection. This will also help us sort the validators efficiently.
There was a problem hiding this comment.
as discussed added UserValidatorVote collection
jsonstore/jsonstore.go
Outdated
| if validators != nil { | ||
| for _, element := range validators { | ||
| validator := Validator{ | ||
| ID: bson.NewObjectId(), |
There was a problem hiding this comment.
that's a bug. We cannot generate random value for each like that cos it will create different IDs on on every validator node.
…ike Address, PubKey etc., adding code for testing
adding script to trigger multiple nodes locally
…ling upgrading tendermint to have proper access to Validators attributes l…
No description provided.