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

Support multiple instance #20

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Support multiple instance #20

wants to merge 5 commits into from

Conversation

Lbqds
Copy link
Member

@Lbqds Lbqds commented Jan 17, 2022

No description provided.

@killerwhile
Copy link
Member

LGMT, thanks!

Copy link
Member

@killerwhile killerwhile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed more in depth the atomicity logic of the duplicate solution corner case, and it could be improved.


var share1 = {job: {fromGroup: 0, toGroup: 1}, foundBlock: false, blockHash: 'hash1', difficulty: 1, workerAddress: 'miner1'};
var share2 = {job: {fromGroup: 0, toGroup: 1}, foundBlock: false, blockHash: 'hash2', difficulty: 2, workerAddress: 'miner1'};
var invalidShare = {job: {fromGroup: 0, toGroup: 1}, foundBlock: false, blockHash: 'hash1', difficulty: 3, workerAddress: 'miner1'};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it more relevant to be from a different worker address?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we check if a share is duplicated based on hash, but it's good for testing, thanks.

var newKey = _this.roundKey(fromGroup, toGroup, blockHash);
var blockWithTs = blockHash + ':' + currentMs.toString();

redisTx.rename(currentRound, newKey);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamenx should probably be used here, otherwise in case of found block sent with delay (but still not expired) by one worker, the sharecache key would have been deleted and the shares for the block overwritten by new currentRound.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch, thanks, the remaining commands will continue to execute even if renamenx failed in redis transaction, so my thought is that we can use set hash true ex expiryPeriod nx to check if the share is duplicated, which expiryPeriod > jobExpiryPeriod, how do you think?


redisTx.rename(currentRound, newKey);
redisTx.sadd(pendingBlocksKey, blockWithTs);
redisTx.hset(foundBlocksKey, blockHash, share.workerAddress)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hsetnx should be used here, so that "paternity" of the block is kept to the first worker who submitted it (in case of same corner case than above)

Copy link

@rfkih rfkih left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello

@sergeybrava
Copy link

-_-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants