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

Track Previously Seen Merkle Index to Prevent Duplicate Log Spam #1566

Merged
merged 40 commits into from
Feb 12, 2019

Conversation

rauljordan
Copy link
Contributor

@rauljordan rauljordan commented Feb 12, 2019

Part of #1565


Description

Write why you are making the changes in this pull request

Sometimes we might receive duplicate logs from the ETH1.0 nodes we are connected to, causing our powchain service to unnecessarily update its deposit trie with this log even though we have already seen this Merkle index. This is a bug as it leaves our trie with an inconsistent root.

Write a summary of the changes you are making

This PR introduces a variable called lastReceivedMerkleIndex in our powchain service which we use to check if we have already seen a Merkle index, preventing unnecessary updates to the trie. This PR adds a test for this duplicate log spam to check the root does not change.

@codecov
Copy link

codecov bot commented Feb 12, 2019

Codecov Report

Merging #1566 into master will decrease coverage by 0.59%.
The diff coverage is 100%.

@@            Coverage Diff            @@
##           master    #1566     +/-   ##
=========================================
- Coverage   71.98%   71.39%   -0.6%     
=========================================
  Files          99       99             
  Lines        6732     6568    -164     
=========================================
- Hits         4846     4689    -157     
+ Misses       1471     1466      -5     
+ Partials      415      413      -2

@rauljordan rauljordan self-assigned this Feb 12, 2019
@rauljordan rauljordan added this to the Sapphire milestone Feb 12, 2019
@rauljordan rauljordan requested review from nisdas, prestonvanloon and terencechain and removed request for nisdas and prestonvanloon February 12, 2019 17:23
Copy link
Member

@terencechain terencechain left a comment

Choose a reason for hiding this comment

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

just one small comment

BeaconDB: &db.BeaconDB{},
})
if err != nil {
t.Fatalf("unable to setup web3 ETH1.0 chain service: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

s/unable/Unable

// ETH1.0 network, and prevents us from updating our trie
// with the same log twice, causing an inconsistent state root.
index := binary.LittleEndian.Uint64(merkleTreeIndex)
if int64(index) == w.lastReceivedMerkleIndex {
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 be

if int64(index) <= w.lastReceivedMerkleIndex {

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch

@rauljordan rauljordan merged commit cd415b0 into master Feb 12, 2019
@rauljordan rauljordan deleted the track-prev-index branch February 12, 2019 19:50
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.

3 participants