-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Changes from 37 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
86fcda2
using little endian and tests for encoding dep inputs
c74307c
use decode value and timestamp method in state
19f3686
updated comments to match serialization format
1927a41
latest compiled contract, abi, bytecode, and bindings
4a74367
resolve some conflicts
92410cb
to little endian everywhere
f60565b
fix all tests except for contract tests
156705c
Merge branch 'new-contract' into fix-encoding-decoding
df64ad9
include contract changes
5d81cba
Merge branch 'master' into fix-encoding-decoding
rauljordan 21a3a9d
Merge branch 'master' into fix-encoding-decoding
terencechain dee0a28
address broken build
cbc8066
Merge branch 'master' into fix-encoding-decoding
rauljordan da6a588
compile with vyper v8
5522e79
update readme
b35fddf
merge master
2949353
Merge branch 'master' into fix-encoding-decoding
rauljordan f319e02
fix pkg name
0f9f0e2
add skip chainstart delay
b0cf284
skip chainstart delay tests pass
07af614
Merge branch 'master' into fix-encoding-decoding
rauljordan 95513e5
to little endian timestamp
7848df0
Merge branch 'fix-encoding-decoding' of github.com:prysmaticlabs/prys…
eae8948
pull origin
416c1de
using genesis timestamp instead of bool
bb7f5cd
update with gofmt
c61424a
Merge branch 'master' into no-merkle-prestart
rauljordan b036fca
make more fields public
6250120
resolve with master
9e2a1ad
Merge branch 'no-merkle-prestart' into track-prev-index
b014659
duplicate log spam inconsistent root fixed by tracking last seen index
93519db
resolve confs with master
6686957
sync with master
c0d6569
readd weird removal of import
bf5d95b
readd libp2p import
4cbe966
gazelle
1646ae7
readd eth
574e8bb
Merge branch 'master' into track-prev-index
rauljordan 6852d47
comments
664a926
Merge branch 'track-prev-index' of github.com:prysmaticlabs/prysm int…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ import ( | |
"testing" | ||
"time" | ||
|
||
"github.com/ethereum/go-ethereum" | ||
ethereum "github.com/ethereum/go-ethereum" | ||
"github.com/ethereum/go-ethereum/accounts/abi/bind" | ||
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends" | ||
"github.com/ethereum/go-ethereum/common" | ||
|
@@ -533,6 +533,71 @@ func TestProcessDepositLog_InsertsPendingDeposit(t *testing.T) { | |
} | ||
} | ||
|
||
func TestProcessDepositLog_SkipDuplicateLog(t *testing.T) { | ||
endpoint := "ws://127.0.0.1" | ||
testAcc, err := setup() | ||
if err != nil { | ||
t.Fatalf("Unable to set up simulated backend %v", err) | ||
} | ||
web3Service, err := NewWeb3Service(context.Background(), &Web3ServiceConfig{ | ||
Endpoint: endpoint, | ||
DepositContract: testAcc.contractAddr, | ||
Reader: &goodReader{}, | ||
Logger: &goodLogger{}, | ||
ContractBackend: testAcc.backend, | ||
BeaconDB: &db.BeaconDB{}, | ||
}) | ||
if err != nil { | ||
t.Fatalf("unable to setup web3 ETH1.0 chain service: %v", err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/unable/Unable |
||
} | ||
|
||
testAcc.backend.Commit() | ||
|
||
web3Service.depositTrie = trieutil.NewDepositTrie() | ||
|
||
var stub [48]byte | ||
copy(stub[:], []byte("testing")) | ||
|
||
data := &pb.DepositInput{ | ||
Pubkey: stub[:], | ||
ProofOfPossession: stub[:], | ||
WithdrawalCredentialsHash32: []byte("withdraw"), | ||
} | ||
|
||
serializedData := new(bytes.Buffer) | ||
if err := ssz.Encode(serializedData, data); err != nil { | ||
t.Fatalf("Could not serialize data %v", err) | ||
} | ||
|
||
testAcc.txOpts.Value = amount32Eth | ||
if _, err := testAcc.contract.Deposit(testAcc.txOpts, serializedData.Bytes()); err != nil { | ||
t.Fatalf("Could not deposit to VRC %v", err) | ||
} | ||
|
||
testAcc.backend.Commit() | ||
|
||
query := ethereum.FilterQuery{ | ||
Addresses: []common.Address{ | ||
web3Service.depositContractAddress, | ||
}, | ||
} | ||
|
||
logs, err := testAcc.backend.FilterLogs(web3Service.ctx, query) | ||
if err != nil { | ||
t.Fatalf("Unable to retrieve logs %v", err) | ||
} | ||
|
||
web3Service.ProcessDepositLog(logs[0]) | ||
// We keep track of the current deposit root and make sure it doesn't change if we | ||
// receive a duplicate log from the contract. | ||
currentRoot := web3Service.depositTrie.Root() | ||
web3Service.ProcessDepositLog(logs[0]) | ||
nextRoot := web3Service.depositTrie.Root() | ||
if currentRoot != nextRoot { | ||
t.Error("Processing a duplicate log should not update deposit trie") | ||
} | ||
} | ||
|
||
func TestUnpackDepositLogs(t *testing.T) { | ||
endpoint := "ws://127.0.0.1" | ||
testAcc, err := setup() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch