Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go-kosu: fixing witness issues #230

Merged
merged 3 commits into from Aug 27, 2019
Merged

go-kosu: fixing witness issues #230

merged 3 commits into from Aug 27, 2019

Conversation

@hrharder
Copy link
Member

hrharder commented Aug 23, 2019

Overview

Fixing three small issues in the Witness.

Description

While working on the Explore API server and kosu.js Go-Kosu client, I noticed a few weird things via the RPC server that indicated underlying errors, all of which occurred in the witness.

1. Rebalance periods skip 10 blocks

I noticed this:

> kosu.node.roundInfo().then(console.log)
> { number: 89, limit: 10, startsAt: 1976, endsAt: 1986 }
> kosu.node.roundInfo().then(console.log)
> { number: 90, limit: 10, startsAt: 1996, endsAt: 2006 }

Round 90 should have had startsAt: 1986 and endsAt: 1996. The reason for this error was rebalance was being called with the current Ethereum block, not the matured Ethereum block, causing the 10 block discrepancy. This is now fixed.

2. Poster accounts not associated with the right address

After registering a poster account, I was able to see the account was created with kosu_numberPosters, but unable to query it with kosu_queryPoster. After adding some log statements, I noticed the address being associated with the account was not my address, and was one I did not reckognize.

The source of the failure was the TransactionWitness TX was being created in the Witness with the Address of the contract that emitted the event, not the address contained within the event data. Certainly easy to miss, and now should be fixed.

3. Validator Ethereum addresses being padded

In a similar vein to the above issue, I noticed validator objects were being sent over (from kosu_queryValidator) like this:

{ 
  balance: 500000000000000000000,
  power: 500,
  publicKey: 'wy9oIwzlO+KEItHZvvA9H9MnfqZNnO1bghLVZUgpJX8=',
  ethAccount:
   '000000000000000000000000c521f483f607eb5ea4d6b2dfdbd540134753a865',
  firstVote: 2319,
  lastVoted: 2320,
  lastProposed: 2321,
  totalVotes: 3,
  active: true,
  applied: true 
}

As you can see, there is 12 bytes of padding on the ethAccount that shouldn't be there. This was because all event data from the KosuEvent is padded to 32 bytes, so the first 12 empty bytes just need to be stripped off.

Notes

@gchaincl let me know what you think of these changes, and if you would approach any of them differently than I did.

@hrharder hrharder added the bug label Aug 23, 2019
@hrharder hrharder requested a review from gchaincl Aug 23, 2019
@hrharder hrharder added the WIP label Aug 23, 2019
@hrharder

This comment has been minimized.

Copy link
Member Author

hrharder commented Aug 23, 2019

I've noticed an issue running this branch, that I also saw the one other time I deployed a multi-node test network.

It seems that the nodes are unable to rebalance (every proposal gets rejected) and it's not clear to me why. This was tested on the Ropsten network.

hrharder and others added 2 commits Aug 26, 2019
@gchaincl gchaincl merged commit c4529a7 into master Aug 27, 2019
1 check passed
1 check passed
continuous-integration/drone/pr Build is passing
Details
@gchaincl gchaincl deleted the fix/go-kosu/witness-errors branch Aug 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.