-
Notifications
You must be signed in to change notification settings - Fork 682
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix P-chain validator set lookup race condition (#2672)
Co-authored-by: Darioush Jalali <[email protected]>
- Loading branch information
1 parent
39bb11f
commit 68980eb
Showing
10 changed files
with
191 additions
and
65 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package gossip | ||
|
||
import ( | ||
"google.golang.org/protobuf/proto" | ||
|
||
"github.com/ava-labs/avalanchego/ids" | ||
"github.com/ava-labs/avalanchego/proto/pb/sdk" | ||
"github.com/ava-labs/avalanchego/utils/bloom" | ||
) | ||
|
||
func MarshalAppRequest(filter, salt []byte) ([]byte, error) { | ||
request := &sdk.PullGossipRequest{ | ||
Filter: filter, | ||
Salt: salt, | ||
} | ||
return proto.Marshal(request) | ||
} | ||
|
||
func ParseAppRequest(bytes []byte) (*bloom.ReadFilter, ids.ID, error) { | ||
request := &sdk.PullGossipRequest{} | ||
if err := proto.Unmarshal(bytes, request); err != nil { | ||
return nil, ids.Empty, err | ||
} | ||
|
||
salt, err := ids.ToID(request.Salt) | ||
if err != nil { | ||
return nil, ids.Empty, err | ||
} | ||
|
||
filter, err := bloom.Parse(request.Filter) | ||
return filter, salt, err | ||
} | ||
|
||
func MarshalAppResponse(gossip [][]byte) ([]byte, error) { | ||
return proto.Marshal(&sdk.PullGossipResponse{ | ||
Gossip: gossip, | ||
}) | ||
} | ||
|
||
func ParseAppResponse(bytes []byte) ([][]byte, error) { | ||
response := &sdk.PullGossipResponse{} | ||
err := proto.Unmarshal(bytes, response) | ||
return response.Gossip, err | ||
} | ||
|
||
func MarshalAppGossip(gossip [][]byte) ([]byte, error) { | ||
return proto.Marshal(&sdk.PushGossip{ | ||
Gossip: gossip, | ||
}) | ||
} | ||
|
||
func ParseAppGossip(bytes []byte) ([][]byte, error) { | ||
msg := &sdk.PushGossip{} | ||
err := proto.Unmarshal(bytes, msg) | ||
return msg.Gossip, err | ||
} |
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
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
Oops, something went wrong.