diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index ae2a166c2d..717e935c64 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -40,7 +40,7 @@ jobs: - name: Up to date Go proto generated run: | go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28 && \ - PROTOC_VERSION=21.10 && \ + PROTOC_VERSION=24.4 && \ curl -sL --output protoc.zip "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip" && \ sudo unzip protoc.zip -d /usr/local && \ rm protoc.zip && \ diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml deleted file mode 100644 index 03e2fc7ebb..0000000000 --- a/.github/workflows/development.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Trigger Multiple Gossamer Deployments - -on: - push: - branches: - - development - -jobs: - dispatch: - runs-on: ubuntu-latest - strategy: - matrix: - chain: [paseo, westend] # List of chains to deploy - steps: - - name: Dispatch Repository Event for ${{ matrix.chain }} - uses: peter-evans/repository-dispatch@v3 - with: - token: ${{ secrets.PAT }} - repository: Chainsafe/infrastructure-general - event-type: deploy-gossamer-snapshot - client-payload: '{"ref": "refs/heads/main", "inputs": {"chain": "${{ matrix.chain }}"}}' diff --git a/.github/workflows/dispatch.yml b/.github/workflows/dispatch.yml new file mode 100644 index 0000000000..b88c53ab11 --- /dev/null +++ b/.github/workflows/dispatch.yml @@ -0,0 +1,59 @@ +name: Dispatch workflow to deploy Gossamer nodes + +on: + workflow_dispatch: + inputs: + commit: + description: 'commit' + required: true + nodeType: + description: 'Node type' + required: true + default: 'genesis' + type: choice + options: + - snapshot + - genesis + cluster: + description: 'Cluster' + default: 'shared-gossamer' + type: choice + options: + - shared-gossamer + - shared-gossamer-2 + required: true + chain: + description: 'Chain' + required: true + default: 'westend' + type: choice + options: + - paseo + - westend + +jobs: + dispatch: + runs-on: ubuntu-latest + steps: + - name: Get Token + id: get_workflow_token + uses: peter-murray/workflow-application-token-action@v3 + with: + application_id: ${{ vars.APPLICATION_ID }} + application_private_key: ${{ secrets.APPLICATION_PRIVATE_KEY }} + + - name: Dispatch Repository Event for ${{ github.event.inputs.chain }} + uses: peter-evans/repository-dispatch@v3 + with: + token: ${{ steps.get_workflow_token.outputs.token }} + repository: Chainsafe/infrastructure-general + event-type: deploy-gossamer-${{ github.event.inputs.nodeType }} + client-payload: | + { + "ref": "refs/heads/main", + "inputs": { + "commit": "${{ github.event.inputs.commit }}", + "chain": "${{ github.event.inputs.chain }}", + "cluster": "${{ github.event.inputs.cluster }}" + } + } diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 040b4393e0..f2aadc34b1 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -46,7 +46,7 @@ jobs: image: ${{ steps.build-image.outputs.image }} - name: Deploy Amazon ECS task definition - uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + uses: aws-actions/amazon-ecs-deploy-task-definition@v2 with: task-definition: ${{ steps.task-def.outputs.task-definition }} service: gossamer-${{ matrix.chain }}-svc diff --git a/Dockerfile.development b/Dockerfile.development index ea054e45d1..01c8c5cc4f 100644 --- a/Dockerfile.development +++ b/Dockerfile.development @@ -1,4 +1,4 @@ -FROM golang:1.22 +FROM golang:1.23 ARG chain="polkadot" ARG basepath="~/.local/share/gossamer" diff --git a/Dockerfile.staging b/Dockerfile.staging index ded6ef723d..eacc5e6a8c 100644 --- a/Dockerfile.staging +++ b/Dockerfile.staging @@ -1,4 +1,4 @@ -FROM golang:1.22 +FROM golang:1.23 ARG chain="polkadot" ARG basepath="~/.local/share/gossamer" diff --git a/README.md b/README.md index 4e7395a63c..f3041ae34b 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,30 @@ Then start the three hosts: ./bin/gossamer --chain westend-local --charlie ``` +## Standalone Packages + +In addition to the core functionality provided by Gossamer, we have developed some standalone packages that can be used independently. These packages are located in the `pkg` directory and serve various utility purposes. Here’s an overview of some of these packages: + +### Scale + +To support parity's [scale type encoding](https://docs.substrate.io/reference/scale-codec/) in golang. +More details [here](./pkg/scale/README.md) + +### Trie + +The `trie` package includes multiple implementations of polkadot merkle tries. These implementations are useful for various applications requiring efficient data structures. Here are the key implementations: + +#### In-Memory Trie + +This implementation supports polkadot merkle tries that are stored entirely in memory. It includes features for backing up the trie using a database to ensure persistence. + +#### TrieDB + +An evolution of the in-memory trie, `TrieDB` introduces lazy loading capabilities from the underlying database. This approach optimizes performance and resource usage by loading data only as needed. + +For more details on how to use `TrieDB`, refer to the specific [README](pkg/trie/triedb/README.md) + + ## Contribute - Check out the [Contributing Guidelines](.github/CONTRIBUTING.md) and our diff --git a/dot/core/service.go b/dot/core/service.go index 73ef05bcce..740f186e8f 100644 --- a/dot/core/service.go +++ b/dot/core/service.go @@ -280,7 +280,7 @@ func (s *Service) handleBlock(block *types.Block, state *rtstorage.TrieState) er } logger.Debugf("imported block %s and stored state trie with root %s", - block.Header.Hash(), state.MustRoot()) + block.Header.Hash(), state.Trie().MustHash()) parentRuntimeInstance, err := s.blockState.GetRuntime(block.Header.ParentHash) if err != nil { diff --git a/dot/network/errors.go b/dot/network/errors.go index d1037b1a7b..80ccea0f94 100644 --- a/dot/network/errors.go +++ b/dot/network/errors.go @@ -10,19 +10,16 @@ import ( var ( ErrNoPeersConnected = errors.New("no peers connected") ErrReceivedEmptyMessage = errors.New("received empty message") - ErrNilBlockInResponse = errors.New("nil block in response") - errCannotValidateHandshake = errors.New("failed to validate handshake") - errMessageTypeNotValid = errors.New("message type is not valid") - errInvalidHandshakeForPeer = errors.New("peer previously sent invalid handshake") - errHandshakeTimeout = errors.New("handshake timeout reached") - errBlockRequestFromNumberInvalid = errors.New("block request message From number is not valid") - errInvalidStartingBlockType = errors.New("invalid StartingBlock in messsage") - errInboundHanshakeExists = errors.New("an inbound handshake already exists for given peer") - errInvalidRole = errors.New("invalid role") - ErrFailedToReadEntireMessage = errors.New("failed to read entire message") - ErrNilStream = errors.New("nil stream") - ErrInvalidLEB128EncodedData = errors.New("invalid LEB128 encoded data") - ErrGreaterThanMaxSize = errors.New("greater than maximum size") - ErrStreamReset = errors.New("stream reset") + errCannotValidateHandshake = errors.New("failed to validate handshake") + errMessageTypeNotValid = errors.New("message type is not valid") + errInvalidHandshakeForPeer = errors.New("peer previously sent invalid handshake") + errHandshakeTimeout = errors.New("handshake timeout reached") + errInboundHanshakeExists = errors.New("an inbound handshake already exists for given peer") + errInvalidRole = errors.New("invalid role") + ErrFailedToReadEntireMessage = errors.New("failed to read entire message") + ErrNilStream = errors.New("nil stream") + ErrInvalidLEB128EncodedData = errors.New("invalid LEB128 encoded data") + ErrGreaterThanMaxSize = errors.New("greater than maximum size") + ErrStreamReset = errors.New("stream reset") ) diff --git a/dot/network/helpers_test.go b/dot/network/helpers_test.go index 0ab64e7cce..24d4abba46 100644 --- a/dot/network/helpers_test.go +++ b/dot/network/helpers_test.go @@ -10,6 +10,7 @@ import ( "testing" "time" + "github.com/ChainSafe/gossamer/dot/network/messages" "github.com/ChainSafe/gossamer/dot/types" "github.com/ChainSafe/gossamer/internal/log" "github.com/ChainSafe/gossamer/lib/common" @@ -32,14 +33,14 @@ const ( ) type testStreamHandler struct { - messages map[peer.ID][]Message + messages map[peer.ID][]messages.P2PMessage decoder messageDecoder exit bool } func newTestStreamHandler(decoder messageDecoder) *testStreamHandler { return &testStreamHandler{ - messages: make(map[peer.ID][]Message), + messages: make(map[peer.ID][]messages.P2PMessage), decoder: decoder, } } @@ -55,7 +56,7 @@ func (s *testStreamHandler) handleStream(stream libp2pnetwork.Stream) { s.readStream(stream, peer, s.decoder, s.handleMessage) } -func (s *testStreamHandler) handleMessage(stream libp2pnetwork.Stream, msg Message) error { +func (s *testStreamHandler) handleMessage(stream libp2pnetwork.Stream, msg messages.P2PMessage) error { msgs := s.messages[stream.Conn().RemotePeer()] s.messages[stream.Conn().RemotePeer()] = append(msgs, msg) @@ -65,7 +66,7 @@ func (s *testStreamHandler) handleMessage(stream libp2pnetwork.Stream, msg Messa return s.writeToStream(stream, announceHandshake) } -func (s *testStreamHandler) writeToStream(stream libp2pnetwork.Stream, msg Message) error { +func (s *testStreamHandler) writeToStream(stream libp2pnetwork.Stream, msg messages.P2PMessage) error { encMsg, err := msg.Encode() if err != nil { return err @@ -124,24 +125,26 @@ var starting, _ = variadic.NewUint32OrHash(uint32(1)) var one = uint32(1) -func newTestBlockRequestMessage(t *testing.T) *BlockRequestMessage { +func newTestBlockRequestMessage(t *testing.T) *messages.BlockRequestMessage { t.Helper() - return &BlockRequestMessage{ - RequestedData: RequestedDataHeader + RequestedDataBody + RequestedDataJustification, + return &messages.BlockRequestMessage{ + RequestedData: messages.RequestedDataHeader + + messages.RequestedDataBody + + messages.RequestedDataJustification, StartingBlock: *starting, Direction: 1, Max: &one, } } -func testBlockRequestMessageDecoder(in []byte, _ peer.ID, _ bool) (Message, error) { - msg := new(BlockRequestMessage) +func testBlockRequestMessageDecoder(in []byte, _ peer.ID, _ bool) (messages.P2PMessage, error) { + msg := new(messages.BlockRequestMessage) err := msg.Decode(in) return msg, err } -func testBlockAnnounceMessageDecoder(in []byte, _ peer.ID, _ bool) (Message, error) { +func testBlockAnnounceMessageDecoder(in []byte, _ peer.ID, _ bool) (messages.P2PMessage, error) { msg := BlockAnnounceMessage{ Number: 0, Digest: types.NewDigest(), @@ -150,7 +153,7 @@ func testBlockAnnounceMessageDecoder(in []byte, _ peer.ID, _ bool) (Message, err return &msg, err } -func testBlockAnnounceHandshakeDecoder(in []byte, _ peer.ID, _ bool) (Message, error) { +func testBlockAnnounceHandshakeDecoder(in []byte, _ peer.ID, _ bool) (messages.P2PMessage, error) { msg := new(BlockAnnounceHandshake) err := msg.Decode(in) return msg, err @@ -280,11 +283,11 @@ func createTestService(t *testing.T, cfg *Config) (srvc *Service) { return srvc } -func newTestBlockResponseMessage(t *testing.T) *BlockResponseMessage { +func newTestBlockResponseMessage(t *testing.T) *messages.BlockResponseMessage { t.Helper() const blockRequestSize = 128 - msg := &BlockResponseMessage{ + msg := &messages.BlockResponseMessage{ BlockData: make([]*types.BlockData, blockRequestSize), } diff --git a/dot/network/host.go b/dot/network/host.go index a3d30ed21b..97984ce576 100644 --- a/dot/network/host.go +++ b/dot/network/host.go @@ -14,6 +14,7 @@ import ( "sync" "time" + "github.com/ChainSafe/gossamer/dot/network/messages" "github.com/ChainSafe/gossamer/dot/peerset" "github.com/ChainSafe/gossamer/internal/pubip" "github.com/dgraph-io/ristretto" @@ -330,7 +331,7 @@ func (h *host) bootstrap() { // send creates a new outbound stream with the given peer and writes the message. It also returns // the newly created stream. -func (h *host) send(p peer.ID, pid protocol.ID, msg Message) (network.Stream, error) { +func (h *host) send(p peer.ID, pid protocol.ID, msg messages.P2PMessage) (network.Stream, error) { // open outbound stream with host protocol id stream, err := h.p2pHost.NewStream(h.ctx, p, pid) if err != nil { @@ -354,7 +355,7 @@ func (h *host) send(p peer.ID, pid protocol.ID, msg Message) (network.Stream, er return stream, nil } -func (h *host) writeToStream(s network.Stream, msg Message) error { +func (h *host) writeToStream(s network.Stream, msg messages.P2PMessage) error { encMsg, err := msg.Encode() if err != nil { return err diff --git a/dot/network/light.go b/dot/network/light.go index 0943cb823d..de34eb465c 100644 --- a/dot/network/light.go +++ b/dot/network/light.go @@ -6,6 +6,7 @@ package network import ( "fmt" + "github.com/ChainSafe/gossamer/dot/network/messages" "github.com/ChainSafe/gossamer/dot/types" "github.com/ChainSafe/gossamer/lib/common" "github.com/ChainSafe/gossamer/pkg/scale" @@ -19,7 +20,7 @@ func (s *Service) handleLightStream(stream libp2pnetwork.Stream) { s.readStream(stream, s.decodeLightMessage, s.handleLightMsg, MaxBlockResponseSize) } -func (s *Service) decodeLightMessage(in []byte, peer peer.ID, _ bool) (Message, error) { +func (s *Service) decodeLightMessage(in []byte, peer peer.ID, _ bool) (messages.P2PMessage, error) { s.lightRequestMu.RLock() defer s.lightRequestMu.RUnlock() @@ -33,7 +34,7 @@ func (s *Service) decodeLightMessage(in []byte, peer peer.ID, _ bool) (Message, return newLightRequestFromBytes(in) } -func (s *Service) handleLightMsg(stream libp2pnetwork.Stream, msg Message) (err error) { +func (s *Service) handleLightMsg(stream libp2pnetwork.Stream, msg messages.P2PMessage) (err error) { defer func() { err := stream.Close() if err != nil && err.Error() != ErrStreamReset.Error() { diff --git a/dot/network/message.go b/dot/network/message.go index 774d18cacb..40aa361939 100644 --- a/dot/network/message.go +++ b/dot/network/message.go @@ -4,22 +4,12 @@ package network import ( - "encoding/binary" - "errors" "fmt" - "google.golang.org/protobuf/proto" - - pb "github.com/ChainSafe/gossamer/dot/network/proto" - "github.com/ChainSafe/gossamer/dot/types" + "github.com/ChainSafe/gossamer/dot/network/messages" "github.com/ChainSafe/gossamer/lib/common" - "github.com/ChainSafe/gossamer/lib/common/variadic" - "github.com/ChainSafe/gossamer/pkg/scale" ) -// MaxBlocksInResponse is maximum number of block data a BlockResponse message can contain -const MaxBlocksInResponse = 128 - type MessageType byte // Message types for notifications protocol messages. Used internally to map message to protocol. @@ -29,308 +19,13 @@ const ( ConsensusMsgType ) -// Message must be implemented by all network messages -type Message interface { - Encode() ([]byte, error) -} - // NotificationsMessage must be implemented by all messages sent over a notifications protocol type NotificationsMessage interface { - Message + messages.P2PMessage Type() MessageType Hash() (common.Hash, error) } -const ( - RequestedDataHeader = byte(1) - RequestedDataBody = byte(2) - RequestedDataReceipt = byte(4) - RequestedDataMessageQueue = byte(8) - RequestedDataJustification = byte(16) - BootstrapRequestData = RequestedDataHeader + - RequestedDataBody + - RequestedDataJustification -) - -var _ Message = (*BlockRequestMessage)(nil) - -// SyncDirection is the direction of data in a block response -type SyncDirection byte - -const ( - // Ascending is used when block response data is in ascending order (ie parent to child) - Ascending SyncDirection = iota - - // Descending is used when block response data is in descending order (ie child to parent) - Descending -) - -func (sd SyncDirection) String() string { - switch sd { - case Ascending: - return "ascending" - case Descending: - return "descending" - default: - return "invalid" - } -} - -// BlockRequestMessage is sent to request some blocks from a peer -type BlockRequestMessage struct { - RequestedData byte - StartingBlock variadic.Uint32OrHash // first byte 0 = block hash (32 byte), first byte 1 = block number (uint32) - Direction SyncDirection // 0 = ascending, 1 = descending - Max *uint32 -} - -func (bm *BlockRequestMessage) RequestField(req byte) bool { - return (bm.RequestedData & req) == req -} - -// String formats a BlockRequestMessage as a string -func (bm *BlockRequestMessage) String() string { - max := uint32(0) - if bm.Max != nil { - max = *bm.Max - } - return fmt.Sprintf("BlockRequestMessage RequestedData=%d StartingBlock=%v Direction=%d Max=%d", - bm.RequestedData, - bm.StartingBlock.String(), - bm.Direction, - max) -} - -// Encode returns the protobuf encoded BlockRequestMessage -func (bm *BlockRequestMessage) Encode() ([]byte, error) { - var max uint32 - if bm.Max != nil { - max = *bm.Max - } - - msg := &pb.BlockRequest{ - Fields: uint32(bm.RequestedData) << 24, // put byte in most significant byte of uint32 - Direction: pb.Direction(bm.Direction), - MaxBlocks: max, - } - - if bm.StartingBlock.IsHash() { - hash := bm.StartingBlock.Hash() - msg.FromBlock = &pb.BlockRequest_Hash{ - Hash: hash[:], - } - } else if bm.StartingBlock.IsUint32() { - buf := make([]byte, 4) - binary.LittleEndian.PutUint32(buf, bm.StartingBlock.Uint32()) - msg.FromBlock = &pb.BlockRequest_Number{ - Number: buf, - } - } else { - return nil, errInvalidStartingBlockType - } - - return proto.Marshal(msg) -} - -// Decode decodes the protobuf encoded input to a BlockRequestMessage -func (bm *BlockRequestMessage) Decode(in []byte) error { - msg := &pb.BlockRequest{} - err := proto.Unmarshal(in, msg) - if err != nil { - return err - } - - var ( - startingBlock *variadic.Uint32OrHash - max *uint32 - ) - - switch from := msg.FromBlock.(type) { - case *pb.BlockRequest_Hash: - startingBlock, err = variadic.NewUint32OrHash(common.BytesToHash(from.Hash)) - case *pb.BlockRequest_Number: - if len(from.Number) != 4 { - return fmt.Errorf("%w expected 4 bytes, got %d bytes", errBlockRequestFromNumberInvalid, len(from.Number)) - } - - number := binary.LittleEndian.Uint32(from.Number) - startingBlock, err = variadic.NewUint32OrHash(number) - default: - err = errors.New("invalid StartingBlock") - } - - if err != nil { - return err - } - - if msg.MaxBlocks != 0 { - max = &msg.MaxBlocks - } else { - max = nil - } - - bm.RequestedData = byte(msg.Fields >> 24) - bm.StartingBlock = *startingBlock - bm.Direction = SyncDirection(byte(msg.Direction)) - bm.Max = max - - return nil -} - -var _ ResponseMessage = (*BlockResponseMessage)(nil) - -// BlockResponseMessage is sent in response to a BlockRequestMessage -type BlockResponseMessage struct { - BlockData []*types.BlockData -} - -// String formats a BlockResponseMessage as a string -func (bm *BlockResponseMessage) String() string { - if bm == nil { - return "BlockResponseMessage=nil" - } - - return fmt.Sprintf("BlockResponseMessage BlockData=%v", bm.BlockData) -} - -// Encode returns the protobuf encoded BlockResponseMessage -func (bm *BlockResponseMessage) Encode() ([]byte, error) { - var ( - err error - ) - - msg := &pb.BlockResponse{ - Blocks: make([]*pb.BlockData, len(bm.BlockData)), - } - - for i, bd := range bm.BlockData { - msg.Blocks[i], err = blockDataToProtobuf(bd) - if err != nil { - return nil, err - } - } - - return proto.Marshal(msg) -} - -// Decode decodes the protobuf encoded input to a BlockResponseMessage -func (bm *BlockResponseMessage) Decode(in []byte) (err error) { - msg := &pb.BlockResponse{} - err = proto.Unmarshal(in, msg) - if err != nil { - return err - } - - bm.BlockData = make([]*types.BlockData, len(msg.Blocks)) - - for i, bd := range msg.Blocks { - block, err := protobufToBlockData(bd) - if err != nil { - return err - } - - if block == nil { - return fmt.Errorf("decoding blockResponseMessage: %w", ErrNilBlockInResponse) - } - bm.BlockData[i] = block - } - - return nil -} - -// blockDataToProtobuf converts a gossamer BlockData to a protobuf-defined BlockData -func blockDataToProtobuf(bd *types.BlockData) (*pb.BlockData, error) { - p := &pb.BlockData{ - Hash: bd.Hash[:], - } - - if bd.Header != nil { - header, err := scale.Marshal(*bd.Header) - if err != nil { - return nil, err - } - p.Header = header - } - - if bd.Body != nil { - body := bd.Body - exts, err := body.AsEncodedExtrinsics() - if err != nil { - return nil, err - } - - p.Body = types.ExtrinsicsArrayToBytesArray(exts) - } - - if bd.Receipt != nil { - p.Receipt = *bd.Receipt - } - - if bd.MessageQueue != nil { - p.MessageQueue = *bd.MessageQueue - } - - if bd.Justification != nil { - p.Justification = *bd.Justification - if len(*bd.Justification) == 0 { - p.IsEmptyJustification = true - } - } - - return p, nil -} - -func protobufToBlockData(pbd *pb.BlockData) (*types.BlockData, error) { - bd := &types.BlockData{ - Hash: common.BytesToHash(pbd.Hash), - } - - if pbd.Header != nil { - header := types.NewEmptyHeader() - err := scale.Unmarshal(pbd.Header, header) - if err != nil { - return nil, err - } - - bd.Header = header - } - - if pbd.Body != nil { - body, err := types.NewBodyFromEncodedBytes(pbd.Body) - if err != nil { - return nil, err - } - - bd.Body = body - } else { - bd.Body = nil - } - - if pbd.Receipt != nil { - bd.Receipt = &pbd.Receipt - } else { - bd.Receipt = nil - } - - if pbd.MessageQueue != nil { - bd.MessageQueue = &pbd.MessageQueue - } else { - bd.MessageQueue = nil - } - - if pbd.Justification != nil { - bd.Justification = &pbd.Justification - } else { - bd.Justification = nil - } - - if pbd.Justification == nil && pbd.IsEmptyJustification { - bd.Justification = &[]byte{} - } - - return bd, nil -} - var _ NotificationsMessage = &ConsensusMessage{} // ConsensusMessage is mostly opaque to us @@ -368,40 +63,3 @@ func (cm *ConsensusMessage) Hash() (common.Hash, error) { } return common.Blake2bHash(encMsg) } - -func NewBlockRequest(startingBlock variadic.Uint32OrHash, amount uint32, - requestedData byte, direction SyncDirection) *BlockRequestMessage { - return &BlockRequestMessage{ - RequestedData: requestedData, - StartingBlock: startingBlock, - Direction: direction, - Max: &amount, - } -} - -func NewAscendingBlockRequests(startNumber, targetNumber uint, requestedData byte) []*BlockRequestMessage { - if startNumber > targetNumber { - return []*BlockRequestMessage{} - } - - diff := targetNumber - startNumber - - // start and end block are the same, just request 1 block - if diff == 0 { - return []*BlockRequestMessage{ - NewBlockRequest(*variadic.Uint32OrHashFrom(uint32(startNumber)), 1, requestedData, Ascending), - } - } - - numRequests := diff / MaxBlocksInResponse - - reqs := make([]*BlockRequestMessage, numRequests) - for i := uint(0); i < numRequests; i++ { - max := uint32(MaxBlocksInResponse) - start := variadic.Uint32OrHashFrom(startNumber) - reqs[i] = NewBlockRequest(*start, max, requestedData, Ascending) - startNumber += uint(max) - } - - return reqs -} diff --git a/dot/network/message_test.go b/dot/network/message_test.go index bfaf3203b0..cfcb215118 100644 --- a/dot/network/message_test.go +++ b/dot/network/message_test.go @@ -8,6 +8,7 @@ import ( "regexp" "testing" + "github.com/ChainSafe/gossamer/dot/network/messages" "github.com/ChainSafe/gossamer/dot/types" "github.com/ChainSafe/gossamer/lib/common" "github.com/ChainSafe/gossamer/lib/common/variadic" @@ -23,7 +24,7 @@ func TestEncodeBlockRequestMessage(t *testing.T) { genesisHash := common.MustHexToBytes("0xdcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b") var one uint32 = 1 - bm := &BlockRequestMessage{ + bm := &messages.BlockRequestMessage{ RequestedData: 1, StartingBlock: *variadic.NewUint32OrHashFromBytes(append([]byte{0}, genesisHash...)), Direction: 1, @@ -35,7 +36,7 @@ func TestEncodeBlockRequestMessage(t *testing.T) { require.Equal(t, expected, encMsg) - res := new(BlockRequestMessage) + res := new(messages.BlockRequestMessage) err = res.Decode(encMsg) require.NoError(t, err) require.Equal(t, bm, res) @@ -47,7 +48,7 @@ func TestEncodeBlockRequestMessage_BlockHash(t *testing.T) { genesisHash := common.MustHexToBytes("0xdcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b") var one uint32 = 1 - bm := &BlockRequestMessage{ + bm := &messages.BlockRequestMessage{ RequestedData: 1, StartingBlock: *variadic.NewUint32OrHashFromBytes(append([]byte{0}, genesisHash...)), Direction: 1, @@ -57,7 +58,7 @@ func TestEncodeBlockRequestMessage_BlockHash(t *testing.T) { encMsg, err := bm.Encode() require.NoError(t, err) - res := new(BlockRequestMessage) + res := new(messages.BlockRequestMessage) err = res.Decode(encMsg) require.NoError(t, err) require.Equal(t, bm, res) @@ -67,7 +68,7 @@ func TestEncodeBlockRequestMessage_BlockNumber(t *testing.T) { t.Parallel() var one uint32 = 1 - bm := &BlockRequestMessage{ + bm := &messages.BlockRequestMessage{ RequestedData: 1, StartingBlock: *variadic.NewUint32OrHashFromBytes([]byte{1, 1}), Direction: 1, @@ -77,7 +78,7 @@ func TestEncodeBlockRequestMessage_BlockNumber(t *testing.T) { encMsg, err := bm.Encode() require.NoError(t, err) - res := new(BlockRequestMessage) + res := new(messages.BlockRequestMessage) err = res.Decode(encMsg) require.NoError(t, err) require.Equal(t, bm, res) @@ -88,7 +89,7 @@ func TestBlockRequestString(t *testing.T) { genesisHash := common.MustHexToBytes("0xdcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b") - bm := &BlockRequestMessage{ + bm := &messages.BlockRequestMessage{ RequestedData: 1, StartingBlock: *variadic.NewUint32OrHashFromBytes(append([]byte{0}, genesisHash...)), Direction: 1, @@ -107,7 +108,7 @@ func TestEncodeBlockRequestMessage_NoOptionals(t *testing.T) { genesisHash := common.MustHexToBytes("0xdcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b") - bm := &BlockRequestMessage{ + bm := &messages.BlockRequestMessage{ RequestedData: 1, StartingBlock: *variadic.NewUint32OrHashFromBytes(append([]byte{0}, genesisHash...)), Direction: 1, @@ -117,7 +118,7 @@ func TestEncodeBlockRequestMessage_NoOptionals(t *testing.T) { encMsg, err := bm.Encode() require.NoError(t, err) - res := new(BlockRequestMessage) + res := new(messages.BlockRequestMessage) err = res.Decode(encMsg) require.NoError(t, err) require.Equal(t, bm, res) @@ -130,7 +131,7 @@ func TestEncodeBlockResponseMessage_Empty(t *testing.T) { bd.Header = types.NewEmptyHeader() bd.Header.Hash() - bm := &BlockResponseMessage{ + bm := &messages.BlockResponseMessage{ BlockData: []*types.BlockData{bd}, } @@ -140,7 +141,7 @@ func TestEncodeBlockResponseMessage_Empty(t *testing.T) { empty := types.NewEmptyBlockData() empty.Header = types.NewEmptyHeader() - act := &BlockResponseMessage{ + act := &messages.BlockResponseMessage{ BlockData: []*types.BlockData{empty}, } err = act.Decode(enc) @@ -179,7 +180,7 @@ func TestEncodeBlockResponseMessage_WithBody(t *testing.T) { Justification: nil, } - bm := &BlockResponseMessage{ + bm := &messages.BlockResponseMessage{ BlockData: []*types.BlockData{bd}, } @@ -189,7 +190,7 @@ func TestEncodeBlockResponseMessage_WithBody(t *testing.T) { empty := types.NewEmptyBlockData() empty.Header = types.NewEmptyHeader() - act := &BlockResponseMessage{ + act := &messages.BlockResponseMessage{ BlockData: []*types.BlockData{empty}, } err = act.Decode(enc) @@ -230,7 +231,7 @@ func TestEncodeBlockResponseMessage_WithAll(t *testing.T) { Justification: &[]byte{3}, } - bm := &BlockResponseMessage{ + bm := &messages.BlockResponseMessage{ BlockData: []*types.BlockData{bd}, } @@ -241,7 +242,7 @@ func TestEncodeBlockResponseMessage_WithAll(t *testing.T) { empty := types.NewEmptyBlockData() empty.Header = types.NewEmptyHeader() - act := &BlockResponseMessage{ + act := &messages.BlockResponseMessage{ BlockData: []*types.BlockData{empty}, } err = act.Decode(enc) @@ -426,27 +427,27 @@ func TestDecodeConsensusMessage(t *testing.T) { func TestAscendingBlockRequest(t *testing.T) { one := uint32(1) three := uint32(3) - maxResponseSize := uint32(MaxBlocksInResponse) + maxResponseSize := uint32(messages.MaxBlocksInResponse) cases := map[string]struct { startNumber, targetNumber uint - expectedBlockRequestMessage []*BlockRequestMessage + expectedBlockRequestMessage []*messages.BlockRequestMessage expectedTotalOfBlocksRequested uint32 }{ "start_greater_than_target": { startNumber: 10, targetNumber: 0, - expectedBlockRequestMessage: []*BlockRequestMessage{}, + expectedBlockRequestMessage: []*messages.BlockRequestMessage{}, expectedTotalOfBlocksRequested: 0, }, "no_difference_between_start_and_target": { startNumber: 10, targetNumber: 10, - expectedBlockRequestMessage: []*BlockRequestMessage{ + expectedBlockRequestMessage: []*messages.BlockRequestMessage{ { - RequestedData: BootstrapRequestData, + RequestedData: messages.BootstrapRequestData, StartingBlock: *variadic.Uint32OrHashFrom(uint32(10)), - Direction: Ascending, + Direction: messages.Ascending, Max: &one, }, }, @@ -457,11 +458,11 @@ func TestAscendingBlockRequest(t *testing.T) { startNumber: 1, targetNumber: 128, expectedTotalOfBlocksRequested: 128, - expectedBlockRequestMessage: []*BlockRequestMessage{ + expectedBlockRequestMessage: []*messages.BlockRequestMessage{ { - RequestedData: BootstrapRequestData, + RequestedData: messages.BootstrapRequestData, StartingBlock: *variadic.Uint32OrHashFrom(uint32(1)), - Direction: Ascending, + Direction: messages.Ascending, Max: &maxResponseSize, }, }, @@ -471,67 +472,66 @@ func TestAscendingBlockRequest(t *testing.T) { startNumber: 1, targetNumber: 128 * 4, // 512 expectedTotalOfBlocksRequested: 512, - expectedBlockRequestMessage: []*BlockRequestMessage{ + expectedBlockRequestMessage: []*messages.BlockRequestMessage{ { - RequestedData: BootstrapRequestData, + RequestedData: messages.BootstrapRequestData, StartingBlock: *variadic.Uint32OrHashFrom(uint32(1)), - Direction: Ascending, + Direction: messages.Ascending, Max: &maxResponseSize, }, { - RequestedData: BootstrapRequestData, + RequestedData: messages.BootstrapRequestData, StartingBlock: *variadic.Uint32OrHashFrom(uint32(129)), - Direction: Ascending, + Direction: messages.Ascending, Max: &maxResponseSize, }, { - RequestedData: BootstrapRequestData, + RequestedData: messages.BootstrapRequestData, StartingBlock: *variadic.Uint32OrHashFrom(uint32(257)), - Direction: Ascending, + Direction: messages.Ascending, Max: &maxResponseSize, }, { - RequestedData: BootstrapRequestData, + RequestedData: messages.BootstrapRequestData, StartingBlock: *variadic.Uint32OrHashFrom(uint32(385)), - Direction: Ascending, + Direction: messages.Ascending, Max: &maxResponseSize, }, }, }, - "requesting_4_chunks_of_128_plus_3_blocks": { startNumber: 1, targetNumber: (128 * 4) + 3, expectedTotalOfBlocksRequested: 515, - expectedBlockRequestMessage: []*BlockRequestMessage{ + expectedBlockRequestMessage: []*messages.BlockRequestMessage{ { - RequestedData: BootstrapRequestData, + RequestedData: messages.BootstrapRequestData, StartingBlock: *variadic.Uint32OrHashFrom(uint32(1)), - Direction: Ascending, + Direction: messages.Ascending, Max: &maxResponseSize, }, { - RequestedData: BootstrapRequestData, + RequestedData: messages.BootstrapRequestData, StartingBlock: *variadic.Uint32OrHashFrom(uint32(129)), - Direction: Ascending, + Direction: messages.Ascending, Max: &maxResponseSize, }, { - RequestedData: BootstrapRequestData, + RequestedData: messages.BootstrapRequestData, StartingBlock: *variadic.Uint32OrHashFrom(uint32(257)), - Direction: Ascending, + Direction: messages.Ascending, Max: &maxResponseSize, }, { - RequestedData: BootstrapRequestData, + RequestedData: messages.BootstrapRequestData, StartingBlock: *variadic.Uint32OrHashFrom(uint32(385)), - Direction: Ascending, + Direction: messages.Ascending, Max: &maxResponseSize, }, { - RequestedData: BootstrapRequestData, + RequestedData: messages.BootstrapRequestData, StartingBlock: *variadic.Uint32OrHashFrom(uint32(513)), - Direction: Ascending, + Direction: messages.Ascending, Max: &three, }, }, @@ -542,7 +542,8 @@ func TestAscendingBlockRequest(t *testing.T) { tt := tt t.Run(tname, func(t *testing.T) { - requests := NewAscendingBlockRequests(tt.startNumber, tt.targetNumber, BootstrapRequestData) + requests := messages.NewAscendingBlockRequests(tt.startNumber, tt.targetNumber, + messages.BootstrapRequestData) require.Equal(t, tt.expectedBlockRequestMessage, requests) acc := uint32(0) diff --git a/dot/network/messages/block.go b/dot/network/messages/block.go new file mode 100644 index 0000000000..b36fe86dab --- /dev/null +++ b/dot/network/messages/block.go @@ -0,0 +1,362 @@ +// Copyright 2024 ChainSafe Systems (ON) +// SPDX-License-Identifier: LGPL-3.0-only + +package messages + +import ( + "encoding/binary" + "errors" + "fmt" + + pb "github.com/ChainSafe/gossamer/dot/network/proto" + "github.com/ChainSafe/gossamer/dot/types" + "github.com/ChainSafe/gossamer/lib/common" + "github.com/ChainSafe/gossamer/lib/common/variadic" + "github.com/ChainSafe/gossamer/pkg/scale" + "google.golang.org/protobuf/proto" +) + +// MaxBlocksInResponse is maximum number of block data a BlockResponse message can contain +const MaxBlocksInResponse = 128 + +// SyncDirection is the direction of data in a block response +type SyncDirection byte + +const ( + // Ascending is used when block response data is in ascending order (ie parent to child) + Ascending SyncDirection = iota + + // Descending is used when block response data is in descending order (ie child to parent) + Descending +) + +// The following defines the fields that will needs to be +// in the response message +const ( + RequestedDataHeader = byte(1) + RequestedDataBody = byte(2) + RequestedDataReceipt = byte(4) + RequestedDataMessageQueue = byte(8) + RequestedDataJustification = byte(16) + BootstrapRequestData = RequestedDataHeader + + RequestedDataBody + + RequestedDataJustification +) + +var ( + _ P2PMessage = (*BlockRequestMessage)(nil) + _ P2PMessage = (*BlockResponseMessage)(nil) +) + +var ( + errBlockRequestFromNumberInvalid = errors.New("block request message From number is not valid") + errInvalidStartingBlockType = errors.New("invalid StartingBlock in messsage") + ErrNilBlockInResponse = errors.New("nil block in response") +) + +// BlockRequestMessage is sent to request some blocks from a peer +type BlockRequestMessage struct { + RequestedData byte + StartingBlock variadic.Uint32OrHash // first byte 0 = block hash (32 byte), first byte 1 = block number (uint32) + Direction SyncDirection // 0 = ascending, 1 = descending + Max *uint32 +} + +func NewBlockRequest(startingBlock variadic.Uint32OrHash, amount uint32, + requestedData byte, direction SyncDirection) *BlockRequestMessage { + return &BlockRequestMessage{ + RequestedData: requestedData, + StartingBlock: startingBlock, + Direction: direction, + Max: &amount, + } +} + +func NewAscendingBlockRequests(startNumber, targetNumber uint, requestedData byte) []*BlockRequestMessage { + if startNumber > targetNumber { + return []*BlockRequestMessage{} + } + + diff := targetNumber - (startNumber - 1) + + // start and end block are the same, just request 1 block + if diff == 0 { + return []*BlockRequestMessage{ + NewBlockRequest(*variadic.Uint32OrHashFrom(uint32(startNumber)), 1, requestedData, Ascending), + } + } + + numRequests := diff / MaxBlocksInResponse + // we should check if the diff is in the maxResponseSize bounds + // otherwise we should increase the numRequests by one, take this + // example, we want to sync from 1 to 259, the diff is 259 + // then the num of requests is 2 (uint(259)/uint(128)) however two requests will + // retrieve only 256 blocks (each request can retrieve a max of 128 blocks), so we should + // create one more request to retrieve those missing blocks, 3 in this example. + missingBlocks := diff % MaxBlocksInResponse + if missingBlocks != 0 { + numRequests++ + } + + reqs := make([]*BlockRequestMessage, numRequests) + for i := uint(0); i < numRequests; i++ { + max := uint32(MaxBlocksInResponse) + + lastIteration := numRequests - 1 + if i == lastIteration && missingBlocks != 0 { + max = uint32(missingBlocks) + } + + start := variadic.Uint32OrHashFrom(startNumber) + reqs[i] = NewBlockRequest(*start, max, requestedData, Ascending) + startNumber += uint(max) + } + + return reqs +} + +// RequestField returns true the field passed as argument exists in the request data +func (bm *BlockRequestMessage) RequestField(field byte) bool { + return (bm.RequestedData & field) == field +} + +// String formats a BlockRequestMessage as a string +func (bm *BlockRequestMessage) String() string { + max := uint32(0) + if bm.Max != nil { + max = *bm.Max + } + return fmt.Sprintf("BlockRequestMessage RequestedData=%d StartingBlock=%v Direction=%d Max=%d", + bm.RequestedData, + bm.StartingBlock, + bm.Direction, + max) +} + +// Encode returns the protobuf encoded BlockRequestMessage +func (bm *BlockRequestMessage) Encode() ([]byte, error) { + var max uint32 + if bm.Max != nil { + max = *bm.Max + } + + msg := &pb.BlockRequest{ + Fields: uint32(bm.RequestedData) << 24, // put byte in most significant byte of uint32 + Direction: pb.Direction(bm.Direction), + MaxBlocks: max, + } + + if bm.StartingBlock.IsHash() { + hash := bm.StartingBlock.Hash() + msg.FromBlock = &pb.BlockRequest_Hash{ + Hash: hash[:], + } + } else if bm.StartingBlock.IsUint32() { + buf := make([]byte, 4) + binary.LittleEndian.PutUint32(buf, bm.StartingBlock.Uint32()) + msg.FromBlock = &pb.BlockRequest_Number{ + Number: buf, + } + } else { + return nil, errInvalidStartingBlockType + } + + return proto.Marshal(msg) +} + +// Decode decodes the protobuf encoded input to a BlockRequestMessage +func (bm *BlockRequestMessage) Decode(in []byte) error { + msg := &pb.BlockRequest{} + err := proto.Unmarshal(in, msg) + if err != nil { + return err + } + + var ( + startingBlock *variadic.Uint32OrHash + max *uint32 + ) + + switch from := msg.FromBlock.(type) { + case *pb.BlockRequest_Hash: + startingBlock, err = variadic.NewUint32OrHash(common.BytesToHash(from.Hash)) + case *pb.BlockRequest_Number: + if len(from.Number) != 4 { + return fmt.Errorf("%w expected 4 bytes, got %d bytes", errBlockRequestFromNumberInvalid, len(from.Number)) + } + + number := binary.LittleEndian.Uint32(from.Number) + startingBlock, err = variadic.NewUint32OrHash(number) + default: + err = errors.New("invalid StartingBlock") + } + + if err != nil { + return err + } + + if msg.MaxBlocks != 0 { + max = &msg.MaxBlocks + } else { + max = nil + } + + bm.RequestedData = byte(msg.Fields >> 24) + bm.StartingBlock = *startingBlock + bm.Direction = SyncDirection(byte(msg.Direction)) + bm.Max = max + + return nil +} + +// BlockResponseMessage is sent in response to a BlockRequestMessage +type BlockResponseMessage struct { + BlockData []*types.BlockData +} + +// String formats a BlockResponseMessage as a string +func (bm *BlockResponseMessage) String() string { + if bm == nil { + return "BlockResponseMessage=nil" + } + + return fmt.Sprintf("BlockResponseMessage BlockData=%v", bm.BlockData) +} + +// Encode returns the protobuf encoded BlockResponseMessage +func (bm *BlockResponseMessage) Encode() ([]byte, error) { + var ( + err error + ) + + msg := &pb.BlockResponse{ + Blocks: make([]*pb.BlockData, len(bm.BlockData)), + } + + for i, bd := range bm.BlockData { + msg.Blocks[i], err = blockDataToProtobuf(bd) + if err != nil { + return nil, err + } + } + + return proto.Marshal(msg) +} + +// Decode decodes the protobuf encoded input to a BlockResponseMessage +func (bm *BlockResponseMessage) Decode(in []byte) (err error) { + msg := &pb.BlockResponse{} + err = proto.Unmarshal(in, msg) + if err != nil { + return err + } + + bm.BlockData = make([]*types.BlockData, len(msg.Blocks)) + + for i, bd := range msg.Blocks { + block, err := protobufToBlockData(bd) + if err != nil { + return err + } + + if block == nil { + return fmt.Errorf("decoding blockResponseMessage: %w", ErrNilBlockInResponse) + } + bm.BlockData[i] = block + } + + return nil +} + +// blockDataToProtobuf converts a gossamer BlockData to a protobuf-defined BlockData +func blockDataToProtobuf(bd *types.BlockData) (*pb.BlockData, error) { + p := &pb.BlockData{ + Hash: bd.Hash[:], + } + + if bd.Header != nil { + header, err := scale.Marshal(*bd.Header) + if err != nil { + return nil, err + } + p.Header = header + } + + if bd.Body != nil { + body := bd.Body + exts, err := body.AsEncodedExtrinsics() + if err != nil { + return nil, err + } + + p.Body = types.ExtrinsicsArrayToBytesArray(exts) + } + + if bd.Receipt != nil { + p.Receipt = *bd.Receipt + } + + if bd.MessageQueue != nil { + p.MessageQueue = *bd.MessageQueue + } + + if bd.Justification != nil { + p.Justification = *bd.Justification + if len(*bd.Justification) == 0 { + p.IsEmptyJustification = true + } + } + + return p, nil +} + +func protobufToBlockData(pbd *pb.BlockData) (*types.BlockData, error) { + bd := &types.BlockData{ + Hash: common.BytesToHash(pbd.Hash), + } + + if pbd.Header != nil { + header := types.NewEmptyHeader() + err := scale.Unmarshal(pbd.Header, header) + if err != nil { + return nil, err + } + + bd.Header = header + } + + if pbd.Body != nil { + body, err := types.NewBodyFromEncodedBytes(pbd.Body) + if err != nil { + return nil, err + } + + bd.Body = body + } else { + bd.Body = nil + } + + if pbd.Receipt != nil { + bd.Receipt = &pbd.Receipt + } else { + bd.Receipt = nil + } + + if pbd.MessageQueue != nil { + bd.MessageQueue = &pbd.MessageQueue + } else { + bd.MessageQueue = nil + } + + if pbd.Justification != nil { + bd.Justification = &pbd.Justification + } else { + bd.Justification = nil + } + + if pbd.Justification == nil && pbd.IsEmptyJustification { + bd.Justification = &[]byte{} + } + + return bd, nil +} diff --git a/dot/network/messages/message.go b/dot/network/messages/message.go new file mode 100644 index 0000000000..6e284e984b --- /dev/null +++ b/dot/network/messages/message.go @@ -0,0 +1,11 @@ +// Copyright 2024 ChainSafe Systems (ON) +// SPDX-License-Identifier: LGPL-3.0-only + +package messages + +// P2PMessage must be implemented by all network messages +type P2PMessage interface { + String() string + Encode() ([]byte, error) + Decode(in []byte) (err error) +} diff --git a/dot/network/messages/state.go b/dot/network/messages/state.go new file mode 100644 index 0000000000..efb48765b3 --- /dev/null +++ b/dot/network/messages/state.go @@ -0,0 +1,54 @@ +// Copyright 2024 ChainSafe Systems (ON) +// SPDX-License-Identifier: LGPL-3.0-only + +package messages + +import ( + "fmt" + + pb "github.com/ChainSafe/gossamer/dot/network/proto" + "github.com/ChainSafe/gossamer/lib/common" + "google.golang.org/protobuf/proto" +) + +var _ P2PMessage = (*StateRequest)(nil) + +// StateRequest defines the parameters to request the state keys +// and values from another peer +type StateRequest struct { + Block common.Hash + Start [][]byte + NoProof bool +} + +func (s *StateRequest) String() string { + return fmt.Sprintf("StateRequest Block=%s Start=[0x%x, 0x%x] NoProof=%v", + s.Block.String(), + s.Start[0], s.Start[1], + s.NoProof, + ) +} + +func (s *StateRequest) Encode() ([]byte, error) { + message := &pb.StateRequest{ + Block: s.Block.ToBytes(), + Start: make([][]byte, len(s.Start)), + NoProof: s.NoProof, + } + copy(message.Start, s.Start) + return proto.Marshal(message) +} + +func (s *StateRequest) Decode(in []byte) error { + message := &pb.StateRequest{} + err := proto.Unmarshal(in, message) + if err != nil { + return err + } + + s.Block = common.BytesToHash(message.Block) + s.Start = make([][]byte, len(message.Start)) + copy(s.Start, message.Start) + s.NoProof = message.NoProof + return nil +} diff --git a/dot/network/mock_syncer_test.go b/dot/network/mock_syncer_test.go index 893f16ffcd..5350fa44af 100644 --- a/dot/network/mock_syncer_test.go +++ b/dot/network/mock_syncer_test.go @@ -12,6 +12,7 @@ package network import ( reflect "reflect" + messages "github.com/ChainSafe/gossamer/dot/network/messages" peer "github.com/libp2p/go-libp2p/core/peer" gomock "go.uber.org/mock/gomock" ) @@ -40,10 +41,10 @@ func (m *MockSyncer) EXPECT() *MockSyncerMockRecorder { } // CreateBlockResponse mocks base method. -func (m *MockSyncer) CreateBlockResponse(arg0 peer.ID, arg1 *BlockRequestMessage) (*BlockResponseMessage, error) { +func (m *MockSyncer) CreateBlockResponse(arg0 peer.ID, arg1 *messages.BlockRequestMessage) (*messages.BlockResponseMessage, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateBlockResponse", arg0, arg1) - ret0, _ := ret[0].(*BlockResponseMessage) + ret0, _ := ret[0].(*messages.BlockResponseMessage) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/dot/network/notifications.go b/dot/network/notifications.go index 8c9f7447a9..b85634ecfd 100644 --- a/dot/network/notifications.go +++ b/dot/network/notifications.go @@ -9,6 +9,7 @@ import ( "io" "time" + "github.com/ChainSafe/gossamer/dot/network/messages" "github.com/ChainSafe/gossamer/dot/peerset" "github.com/libp2p/go-libp2p/core/network" "github.com/libp2p/go-libp2p/core/peer" @@ -19,7 +20,7 @@ const handshakeTimeout = time.Second * 10 // Handshake is the interface all handshakes for notifications protocols must implement type Handshake interface { - Message + messages.P2PMessage IsValid() bool } @@ -96,7 +97,7 @@ func newHandshakeData(received, validated bool, stream network.Stream) *handshak // peer, otherwise it decodes using the notification message decoder. func createDecoder(info *notificationsProtocol, handshakeDecoder HandshakeDecoder, messageDecoder MessageDecoder) messageDecoder { - return func(in []byte, peer peer.ID, inbound bool) (Message, error) { + return func(in []byte, peer peer.ID, inbound bool) (messages.P2PMessage, error) { // if we don't have handshake data on this peer, or we haven't received the handshake from them already, // assume we are receiving the handshake @@ -122,7 +123,7 @@ func (s *Service) createNotificationsMessageHandler( notificationsMessageHandler NotificationsMessageHandler, batchHandler NotificationsMessageBatchHandler, ) messageHandler { - return func(stream network.Stream, m Message) error { + return func(stream network.Stream, m messages.P2PMessage) error { if m == nil || info == nil || info.handshakeValidator == nil || notificationsMessageHandler == nil { return nil } diff --git a/dot/network/proto/api.v1.pb.go b/dot/network/proto/api.v1.pb.go index 252b587f3d..660e8bfa15 100644 --- a/dot/network/proto/api.v1.pb.go +++ b/dot/network/proto/api.v1.pb.go @@ -6,7 +6,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.10 +// protoc v4.24.4 // source: api.v1.proto package proto @@ -342,6 +342,242 @@ func (x *BlockData) GetIsEmptyJustification() bool { return false } +type StateRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Block []byte `protobuf:"bytes,1,opt,name=block,proto3" json:"block,omitempty"` + Start [][]byte `protobuf:"bytes,2,rep,name=start,proto3" json:"start,omitempty"` + NoProof bool `protobuf:"varint,3,opt,name=no_proof,json=noProof,proto3" json:"no_proof,omitempty"` +} + +func (x *StateRequest) Reset() { + *x = StateRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_api_v1_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StateRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StateRequest) ProtoMessage() {} + +func (x *StateRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_v1_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StateRequest.ProtoReflect.Descriptor instead. +func (*StateRequest) Descriptor() ([]byte, []int) { + return file_api_v1_proto_rawDescGZIP(), []int{3} +} + +func (x *StateRequest) GetBlock() []byte { + if x != nil { + return x.Block + } + return nil +} + +func (x *StateRequest) GetStart() [][]byte { + if x != nil { + return x.Start + } + return nil +} + +func (x *StateRequest) GetNoProof() bool { + if x != nil { + return x.NoProof + } + return false +} + +type StateResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Entries []*KeyValueStateEntry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"` + Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` +} + +func (x *StateResponse) Reset() { + *x = StateResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_api_v1_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StateResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StateResponse) ProtoMessage() {} + +func (x *StateResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_v1_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StateResponse.ProtoReflect.Descriptor instead. +func (*StateResponse) Descriptor() ([]byte, []int) { + return file_api_v1_proto_rawDescGZIP(), []int{4} +} + +func (x *StateResponse) GetEntries() []*KeyValueStateEntry { + if x != nil { + return x.Entries + } + return nil +} + +func (x *StateResponse) GetProof() []byte { + if x != nil { + return x.Proof + } + return nil +} + +type KeyValueStateEntry struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + StateRoot []byte `protobuf:"bytes,1,opt,name=state_root,json=stateRoot,proto3" json:"state_root,omitempty"` + Entries []*StateEntry `protobuf:"bytes,2,rep,name=entries,proto3" json:"entries,omitempty"` + Complete bool `protobuf:"varint,3,opt,name=complete,proto3" json:"complete,omitempty"` +} + +func (x *KeyValueStateEntry) Reset() { + *x = KeyValueStateEntry{} + if protoimpl.UnsafeEnabled { + mi := &file_api_v1_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *KeyValueStateEntry) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*KeyValueStateEntry) ProtoMessage() {} + +func (x *KeyValueStateEntry) ProtoReflect() protoreflect.Message { + mi := &file_api_v1_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use KeyValueStateEntry.ProtoReflect.Descriptor instead. +func (*KeyValueStateEntry) Descriptor() ([]byte, []int) { + return file_api_v1_proto_rawDescGZIP(), []int{5} +} + +func (x *KeyValueStateEntry) GetStateRoot() []byte { + if x != nil { + return x.StateRoot + } + return nil +} + +func (x *KeyValueStateEntry) GetEntries() []*StateEntry { + if x != nil { + return x.Entries + } + return nil +} + +func (x *KeyValueStateEntry) GetComplete() bool { + if x != nil { + return x.Complete + } + return false +} + +type StateEntry struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *StateEntry) Reset() { + *x = StateEntry{} + if protoimpl.UnsafeEnabled { + mi := &file_api_v1_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StateEntry) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StateEntry) ProtoMessage() {} + +func (x *StateEntry) ProtoReflect() protoreflect.Message { + mi := &file_api_v1_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StateEntry.ProtoReflect.Descriptor instead. +func (*StateEntry) Descriptor() ([]byte, []int) { + return file_api_v1_proto_rawDescGZIP(), []int{6} +} + +func (x *StateEntry) GetKey() []byte { + if x != nil { + return x.Key + } + return nil +} + +func (x *StateEntry) GetValue() []byte { + if x != nil { + return x.Value + } + return nil +} + var File_api_v1_proto protoreflect.FileDescriptor var file_api_v1_proto_rawDesc = []byte{ @@ -376,13 +612,36 @@ var file_api_v1_proto_rawDesc = []byte{ 0x69, 0x73, 0x5f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x5f, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x14, 0x69, 0x73, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x4a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x2a, 0x2a, 0x0a, 0x09, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x0d, 0x0a, 0x09, 0x41, 0x73, 0x63, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x10, 0x00, 0x12, 0x0e, - 0x0a, 0x0a, 0x44, 0x65, 0x73, 0x63, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x10, 0x01, 0x42, 0x31, - 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x43, 0x68, 0x61, - 0x69, 0x6e, 0x53, 0x61, 0x66, 0x65, 0x2f, 0x67, 0x6f, 0x73, 0x73, 0x61, 0x6d, 0x65, 0x72, 0x2f, - 0x64, 0x6f, 0x74, 0x2f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x6e, 0x22, 0x55, 0x0a, 0x0c, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x72, + 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x12, 0x19, + 0x0a, 0x08, 0x6e, 0x6f, 0x5f, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x07, 0x6e, 0x6f, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x22, 0x5b, 0x0a, 0x0d, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x34, 0x0a, 0x07, 0x65, 0x6e, + 0x74, 0x72, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x65, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, + 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x22, 0x7d, 0x0a, 0x12, 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c, + 0x75, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x1d, 0x0a, 0x0a, + 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x2c, 0x0a, 0x07, 0x65, + 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x61, + 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x52, 0x07, 0x65, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6d, + 0x70, 0x6c, 0x65, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x63, 0x6f, 0x6d, + 0x70, 0x6c, 0x65, 0x74, 0x65, 0x22, 0x34, 0x0a, 0x0a, 0x53, 0x74, 0x61, 0x74, 0x65, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2a, 0x2a, 0x0a, 0x09, 0x44, + 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0d, 0x0a, 0x09, 0x41, 0x73, 0x63, 0x65, + 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x44, 0x65, 0x73, 0x63, 0x65, + 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x10, 0x01, 0x42, 0x31, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x53, 0x61, 0x66, 0x65, 0x2f, + 0x67, 0x6f, 0x73, 0x73, 0x61, 0x6d, 0x65, 0x72, 0x2f, 0x64, 0x6f, 0x74, 0x2f, 0x6e, 0x65, 0x74, + 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -398,21 +657,27 @@ func file_api_v1_proto_rawDescGZIP() []byte { } var file_api_v1_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_api_v1_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_api_v1_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_api_v1_proto_goTypes = []interface{}{ - (Direction)(0), // 0: api.v1.Direction - (*BlockRequest)(nil), // 1: api.v1.BlockRequest - (*BlockResponse)(nil), // 2: api.v1.BlockResponse - (*BlockData)(nil), // 3: api.v1.BlockData + (Direction)(0), // 0: api.v1.Direction + (*BlockRequest)(nil), // 1: api.v1.BlockRequest + (*BlockResponse)(nil), // 2: api.v1.BlockResponse + (*BlockData)(nil), // 3: api.v1.BlockData + (*StateRequest)(nil), // 4: api.v1.StateRequest + (*StateResponse)(nil), // 5: api.v1.StateResponse + (*KeyValueStateEntry)(nil), // 6: api.v1.KeyValueStateEntry + (*StateEntry)(nil), // 7: api.v1.StateEntry } var file_api_v1_proto_depIdxs = []int32{ 0, // 0: api.v1.BlockRequest.direction:type_name -> api.v1.Direction 3, // 1: api.v1.BlockResponse.blocks:type_name -> api.v1.BlockData - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 6, // 2: api.v1.StateResponse.entries:type_name -> api.v1.KeyValueStateEntry + 7, // 3: api.v1.KeyValueStateEntry.entries:type_name -> api.v1.StateEntry + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_api_v1_proto_init() } @@ -457,6 +722,54 @@ func file_api_v1_proto_init() { return nil } } + file_api_v1_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StateRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_v1_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StateResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_v1_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*KeyValueStateEntry); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_v1_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StateEntry); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } file_api_v1_proto_msgTypes[0].OneofWrappers = []interface{}{ (*BlockRequest_Hash)(nil), @@ -468,7 +781,7 @@ func file_api_v1_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_api_v1_proto_rawDesc, NumEnums: 1, - NumMessages: 3, + NumMessages: 7, NumExtensions: 0, NumServices: 0, }, diff --git a/dot/network/proto/api.v1.proto b/dot/network/proto/api.v1.proto index df2ed91715..7cc8b5114c 100644 --- a/dot/network/proto/api.v1.proto +++ b/dot/network/proto/api.v1.proto @@ -61,3 +61,25 @@ message BlockData { // justification. bool is_empty_justification = 7; // optional, false if absent } + +message StateRequest { + bytes block = 1; + repeated bytes start = 2; + bool no_proof = 3; +} + +message StateResponse { + repeated KeyValueStateEntry entries = 1; + bytes proof = 2; +} + +message KeyValueStateEntry { + bytes state_root = 1; + repeated StateEntry entries = 2; + bool complete = 3; +} + +message StateEntry { + bytes key = 1; + bytes value = 2; +} diff --git a/dot/network/request_response.go b/dot/network/request_response.go index 3a3b732cf1..da99c54950 100644 --- a/dot/network/request_response.go +++ b/dot/network/request_response.go @@ -9,6 +9,7 @@ import ( "sync" "time" + "github.com/ChainSafe/gossamer/dot/network/messages" "github.com/ChainSafe/gossamer/dot/peerset" libp2pnetwork "github.com/libp2p/go-libp2p/core/network" "github.com/libp2p/go-libp2p/core/peer" @@ -16,7 +17,7 @@ import ( ) type RequestMaker interface { - Do(to peer.ID, req Message, res ResponseMessage) error + Do(to peer.ID, req, res messages.P2PMessage) error } type RequestResponseProtocol struct { @@ -29,7 +30,7 @@ type RequestResponseProtocol struct { responseBuf []byte } -func (rrp *RequestResponseProtocol) Do(to peer.ID, req Message, res ResponseMessage) error { +func (rrp *RequestResponseProtocol) Do(to peer.ID, req, res messages.P2PMessage) error { rrp.host.p2pHost.ConnManager().Protect(to, "") defer rrp.host.p2pHost.ConnManager().Unprotect(to, "") @@ -55,7 +56,7 @@ func (rrp *RequestResponseProtocol) Do(to peer.ID, req Message, res ResponseMess return rrp.receiveResponse(stream, res) } -func (rrp *RequestResponseProtocol) receiveResponse(stream libp2pnetwork.Stream, msg ResponseMessage) error { +func (rrp *RequestResponseProtocol) receiveResponse(stream libp2pnetwork.Stream, msg messages.P2PMessage) error { // allocating a new (large) buffer every time slows down receiving response by a dramatic amount, // as malloc is one of the most CPU intensive tasks. // thus we should allocate buffers at startup and re-use them instead of allocating new ones each time. @@ -84,9 +85,3 @@ func (rrp *RequestResponseProtocol) receiveResponse(stream libp2pnetwork.Stream, return nil } - -type ResponseMessage interface { - String() string - Encode() ([]byte, error) - Decode(in []byte) (err error) -} diff --git a/dot/network/service.go b/dot/network/service.go index 4d19dfaa44..98169619b3 100644 --- a/dot/network/service.go +++ b/dot/network/service.go @@ -12,6 +12,7 @@ import ( "sync" "time" + "github.com/ChainSafe/gossamer/dot/network/messages" "github.com/ChainSafe/gossamer/dot/peerset" "github.com/ChainSafe/gossamer/dot/telemetry" "github.com/ChainSafe/gossamer/dot/types" @@ -100,10 +101,10 @@ var ( type ( // messageDecoder is passed on readStream to decode the data from the stream into a message. // since messages are decoded based on context, this is different for every sub-protocol. - messageDecoder = func([]byte, peer.ID, bool) (Message, error) + messageDecoder = func([]byte, peer.ID, bool) (messages.P2PMessage, error) // messageHandler is passed on readStream to handle the resulting message. // It should return an error only if the stream is to be closed - messageHandler = func(stream libp2pnetwork.Stream, msg Message) error + messageHandler = func(stream libp2pnetwork.Stream, msg messages.P2PMessage) error ) // Service describes a network service diff --git a/dot/network/state.go b/dot/network/state.go index 09e7d20f11..1358c9e1be 100644 --- a/dot/network/state.go +++ b/dot/network/state.go @@ -8,6 +8,7 @@ import ( "github.com/libp2p/go-libp2p/core/peer" + "github.com/ChainSafe/gossamer/dot/network/messages" "github.com/ChainSafe/gossamer/dot/peerset" "github.com/ChainSafe/gossamer/dot/types" "github.com/ChainSafe/gossamer/lib/common" @@ -32,7 +33,7 @@ type Syncer interface { IsSynced() bool // CreateBlockResponse is called upon receipt of a BlockRequestMessage to create the response - CreateBlockResponse(peer.ID, *BlockRequestMessage) (*BlockResponseMessage, error) + CreateBlockResponse(peer.ID, *messages.BlockRequestMessage) (*messages.BlockResponseMessage, error) OnConnectionClosed(peer.ID) } diff --git a/dot/network/sync.go b/dot/network/sync.go index e0c493a0dc..f37dd0ccd6 100644 --- a/dot/network/sync.go +++ b/dot/network/sync.go @@ -4,6 +4,7 @@ package network import ( + "github.com/ChainSafe/gossamer/dot/network/messages" libp2pnetwork "github.com/libp2p/go-libp2p/core/network" "github.com/libp2p/go-libp2p/core/peer" ) @@ -17,15 +18,15 @@ func (s *Service) handleSyncStream(stream libp2pnetwork.Stream) { s.readStream(stream, decodeSyncMessage, s.handleSyncMessage, MaxBlockResponseSize) } -func decodeSyncMessage(in []byte, _ peer.ID, _ bool) (Message, error) { - msg := new(BlockRequestMessage) +func decodeSyncMessage(in []byte, _ peer.ID, _ bool) (messages.P2PMessage, error) { + msg := new(messages.BlockRequestMessage) err := msg.Decode(in) return msg, err } // handleSyncMessage handles inbound sync streams // the only messages we should receive over an inbound stream are BlockRequestMessages, so we only need to handle those -func (s *Service) handleSyncMessage(stream libp2pnetwork.Stream, msg Message) error { +func (s *Service) handleSyncMessage(stream libp2pnetwork.Stream, msg messages.P2PMessage) error { if msg == nil { return nil } @@ -37,7 +38,7 @@ func (s *Service) handleSyncMessage(stream libp2pnetwork.Stream, msg Message) er } }() - if req, ok := msg.(*BlockRequestMessage); ok { + if req, ok := msg.(*messages.BlockRequestMessage); ok { resp, err := s.syncer.CreateBlockResponse(stream.Conn().RemotePeer(), req) if err != nil { logger.Debugf("cannot create response for request: %s", err) diff --git a/dot/network/sync_test.go b/dot/network/sync_test.go index cfbf9e9605..26b3db64b0 100644 --- a/dot/network/sync_test.go +++ b/dot/network/sync_test.go @@ -6,6 +6,7 @@ package network import ( "testing" + "github.com/ChainSafe/gossamer/dot/network/messages" "github.com/libp2p/go-libp2p/core/peer" "github.com/stretchr/testify/require" ) @@ -21,7 +22,7 @@ func TestDecodeSyncMessage(t *testing.T) { msg, err := decodeSyncMessage(reqEnc, testPeer, true) require.NoError(t, err) - req, ok := msg.(*BlockRequestMessage) + req, ok := msg.(*messages.BlockRequestMessage) require.True(t, ok) require.Equal(t, testBlockReqMessage, req) } diff --git a/dot/rpc/modules/childstate_integration_test.go b/dot/rpc/modules/childstate_integration_test.go index cde3613bc2..6e1e559605 100644 --- a/dot/rpc/modules/childstate_integration_test.go +++ b/dot/rpc/modules/childstate_integration_test.go @@ -257,7 +257,7 @@ func setupChildStateStorage(t *testing.T) (*ChildStateModule, common.Hash) { err = tr.SetChildStorage(childStorageKey, []byte(":another_child"), []byte("value")) require.NoError(t, err) - stateRoot, err := tr.Root() + stateRoot, err := tr.Trie().Hash() require.NoError(t, err) bb, err := st.Block.BestBlock() diff --git a/dot/rpc/modules/childstate_test.go b/dot/rpc/modules/childstate_test.go index 376ed53739..ede45c7adb 100644 --- a/dot/rpc/modules/childstate_test.go +++ b/dot/rpc/modules/childstate_test.go @@ -33,7 +33,7 @@ func createTestTrieState(t *testing.T) (trie.Trie, common.Hash) { err = tr.SetChildStorage([]byte(":child_storage_key"), []byte(":another_child"), []byte("value")) require.NoError(t, err) - stateRoot, err := tr.Root() + stateRoot, err := tr.Trie().Hash() require.NoError(t, err) return tr.Trie(), stateRoot diff --git a/dot/rpc/modules/mock_syncer_test.go b/dot/rpc/modules/mock_syncer_test.go index 458a4788dc..64db24c0c7 100644 --- a/dot/rpc/modules/mock_syncer_test.go +++ b/dot/rpc/modules/mock_syncer_test.go @@ -13,6 +13,7 @@ import ( reflect "reflect" network "github.com/ChainSafe/gossamer/dot/network" + messages "github.com/ChainSafe/gossamer/dot/network/messages" peer "github.com/libp2p/go-libp2p/core/peer" gomock "go.uber.org/mock/gomock" ) @@ -41,10 +42,10 @@ func (m *MockSyncer) EXPECT() *MockSyncerMockRecorder { } // CreateBlockResponse mocks base method. -func (m *MockSyncer) CreateBlockResponse(arg0 peer.ID, arg1 *network.BlockRequestMessage) (*network.BlockResponseMessage, error) { +func (m *MockSyncer) CreateBlockResponse(arg0 peer.ID, arg1 *messages.BlockRequestMessage) (*messages.BlockResponseMessage, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateBlockResponse", arg0, arg1) - ret0, _ := ret[0].(*network.BlockResponseMessage) + ret0, _ := ret[0].(*messages.BlockResponseMessage) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/dot/rpc/modules/state_integration_test.go b/dot/rpc/modules/state_integration_test.go index 2e96210b21..482bdbf060 100644 --- a/dot/rpc/modules/state_integration_test.go +++ b/dot/rpc/modules/state_integration_test.go @@ -574,7 +574,7 @@ func setupStateModule(t *testing.T) (*StateModule, *common.Hash, *common.Hash) { err = ts.SetChildStorage([]byte(`:child1`), []byte(`:key1`), []byte(`:childValue1`)) require.NoError(t, err) - sr1, err := ts.Root() + sr1, err := ts.Trie().Hash() require.NoError(t, err) err = chain.Storage.StoreTrie(ts, nil) require.NoError(t, err) diff --git a/dot/rpc/modules/system_integration_test.go b/dot/rpc/modules/system_integration_test.go index ea3fce3e97..275a741892 100644 --- a/dot/rpc/modules/system_integration_test.go +++ b/dot/rpc/modules/system_integration_test.go @@ -330,7 +330,7 @@ func setupSystemModule(t *testing.T) *SystemModule { Header: types.Header{ Number: 3, ParentHash: chain.Block.BestBlockHash(), - StateRoot: ts.MustRoot(), + StateRoot: ts.Trie().MustHash(), Digest: digest, }, Body: types.Body{}, diff --git a/dot/state/inmemory_storage.go b/dot/state/inmemory_storage.go index 52d7273c08..592852836d 100644 --- a/dot/state/inmemory_storage.go +++ b/dot/state/inmemory_storage.go @@ -60,7 +60,7 @@ func NewStorageState(db database.Database, blockState *BlockState, // StoreTrie stores the given trie in the StorageState and writes it to the database func (s *InmemoryStorageState) StoreTrie(ts *storage.TrieState, header *types.Header) error { - root := ts.MustRoot() + root := ts.Trie().MustHash() s.tries.softSet(root, ts.Trie()) if header != nil { diff --git a/dot/state/inmemory_storage_test.go b/dot/state/inmemory_storage_test.go index 2d98547614..7949cdaffe 100644 --- a/dot/state/inmemory_storage_test.go +++ b/dot/state/inmemory_storage_test.go @@ -34,7 +34,7 @@ func TestStorage_StoreAndLoadTrie(t *testing.T) { ts, err := storage.TrieState(&trie.EmptyHash) require.NoError(t, err) - root, err := ts.Root() + root, err := ts.Trie().Hash() require.NoError(t, err) err = storage.StoreTrie(ts, nil) require.NoError(t, err) @@ -57,7 +57,7 @@ func TestStorage_GetStorageByBlockHash(t *testing.T) { value := []byte("testvalue") ts.Put(key, value) - root, err := ts.Root() + root, err := ts.Trie().Hash() require.NoError(t, err) err = storage.StoreTrie(ts, nil) require.NoError(t, err) @@ -89,7 +89,7 @@ func TestStorage_TrieState(t *testing.T) { require.NoError(t, err) ts.Put([]byte("noot"), []byte("washere")) - root, err := ts.Root() + root, err := ts.Trie().Hash() require.NoError(t, err) err = storage.StoreTrie(ts, nil) require.NoError(t, err) @@ -123,7 +123,7 @@ func TestStorage_LoadFromDB(t *testing.T) { ts.Put(kv.key, kv.value) } - root, err := ts.Root() + root, err := ts.Trie().Hash() require.NoError(t, err) // Write trie to disk. @@ -196,7 +196,7 @@ func TestGetStorageChildAndGetStorageFromChild(t *testing.T) { trieState := runtime.NewTrieState(genTrie) - header := types.NewHeader(blockState.GenesisHash(), trieState.MustRoot(), + header := types.NewHeader(blockState.GenesisHash(), trieState.Trie().MustHash(), common.Hash{}, 1, types.NewDigest()) err = storage.StoreTrie(trieState, header) diff --git a/dot/state/service_integration_test.go b/dot/state/service_integration_test.go index 15c463aa2b..f3246ed23c 100644 --- a/dot/state/service_integration_test.go +++ b/dot/state/service_integration_test.go @@ -478,7 +478,7 @@ func generateBlockWithRandomTrie(t *testing.T, serv *Service, err = trieState.Put(key, value) require.NoError(t, err) - trieStateRoot, err := trieState.Root() + trieStateRoot, err := trieState.Trie().Hash() require.NoError(t, err) if parent == nil { diff --git a/go.mod b/go.mod index bcdb6f18a3..7c0dee0657 100644 --- a/go.mod +++ b/go.mod @@ -4,15 +4,15 @@ require ( github.com/ChainSafe/go-schnorrkel v1.1.0 github.com/OneOfOne/xxhash v1.2.8 github.com/adrg/xdg v0.5.0 - github.com/btcsuite/btcd/btcutil v1.1.5 + github.com/btcsuite/btcd/btcutil v1.1.6 github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce github.com/centrifuge/go-substrate-rpc-client/v4 v4.1.0 - github.com/cockroachdb/pebble v1.1.1 + github.com/cockroachdb/pebble v1.1.2 github.com/cosmos/go-bip39 v1.0.0 github.com/dgraph-io/badger/v2 v2.2007.4 github.com/dgraph-io/ristretto v0.1.1 github.com/disiqueira/gotree v1.0.0 - github.com/ethereum/go-ethereum v1.14.7 + github.com/ethereum/go-ethereum v1.14.8 github.com/fatih/color v1.17.0 github.com/gammazero/deque v0.2.1 github.com/go-playground/validator/v10 v10.22.0 @@ -27,22 +27,23 @@ require ( github.com/jpillora/ipfilter v1.2.9 github.com/karlseguin/ccache/v3 v3.0.5 github.com/klauspost/compress v1.17.9 - github.com/libp2p/go-libp2p v0.33.2 - github.com/libp2p/go-libp2p-kad-dht v0.25.2 + github.com/libp2p/go-libp2p v0.36.2 + github.com/libp2p/go-libp2p-kad-dht v0.26.1 github.com/minio/sha256-simd v1.0.1 github.com/multiformats/go-multiaddr v0.13.0 github.com/nanobox-io/golang-scribble v0.0.0-20190309225732-aa3e7c118975 - github.com/prometheus/client_golang v1.19.1 + github.com/prometheus/client_golang v1.20.0 github.com/prometheus/client_model v0.6.1 github.com/qdm12/gotree v0.2.0 github.com/spf13/cobra v1.8.1 github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.9.0 github.com/tetratelabs/wazero v1.1.0 + github.com/tidwall/btree v1.7.0 go.uber.org/mock v0.4.0 - golang.org/x/crypto v0.25.0 - golang.org/x/exp v0.0.0-20240213143201-ec583247a57a - golang.org/x/term v0.22.0 + golang.org/x/crypto v0.26.0 + golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 + golang.org/x/term v0.23.0 google.golang.org/protobuf v1.34.2 ) @@ -52,7 +53,7 @@ require ( github.com/StackExchange/wmi v1.2.1 // indirect github.com/benbjohnson/clock v1.3.5 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect + github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cockroachdb/errors v1.11.3 // indirect @@ -67,48 +68,48 @@ require ( github.com/deckarep/golang-set v1.8.0 // indirect github.com/decred/base58 v1.0.5 // indirect github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 // indirect github.com/docker/go-units v0.5.0 // indirect - github.com/dustin/go-humanize v1.0.0 // indirect - github.com/elastic/gosigar v0.14.2 // indirect + github.com/dustin/go-humanize v1.0.1 // indirect + github.com/elastic/gosigar v0.14.3 // indirect github.com/flynn/noise v1.1.0 // indirect github.com/francoispqt/gojay v1.2.13 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect - github.com/gabriel-vasile/mimetype v1.4.3 // indirect + github.com/gabriel-vasile/mimetype v1.4.4 // indirect github.com/getsentry/sentry-go v0.27.0 // indirect - github.com/go-logr/logr v1.4.1 // indirect + github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect + github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/google/gopacket v1.1.19 // indirect - github.com/google/pprof v0.0.0-20240207164012-fb44976bdcd5 // indirect + github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect github.com/gtank/ristretto255 v0.1.2 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/golang-lru v0.5.4 // indirect + github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect - github.com/holiman/uint256 v1.3.0 // indirect + github.com/holiman/uint256 v1.3.1 // indirect github.com/huin/goupnp v1.3.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/ipfs/boxo v0.10.0 // indirect + github.com/ipfs/boxo v0.21.0 // indirect github.com/ipfs/go-cid v0.4.1 // indirect github.com/ipfs/go-datastore v0.6.0 // indirect github.com/ipfs/go-log v1.0.5 // indirect github.com/ipfs/go-log/v2 v2.5.1 // indirect - github.com/ipld/go-ipld-prime v0.20.0 // indirect + github.com/ipld/go-ipld-prime v0.21.0 // indirect github.com/jackpal/go-nat-pmp v1.0.2 // indirect github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect github.com/jbenet/goprocess v0.1.4 // indirect github.com/jcelliott/lumber v0.0.0-20160324203708-dd349441af25 // indirect - github.com/klauspost/cpuid/v2 v2.2.7 // indirect + github.com/klauspost/cpuid/v2 v2.2.8 // indirect github.com/koron/go-ssdp v0.0.4 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect @@ -119,7 +120,7 @@ require ( github.com/libp2p/go-libp2p-asn-util v0.4.1 // indirect github.com/libp2p/go-libp2p-kbucket v0.6.3 // indirect github.com/libp2p/go-libp2p-record v0.2.0 // indirect - github.com/libp2p/go-libp2p-routing-helpers v0.7.2 // indirect + github.com/libp2p/go-libp2p-routing-helpers v0.7.4 // indirect github.com/libp2p/go-msgio v0.3.0 // indirect github.com/libp2p/go-nat v0.2.0 // indirect github.com/libp2p/go-netroute v0.2.1 // indirect @@ -130,7 +131,7 @@ require ( github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/miekg/dns v1.1.58 // indirect + github.com/miekg/dns v1.1.61 // indirect github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b // indirect @@ -145,21 +146,38 @@ require ( github.com/multiformats/go-multihash v0.2.3 // indirect github.com/multiformats/go-multistream v0.5.0 // indirect github.com/multiformats/go-varint v0.0.7 // indirect - github.com/onsi/ginkgo/v2 v2.15.0 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/onsi/ginkgo/v2 v2.19.1 // indirect github.com/opencontainers/runtime-spec v1.2.0 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/phuslu/iploc v1.0.20230201 // indirect github.com/pierrec/xxHash v0.1.5 // indirect + github.com/pion/datachannel v1.5.8 // indirect + github.com/pion/dtls/v2 v2.2.12 // indirect + github.com/pion/ice/v2 v2.3.34 // indirect + github.com/pion/interceptor v0.1.29 // indirect + github.com/pion/logging v0.2.2 // indirect + github.com/pion/mdns v0.0.12 // indirect + github.com/pion/randutil v0.1.0 // indirect + github.com/pion/rtcp v1.2.14 // indirect + github.com/pion/rtp v1.8.8 // indirect + github.com/pion/sctp v1.8.20 // indirect + github.com/pion/sdp/v3 v3.0.9 // indirect + github.com/pion/srtp/v2 v2.0.20 // indirect + github.com/pion/stun v0.6.1 // indirect + github.com/pion/transport/v2 v2.2.10 // indirect + github.com/pion/turn/v2 v2.1.6 // indirect + github.com/pion/webrtc/v3 v3.3.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/polydawn/refmt v0.89.0 // indirect - github.com/prometheus/common v0.48.0 // indirect - github.com/prometheus/procfs v0.12.0 // indirect + github.com/prometheus/common v0.55.0 // indirect + github.com/prometheus/procfs v0.15.1 // indirect github.com/quic-go/qpack v0.4.0 // indirect - github.com/quic-go/quic-go v0.42.0 // indirect - github.com/quic-go/webtransport-go v0.6.0 // indirect + github.com/quic-go/quic-go v0.45.2 // indirect + github.com/quic-go/webtransport-go v0.8.0 // indirect github.com/raulk/go-watchdog v1.3.0 // indirect github.com/rogpeppe/go-internal v1.10.0 // indirect github.com/rs/cors v1.8.2 // indirect @@ -173,31 +191,31 @@ require ( github.com/spf13/pflag v1.0.5 // indirect github.com/stretchr/objx v0.5.2 // indirect github.com/subosito/gotenv v1.6.0 // indirect - github.com/tidwall/btree v1.7.0 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce // indirect github.com/vedhavyas/go-subkey v1.0.4-0.20220708014838-349cf3021f51 // indirect github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect + github.com/wlynxg/anet v0.0.3 // indirect go.opencensus.io v0.24.0 // indirect - go.opentelemetry.io/otel v1.24.0 // indirect - go.opentelemetry.io/otel/metric v1.24.0 // indirect - go.opentelemetry.io/otel/trace v1.24.0 // indirect + go.opentelemetry.io/otel v1.27.0 // indirect + go.opentelemetry.io/otel/metric v1.27.0 // indirect + go.opentelemetry.io/otel/trace v1.27.0 // indirect go.uber.org/dig v1.17.1 // indirect - go.uber.org/fx v1.20.1 // indirect + go.uber.org/fx v1.22.1 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/mod v0.17.0 // indirect - golang.org/x/net v0.25.0 // indirect - golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect - golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect - gonum.org/v1/gonum v0.13.0 // indirect + golang.org/x/mod v0.19.0 // indirect + golang.org/x/net v0.27.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.23.0 // indirect + golang.org/x/text v0.17.0 // indirect + golang.org/x/tools v0.23.0 // indirect + gonum.org/v1/gonum v0.15.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - lukechampine.com/blake3 v1.2.1 // indirect + lukechampine.com/blake3 v1.3.0 // indirect ) go 1.21 diff --git a/go.sum b/go.sum index 2140085fb0..1df68baaeb 100644 --- a/go.sum +++ b/go.sum @@ -39,16 +39,18 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= -github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd h1:js1gPwhcFflTZ7Nzl7WHaOTlTr5hIrR4n1NM4v9n4Kw= github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd/go.mod h1:nm3Bko6zh6bWP60UxwoT5LzdGJsQJaPo6HjduXq9p6A= +github.com/btcsuite/btcd v0.24.2 h1:aLmxPguqxza+4ag8R1I2nnJjSu2iFn/kqtHTIImswcY= +github.com/btcsuite/btcd v0.24.2/go.mod h1:5C8ChTkl5ejr3WHj8tkQSCmydiMEPB0ZhQhehpq7Dgg= github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA= github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= -github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k= -github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU= +github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= +github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE= -github.com/btcsuite/btcd/btcutil v1.1.5 h1:+wER79R5670vs/ZusMTF1yTcRYE5GUsFbdjdisflzM8= github.com/btcsuite/btcd/btcutil v1.1.5/go.mod h1:PSZZ4UitpLBWzxGd5VGOrLnmOjtPP/a6HaFo12zMs00= +github.com/btcsuite/btcd/btcutil v1.1.6 h1:zFL2+c3Lb9gEgqKNzowKUPQNb8jV7v5Oaodi/AYFd6c= +github.com/btcsuite/btcd/btcutil v1.1.6/go.mod h1:9dFymx8HpuLqBnsPELrImQeTQfKBQqzqGbbV3jK55aE= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 h1:59Kx4K6lzOW5w6nFlA0v5+lk/6sjybR934QNHSJZPTQ= @@ -82,8 +84,8 @@ github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce h1:giXvy4KSc/6g/e github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v1.1.1 h1:XnKU22oiCLy2Xn8vp1re67cXg4SAasg/WDt1NtcRFaw= -github.com/cockroachdb/pebble v1.1.1/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU= +github.com/cockroachdb/pebble v1.1.2 h1:CUh2IPtR4swHlEj48Rhfzw6l/d0qA31fItcIszQVIsA= +github.com/cockroachdb/pebble v1.1.2/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU= github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= @@ -122,8 +124,8 @@ github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/dgraph-io/badger/v2 v2.2007.3/go.mod h1:26P/7fbL4kUZVEVKLAKXkBXKOydDmM2p1e+NhhnBCAE= github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o= @@ -138,17 +140,18 @@ github.com/disiqueira/gotree v1.0.0/go.mod h1:7CwL+VWsWAU95DovkdRZAtA7YbtHwGk+tL github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/elastic/gosigar v0.12.0/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= -github.com/elastic/gosigar v0.14.2 h1:Dg80n8cr90OZ7x+bAax/QjoW/XqTI11RmA79ZwIm9/4= -github.com/elastic/gosigar v0.14.2/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= +github.com/elastic/gosigar v0.14.3 h1:xwkKwPia+hSfg9GqrCUKYdId102m9qTJIIr7egmK/uo= +github.com/elastic/gosigar v0.14.3/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/ethereum/go-ethereum v1.14.7 h1:EHpv3dE8evQmpVEQ/Ne2ahB06n2mQptdwqaMNhAT29g= -github.com/ethereum/go-ethereum v1.14.7/go.mod h1:Mq0biU2jbdmKSZoqOj29017ygFrMnB5/Rifwp980W4o= +github.com/ethereum/go-ethereum v1.14.8 h1:NgOWvXS+lauK+zFukEvi85UmmsS/OkV0N23UZ1VTIig= +github.com/ethereum/go-ethereum v1.14.8/go.mod h1:TJhyuDq0JDppAkFXgqjwpdlQApywnu/m10kFPxh8vvs= github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= @@ -162,8 +165,8 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= -github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= +github.com/gabriel-vasile/mimetype v1.4.4 h1:QjV6pZ7/XZ7ryI2KuyeEDE8wnh7fHP9YnQy+R0LnH8I= +github.com/gabriel-vasile/mimetype v1.4.4/go.mod h1:JwLei5XPtWdGiMFB5Pjle1oEeoSeEuJfJE+TtfvdB/s= github.com/gammazero/deque v0.2.1 h1:qSdsbG6pgp6nL7A0+K/B7s12mcCY/5l5SIUpMOl+dC0= github.com/gammazero/deque v0.2.1/go.mod h1:LFroj8x4cMYCukHJDbxFCkT+r9AndaJnFMuZDV34tuU= github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= @@ -174,8 +177,8 @@ github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= -github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= @@ -189,8 +192,8 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.22.0 h1:k6HsTZ0sTnROkhS//R0O+55JgM8C4Bx7ia+JlgcnOao= github.com/go-playground/validator/v10 v10.22.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= +github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= +github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0= github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -244,11 +247,12 @@ github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20240207164012-fb44976bdcd5 h1:E/LAvt58di64hlYjx7AsNS6C/ysHWYo+2qPCZKTQhRo= -github.com/google/pprof v0.0.0-20240207164012-fb44976bdcd5/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= +github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 h1:FKHo8hFI3A+7w0aUQuYXQ+6EN5stWmeY/AZqtM8xk9k= +github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= @@ -274,20 +278,20 @@ github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= -github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= +github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/holiman/uint256 v1.3.0 h1:4wdcm/tnd0xXdu7iS3ruNvxkWwrb4aeBQv19ayYn8F4= -github.com/holiman/uint256 v1.3.0/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= +github.com/holiman/uint256 v1.3.1 h1:JfTzmih28bittyHM8z360dCjIA9dbPIBlcTI6lmctQs= +github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/ipfs/boxo v0.10.0 h1:tdDAxq8jrsbRkYoF+5Rcqyeb91hgWe2hp7iLu7ORZLY= -github.com/ipfs/boxo v0.10.0/go.mod h1:Fg+BnfxZ0RPzR0nOodzdIq3A7KgoWAOWsEIImrIQdBM= +github.com/ipfs/boxo v0.21.0 h1:XpGXb+TQQ0IUdYaeAxGzWjSs6ow/Lce148A/2IbRDVE= +github.com/ipfs/boxo v0.21.0/go.mod h1:NmweAYeY1USOaJJxouy7DLr/Y5M8UBSsCI2KRivO+TY= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= github.com/ipfs/go-datastore v0.5.1/go.mod h1:9zhEApYMTl17C8YDp7JmU7sQZi2/wqiYh73hakZ90Bk= @@ -298,16 +302,16 @@ github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46U github.com/ipfs/go-ds-badger2 v0.1.3 h1:Zo9JicXJ1DmXTN4KOw7oPXkspZ0AWHcAFCP1tQKnegg= github.com/ipfs/go-ds-badger2 v0.1.3/go.mod h1:TPhhljfrgewjbtuL/tczP8dNrBYwwk+SdPYbms/NO9w= github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw= -github.com/ipfs/go-ipfs-util v0.0.2 h1:59Sswnk1MFaiq+VcaknX7aYEyGyGDAA73ilhEK2POp8= -github.com/ipfs/go-ipfs-util v0.0.2/go.mod h1:CbPtkWJzjLdEcezDns2XYaehFVNXG9zrdrtMecczcsQ= +github.com/ipfs/go-ipfs-util v0.0.3 h1:2RFdGez6bu2ZlZdI+rWfIdbQb1KudQp3VGwPtdNCmE0= +github.com/ipfs/go-ipfs-util v0.0.3/go.mod h1:LHzG1a0Ig4G+iZ26UUOMjHd+lfM84LZCrn17xAKWBvs= github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8= github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo= github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g= github.com/ipfs/go-log/v2 v2.5.0/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI= github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY= github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI= -github.com/ipld/go-ipld-prime v0.20.0 h1:Ud3VwE9ClxpO2LkCYP7vWPc0Fo+dYdYzgxUJZ3uRG4g= -github.com/ipld/go-ipld-prime v0.20.0/go.mod h1:PzqZ/ZR981eKbgdr3y2DJYeD/8bgMawdGVlJDE8kK+M= +github.com/ipld/go-ipld-prime v0.21.0 h1:n4JmcpOlPDIxBcY037SVfpd1G+Sj1nKZah0m6QH9C2E= +github.com/ipld/go-ipld-prime v0.21.0/go.mod h1:3RLqy//ERg/y5oShXXdx5YIp50cFGOanyMctpPjsvxQ= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA= @@ -338,8 +342,8 @@ github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6 github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= -github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= -github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM= +github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/koron/go-ssdp v0.0.4 h1:1IDwrghSKYM7yLf7XCzbByg2sJ/JcNOZRXS2jczTwz0= github.com/koron/go-ssdp v0.0.4/go.mod h1:oDXq+E5IL5q0U8uSBcoAXzTzInwy5lEgC91HoKtbmZk= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -352,6 +356,8 @@ github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= @@ -360,18 +366,18 @@ github.com/libp2p/go-cidranger v1.1.0 h1:ewPN8EZ0dd1LSnrtuwd4709PXVcITVeuwbag38y github.com/libp2p/go-cidranger v1.1.0/go.mod h1:KWZTfSr+r9qEo9OkI9/SIEeAtw+NNoU0dXIXt15Okic= github.com/libp2p/go-flow-metrics v0.1.0 h1:0iPhMI8PskQwzh57jB9WxIuIOQ0r+15PChFGkx3Q3WM= github.com/libp2p/go-flow-metrics v0.1.0/go.mod h1:4Xi8MX8wj5aWNDAZttg6UPmc0ZrnFNsMtpsYUClFtro= -github.com/libp2p/go-libp2p v0.33.2 h1:vCdwnFxoGOXMKmaGHlDSnL4bM3fQeW8pgIa9DECnb40= -github.com/libp2p/go-libp2p v0.33.2/go.mod h1:zTeppLuCvUIkT118pFVzA8xzP/p2dJYOMApCkFh0Yww= +github.com/libp2p/go-libp2p v0.36.2 h1:BbqRkDaGC3/5xfaJakLV/BrpjlAuYqSB0lRvtzL3B/U= +github.com/libp2p/go-libp2p v0.36.2/go.mod h1:XO3joasRE4Eup8yCTTP/+kX+g92mOgRaadk46LmPhHY= github.com/libp2p/go-libp2p-asn-util v0.4.1 h1:xqL7++IKD9TBFMgnLPZR6/6iYhawHKHl950SO9L6n94= github.com/libp2p/go-libp2p-asn-util v0.4.1/go.mod h1:d/NI6XZ9qxw67b4e+NgpQexCIiFYJjErASrYW4PFDN8= -github.com/libp2p/go-libp2p-kad-dht v0.25.2 h1:FOIk9gHoe4YRWXTu8SY9Z1d0RILol0TrtApsMDPjAVQ= -github.com/libp2p/go-libp2p-kad-dht v0.25.2/go.mod h1:6za56ncRHYXX4Nc2vn8z7CZK0P4QiMcrn77acKLM2Oo= +github.com/libp2p/go-libp2p-kad-dht v0.26.1 h1:AazV3LCImYVkDUGAHx5lIEgZ9iUI2QQKH5GMRQU8uEA= +github.com/libp2p/go-libp2p-kad-dht v0.26.1/go.mod h1:mqRUGJ/+7ziQ3XknU2kKHfsbbgb9xL65DXjPOJwmZF8= github.com/libp2p/go-libp2p-kbucket v0.6.3 h1:p507271wWzpy2f1XxPzCQG9NiN6R6lHL9GiSErbQQo0= github.com/libp2p/go-libp2p-kbucket v0.6.3/go.mod h1:RCseT7AH6eJWxxk2ol03xtP9pEHetYSPXOaJnOiD8i0= github.com/libp2p/go-libp2p-record v0.2.0 h1:oiNUOCWno2BFuxt3my4i1frNrt7PerzB3queqa1NkQ0= github.com/libp2p/go-libp2p-record v0.2.0/go.mod h1:I+3zMkvvg5m2OcSdoL0KPljyJyvNDFGKX7QdlpYUcwk= -github.com/libp2p/go-libp2p-routing-helpers v0.7.2 h1:xJMFyhQ3Iuqnk9Q2dYE1eUTzsah7NLw3Qs2zjUV78T0= -github.com/libp2p/go-libp2p-routing-helpers v0.7.2/go.mod h1:cN4mJAD/7zfPKXBcs9ze31JGYAZgzdABEm+q/hkswb8= +github.com/libp2p/go-libp2p-routing-helpers v0.7.4 h1:6LqS1Bzn5CfDJ4tzvP9uwh42IB7TJLNFJA6dEeGBv84= +github.com/libp2p/go-libp2p-routing-helpers v0.7.4/go.mod h1:we5WDj9tbolBXOuF1hGOkR+r7Uh1408tQbAKaT5n1LE= github.com/libp2p/go-libp2p-testing v0.12.0 h1:EPvBb4kKMWO29qP4mZGyhVzUyR25dvfUIK5WDu6iPUA= github.com/libp2p/go-libp2p-testing v0.12.0/go.mod h1:KcGDRXyN7sQCllucn1cOOS+Dmm7ujhfEyXQL5lvkcPg= github.com/libp2p/go-msgio v0.3.0 h1:mf3Z8B1xcFN314sWX+2vOTShIE0Mmn2TXn3YCUQGNj0= @@ -403,8 +409,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5 github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4= -github.com/miekg/dns v1.1.58 h1:ca2Hdkz+cDg/7eNF6V56jjzuZ4aCAE+DbVkILdQWG/4= -github.com/miekg/dns v1.1.58/go.mod h1:Ypv+3b/KadlvW9vJfXOTf300O4UqaHFzFCuHz+rPkBY= +github.com/miekg/dns v1.1.61 h1:nLxbwF3XxhwVSm8g9Dghm9MHPaUZuqhPiGL+675ZmEs= +github.com/miekg/dns v1.1.61/go.mod h1:mnAarhS3nWaW+NVP2wTkYVIZyHNJ098SJZUki3eykwQ= github.com/mikioh/tcp v0.0.0-20190314235350-803a9b46060c h1:bzE/A84HN25pxAuk9Eej1Kz9OUelF97nAc82bDquQI8= github.com/mikioh/tcp v0.0.0-20190314235350-803a9b46060c/go.mod h1:0SQS9kMwD2VsyFEB++InYyBJroV/FRmBgcydeSUcJms= github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b h1:z78hV3sbSMAUoyUMM0I83AUIT6Hu17AWfgjzIbtrYFc= @@ -451,6 +457,8 @@ github.com/multiformats/go-multistream v0.5.0/go.mod h1:n6tMZiwiP2wUsR8DgfDWw1dy github.com/multiformats/go-varint v0.0.1/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8= github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/nanobox-io/golang-scribble v0.0.0-20190309225732-aa3e7c118975 h1:zm/Rb2OsnLWCY88Njoqgo4X6yt/lx3oBNWhepX0AOMU= github.com/nanobox-io/golang-scribble v0.0.0-20190309225732-aa3e7c118975/go.mod h1:4Mct/lWCFf1jzQTTAaWtOI7sXqmG+wBeiBfT4CxoaJk= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= @@ -460,14 +468,14 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/ginkgo/v2 v2.15.0 h1:79HwNRBAZHOEwrczrgSOPy+eFTTlIGELKy5as+ClttY= -github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= +github.com/onsi/ginkgo/v2 v2.19.1 h1:QXgq3Z8Crl5EL1WBAC98A5sEBHARrAJNzAmMxzLcRF0= +github.com/onsi/ginkgo/v2 v2.19.1/go.mod h1:O3DtEWQkPa/F7fBMgmZQKKsluAy8pd3rEQdrjkPb9zA= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= -github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= +github.com/onsi/gomega v1.34.0 h1:eSSPsPNp6ZpsG8X1OVmOTxig+CblTc4AxpPBykhe2Os= +github.com/onsi/gomega v1.34.0/go.mod h1:MIKI8c+f+QLWk+hxbePD4i0LMJSExPaZOVfkoex4cAo= github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE7dzrbT927iTk= github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= @@ -485,6 +493,48 @@ github.com/pierrec/xxHash v0.1.5 h1:n/jBpwTHiER4xYvK3/CdPVnLDPchj8eTJFFLUb4QHBo= github.com/pierrec/xxHash v0.1.5/go.mod h1:w2waW5Zoa/Wc4Yqe0wgrIYAGKqRMf7czn2HNKXmuL+I= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= +github.com/pion/datachannel v1.5.8 h1:ph1P1NsGkazkjrvyMfhRBUAWMxugJjq2HfQifaOoSNo= +github.com/pion/datachannel v1.5.8/go.mod h1:PgmdpoaNBLX9HNzNClmdki4DYW5JtI7Yibu8QzbL3tI= +github.com/pion/dtls/v2 v2.2.7/go.mod h1:8WiMkebSHFD0T+dIU+UeBaoV7kDhOW5oDCzZ7WZ/F9s= +github.com/pion/dtls/v2 v2.2.12 h1:KP7H5/c1EiVAAKUmXyCzPiQe5+bCJrpOeKg/L05dunk= +github.com/pion/dtls/v2 v2.2.12/go.mod h1:d9SYc9fch0CqK90mRk1dC7AkzzpwJj6u2GU3u+9pqFE= +github.com/pion/ice/v2 v2.3.34 h1:Ic1ppYCj4tUOcPAp76U6F3fVrlSw8A9JtRXLqw6BbUM= +github.com/pion/ice/v2 v2.3.34/go.mod h1:mBF7lnigdqgtB+YHkaY/Y6s6tsyRyo4u4rPGRuOjUBQ= +github.com/pion/interceptor v0.1.29 h1:39fsnlP1U8gw2JzOFWdfCU82vHvhW9o0rZnZF56wF+M= +github.com/pion/interceptor v0.1.29/go.mod h1:ri+LGNjRUc5xUNtDEPzfdkmSqISixVTBF/z/Zms/6T4= +github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY= +github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms= +github.com/pion/mdns v0.0.12 h1:CiMYlY+O0azojWDmxdNr7ADGrnZ+V6Ilfner+6mSVK8= +github.com/pion/mdns v0.0.12/go.mod h1:VExJjv8to/6Wqm1FXK+Ii/Z9tsVk/F5sD/N70cnYFbk= +github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA= +github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8= +github.com/pion/rtcp v1.2.12/go.mod h1:sn6qjxvnwyAkkPzPULIbVqSKI5Dv54Rv7VG0kNxh9L4= +github.com/pion/rtcp v1.2.14 h1:KCkGV3vJ+4DAJmvP0vaQShsb0xkRfWkO540Gy102KyE= +github.com/pion/rtcp v1.2.14/go.mod h1:sn6qjxvnwyAkkPzPULIbVqSKI5Dv54Rv7VG0kNxh9L4= +github.com/pion/rtp v1.8.3/go.mod h1:pBGHaFt/yW7bf1jjWAoUjpSNoDnw98KTMg+jWWvziqU= +github.com/pion/rtp v1.8.8 h1:EtYFHI0rpUEjT/RMnGfb1vdJhbYmPG77szD72uUnSxs= +github.com/pion/rtp v1.8.8/go.mod h1:pBGHaFt/yW7bf1jjWAoUjpSNoDnw98KTMg+jWWvziqU= +github.com/pion/sctp v1.8.20 h1:sOc3lkV/tQaP57ZUEXIMdM2V92IIB2ia5v/ygnBxaEg= +github.com/pion/sctp v1.8.20/go.mod h1:oTxw8i5m+WbDHZJL/xUpe6CPIn1Y0GIKKwTLF4h53H8= +github.com/pion/sdp/v3 v3.0.9 h1:pX++dCHoHUwq43kuwf3PyJfHlwIj4hXA7Vrifiq0IJY= +github.com/pion/sdp/v3 v3.0.9/go.mod h1:B5xmvENq5IXJimIO4zfp6LAe1fD9N+kFv+V/1lOdz8M= +github.com/pion/srtp/v2 v2.0.20 h1:HNNny4s+OUmG280ETrCdgFndp4ufx3/uy85EawYEhTk= +github.com/pion/srtp/v2 v2.0.20/go.mod h1:0KJQjA99A6/a0DOVTu1PhDSw0CXF2jTkqOoMg3ODqdA= +github.com/pion/stun v0.6.1 h1:8lp6YejULeHBF8NmV8e2787BogQhduZugh5PdhDyyN4= +github.com/pion/stun v0.6.1/go.mod h1:/hO7APkX4hZKu/D0f2lHzNyvdkTGtIy3NDmLR7kSz/8= +github.com/pion/transport/v2 v2.2.1/go.mod h1:cXXWavvCnFF6McHTft3DWS9iic2Mftcz1Aq29pGcU5g= +github.com/pion/transport/v2 v2.2.3/go.mod h1:q2U/tf9FEfnSBGSW6w5Qp5PFWRLRj3NjLhCCgpRK4p0= +github.com/pion/transport/v2 v2.2.4/go.mod h1:q2U/tf9FEfnSBGSW6w5Qp5PFWRLRj3NjLhCCgpRK4p0= +github.com/pion/transport/v2 v2.2.10 h1:ucLBLE8nuxiHfvkFKnkDQRYWYfp8ejf4YBOPfaQpw6Q= +github.com/pion/transport/v2 v2.2.10/go.mod h1:sq1kSLWs+cHW9E+2fJP95QudkzbK7wscs8yYgQToO5E= +github.com/pion/transport/v3 v3.0.1/go.mod h1:UY7kiITrlMv7/IKgd5eTUcaahZx5oUN3l9SzK5f5xE0= +github.com/pion/transport/v3 v3.0.6 h1:k1mQU06bmmX143qSWgXFqSH1KUJceQvIUuVH/K5ELWw= +github.com/pion/transport/v3 v3.0.6/go.mod h1:HvJr2N/JwNJAfipsRleqwFoR3t/pWyHeZUs89v3+t5s= +github.com/pion/turn/v2 v2.1.3/go.mod h1:huEpByKKHix2/b9kmTAM3YoX6MKP+/D//0ClgUYR2fY= +github.com/pion/turn/v2 v2.1.6 h1:Xr2niVsiPTB0FPtt+yAWKFUkU1eotQbGgpTIld4x1Gc= +github.com/pion/turn/v2 v2.1.6/go.mod h1:huEpByKKHix2/b9kmTAM3YoX6MKP+/D//0ClgUYR2fY= +github.com/pion/webrtc/v3 v3.3.0 h1:Rf4u6n6U5t5sUxhYPQk/samzU/oDv7jk6BA5hyO2F9I= +github.com/pion/webrtc/v3 v3.3.0/go.mod h1:hVmrDJvwhEertRWObeb1xzulzHGeVUoPlWvxdGzcfU0= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -495,26 +545,26 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH github.com/polydawn/refmt v0.89.0 h1:ADJTApkvkeBZsN0tBTx8QjpD9JkmxbKp0cxfr9qszm4= github.com/polydawn/refmt v0.89.0/go.mod h1:/zvteZs/GwLtCgZ4BL6CBsk9IKIlexP43ObX9AxTqTw= github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= -github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= +github.com/prometheus/client_golang v1.20.0 h1:jBzTZ7B099Rg24tny+qngoynol8LtVYlA2bqx3vEloI= +github.com/prometheus/client_golang v1.20.0/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE= -github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= +github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= -github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= +github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/qdm12/gotree v0.2.0 h1:+58ltxkNLUyHtATFereAcOjBVfY6ETqRex8XK90Fb/c= github.com/qdm12/gotree v0.2.0/go.mod h1:1SdFaqKZuI46U1apbXIf25pDMNnrPuYLEqMF/qL4lY4= github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= -github.com/quic-go/quic-go v0.42.0 h1:uSfdap0eveIl8KXnipv9K7nlwZ5IqLlYOpJ58u5utpM= -github.com/quic-go/quic-go v0.42.0/go.mod h1:132kz4kL3F9vxhW3CtQJLDVwcFe5wdWeJXXijhsO57M= -github.com/quic-go/webtransport-go v0.6.0 h1:CvNsKqc4W2HljHJnoT+rMmbRJybShZ0YPFDD3NxaZLY= -github.com/quic-go/webtransport-go v0.6.0/go.mod h1:9KjU4AEBqEQidGHNDkZrb8CAa1abRaosM2yGOyiikEc= +github.com/quic-go/quic-go v0.45.2 h1:DfqBmqjb4ExSdxRIb/+qXhPC+7k6+DUNZha4oeiC9fY= +github.com/quic-go/quic-go v0.45.2/go.mod h1:1dLehS7TIR64+vxGR70GDcatWTOtMX2PUtnKsjbTurI= +github.com/quic-go/webtransport-go v0.8.0 h1:HxSrwun11U+LlmwpgM1kEqIqH90IT4N8auv/cD7QFJg= +github.com/quic-go/webtransport-go v0.8.0/go.mod h1:N99tjprW432Ut5ONql/aUhSLT0YVSlwHohQsuac9WaM= github.com/raulk/go-watchdog v1.3.0 h1:oUmdlHxdkXRJlwfG0O9omj8ukerm8MEQavSiDTEtBsk= github.com/raulk/go-watchdog v1.3.0/go.mod h1:fIvOnLbF0b0ZwkB9YU4mOW9Did//4vPZtDqv66NfsMU= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -597,6 +647,7 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= @@ -625,27 +676,28 @@ github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0 h1:GDDkbFiaK8jsSD github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 h1:EKhdznlJHPMoKr0XTrX+IlJs1LH3lyx2nfr1dOlZ79k= github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1/go.mod h1:8UvriyWtv5Q5EOgjHaSseUEdkQfvwFv1I/In/O2M9gc= +github.com/wlynxg/anet v0.0.3 h1:PvR53psxFXstc12jelG6f1Lv4MWqE0tI76/hHGjh9rg= +github.com/wlynxg/anet v0.0.3/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= -go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= -go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= -go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= -go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= -go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= +go.opentelemetry.io/otel v1.27.0 h1:9BZoF3yMK/O1AafMiQTVu0YDj5Ea4hPhxCs7sGva+cg= +go.opentelemetry.io/otel v1.27.0/go.mod h1:DMpAK8fzYRzs+bi3rS5REupisuqTheUlSZJ1WnZaPAQ= +go.opentelemetry.io/otel/metric v1.27.0 h1:hvj3vdEKyeCi4YaYfNjv2NUje8FqKqUY8IlF0FxV/ik= +go.opentelemetry.io/otel/metric v1.27.0/go.mod h1:mVFgmRlhljgBiuk/MP/oKylr4hs85GZAylncepAX/ak= +go.opentelemetry.io/otel/trace v1.27.0 h1:IqYb813p7cmbHk0a5y6pD5JPakbVfftRXABGt5/Rscw= +go.opentelemetry.io/otel/trace v1.27.0/go.mod h1:6RiD1hkAprV4/q+yd2ln1HG9GoPx39SuvvstaLBl+l4= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= -go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/dig v1.17.1 h1:Tga8Lz8PcYNsWsyHMZ1Vm0OQOUaJNDyvPImgbAu9YSc= go.uber.org/dig v1.17.1/go.mod h1:Us0rSJiThwCv2GteUN0Q7OKvU7n5J4dxZ9JKUXozFdE= -go.uber.org/fx v1.20.1 h1:zVwVQGS8zYvhh9Xxcu4w1M6ESyeMzebzj2NbSayZ4Mk= -go.uber.org/fx v1.20.1/go.mod h1:iSYNbHf2y55acNCwCXKx7LbWb5WG1Bnue5RDXz1OREg= +go.uber.org/fx v1.22.1 h1:nvvln7mwyT5s1q201YE29V/BFrGor6vMiDNpU/78Mys= +go.uber.org/fx v1.22.1/go.mod h1:HT2M7d7RHo+ebKGh9NRcrsrHHfpZ60nW3QRubMRfv48= go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= @@ -675,11 +727,15 @@ golang.org/x/crypto v0.0.0-20200602180216-279210d13fed/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20240213143201-ec583247a57a h1:HinSgX1tJRX3KsL//Gxynpw5CTOAIPhgL4W8PNiIpVE= -golang.org/x/exp v0.0.0-20240213143201-ec583247a57a/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= +golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= +golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -691,8 +747,10 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= +golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -714,8 +772,14 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210423184538-5f58ad60dda6/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= -golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= -golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= +golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -729,8 +793,10 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180810173357-98c5dad5d1a0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -757,27 +823,44 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210426080607-c94f62235c83/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= +golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= -golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= +golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= +golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= +golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= @@ -799,14 +882,16 @@ golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg= +golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.13.0 h1:a0T3bh+7fhRyqeNbiC3qVHYmkiQgit3wnNan/2c0HMM= -gonum.org/v1/gonum v0.13.0/go.mod h1:/WPYRckkfWrhWefxyYTfrTtQR0KH4iyHNuzxqXAKyAU= +gonum.org/v1/gonum v0.15.0 h1:2lYxjRbTYyxkJxlhC+LvJIx3SsANPdRybu1tGj9/OrQ= +gonum.org/v1/gonum v0.15.0/go.mod h1:xzZVBJBtS+Mz4q0Yl2LJTk+OxOg4jiXZ7qBoM0uISGo= google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y= @@ -870,7 +955,7 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI= -lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= +lukechampine.com/blake3 v1.3.0 h1:sJ3XhFINmHSrYCgl958hscfIa3bw8x4DqMP3u1YvoYE= +lukechampine.com/blake3 v1.3.0/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= sourcegraph.com/sourcegraph/go-diff v0.5.0/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2zzQcaEFbx8wA8rck= sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0= diff --git a/lib/runtime/storage/trie.go b/lib/runtime/storage/trie.go index 074c6dba7d..c8a1eb5828 100644 --- a/lib/runtime/storage/trie.go +++ b/lib/runtime/storage/trie.go @@ -136,18 +136,14 @@ func (t *TrieState) Get(key []byte) []byte { return t.state.Get(key) } -// MustRoot returns the trie's root hash. It panics if it fails to compute the root. -func (t *TrieState) MustRoot() common.Hash { - hash, err := t.Root() - if err != nil { - panic(err) - } - - return hash -} - -// Root returns the trie's root hash +// Root is executed in the block finalisation +// when it is wrapping everything and needs to ensure +// the root hash matches the expected one, in this case +// we commit the changeset we started in the beginning +// WARN: this function should be called only by ext_storage_root_version_1 func (t *TrieState) Root() (common.Hash, error) { + t.CommitTransaction() + // Since the Root function is called without running transactions we can do: if currentTx := t.getCurrentTransaction(); currentTx != nil { panic("cannot calculate root with running transactions") diff --git a/lib/runtime/storage/trie_test.go b/lib/runtime/storage/trie_test.go index 9d9b2f05f0..e263f705f3 100644 --- a/lib/runtime/storage/trie_test.go +++ b/lib/runtime/storage/trie_test.go @@ -588,8 +588,8 @@ func TestTrieState_Root(t *testing.T) { ts.Put([]byte(tc), []byte(tc)) } - expected := ts.MustRoot() - require.Equal(t, expected, ts.MustRoot()) + expected := ts.Trie().MustHash() + require.Equal(t, expected, ts.Trie().MustHash()) } func TestTrieState_ChildRoot(t *testing.T) { diff --git a/lib/runtime/wazero/imports_test.go b/lib/runtime/wazero/imports_test.go index c21520349f..41eecc1827 100644 --- a/lib/runtime/wazero/imports_test.go +++ b/lib/runtime/wazero/imports_test.go @@ -2182,6 +2182,7 @@ func Test_ext_storage_read_version_1_OffsetLargerThanValue(t *testing.T) { func Test_ext_storage_root_version_1(t *testing.T) { inst := NewTestInstance(t, runtime.HOST_API_TEST_RUNTIME, TestWithVersion(DefaultVersion)) + inst.Context.Storage.StartTransaction() ret, err := inst.Exec("rtm_ext_storage_root_version_1", []byte{}) require.NoError(t, err) @@ -2200,6 +2201,7 @@ func Test_ext_storage_root_version_2(t *testing.T) { encVersion, err := scale.Marshal(stateVersion) require.NoError(t, err) + inst.Context.Storage.StartTransaction() ret, err := inst.Exec("rtm_ext_storage_root_version_2", encVersion) require.NoError(t, err) diff --git a/lib/runtime/wazero/instance.go b/lib/runtime/wazero/instance.go index d126f2f2a4..d817a2e617 100644 --- a/lib/runtime/wazero/instance.go +++ b/lib/runtime/wazero/instance.go @@ -930,6 +930,7 @@ func (in *Instance) InitializeBlock(header *types.Header) error { return fmt.Errorf("cannot encode header: %w", err) } + in.Context.Storage.StartTransaction() _, err = in.Exec(runtime.CoreInitializeBlock, encodedHeader) return err } @@ -992,6 +993,10 @@ func (in *Instance) ExecuteBlock(block *types.Block) ([]byte, error) { return nil, err } + // start an changeset at the beginning of the block execution + // then clear prefix can work correctly by ignoring + // keys included under current block execution + in.Context.Storage.StartTransaction() return in.Exec(runtime.CoreExecuteBlock, bdEnc) } diff --git a/lib/runtime/wazero/instance_test.go b/lib/runtime/wazero/instance_test.go index 001a74a30d..a173fbeee0 100644 --- a/lib/runtime/wazero/instance_test.go +++ b/lib/runtime/wazero/instance_test.go @@ -11,7 +11,7 @@ import ( "path/filepath" "testing" - "github.com/ChainSafe/gossamer/dot/network" + "github.com/ChainSafe/gossamer/dot/network/messages" "github.com/ChainSafe/gossamer/dot/types" "github.com/ChainSafe/gossamer/internal/database" "github.com/ChainSafe/gossamer/internal/log" @@ -1000,7 +1000,7 @@ func TestInstance_ExecuteBlock_PaseoRuntime_PaseoBlock1008649(t *testing.T) { instance, err := NewInstanceFromTrie(paseoTrie, cfg) require.NoError(t, err) - blockResponse := &network.BlockResponseMessage{} + blockResponse := &messages.BlockResponseMessage{} err = blockResponse.Decode(common.MustHexToBytes("0x0ab81d0a202dcc0a3c3d4953da49e0006da24c7617a55e2e169dcf59aacc5fbd5856b14fb312c702c154fd69bab5b5676a746c32868b053980a53bb0aaae89fc47d5408056883eb826903d00c75b6a15438acb997f925a09714092fc463af3ba44ab93654c89b775c44dfe13dd89f50472e232a4cff46ce80cfa07fa8777a7acfc2c40a52e7f23b481a2a1b60c0642414245b501030c000000e02c081100000000a4acb383795247df8efcf162903c35af1d09774e83def72e149382695048073868402c77fbb9b7c54c842910999327853c735df23083fd26bd3d2a4a3c934607a875840cddf647d6ab39189d11b07a0e423645e80e0c681ebffc54926a2d0f0a0442454546840318e81c2a62d4f79164052d2969cff6ddfcc35c6fd5bbac6bd5af7e66c64d7d32054241424501017a1cf0a7fc757c3e6cebf7b937ec6bceb42239be3cab62c2a6fec237d00f380a73bcc611b3b07533378e79e47a8b9553f438763e39358f45b09247bbf949f1881a0b280403000b00c29b2f8f011abc1ae934043600ac24e5010000000042f2d3629bcee331ba3e797da9bc8f7b114c56cf5879916f0a5ccaacbbcfcd33c0d66483f41f0aee1c18722313e9e634bd6f443dd420c63e7c8c0fa02a2a4e8824e70101000000d63256338b66d3d86dce4341858efc26160dc11f40885d7ba574b2cbdbb05e3cb80d46137b91740b84a8989e792c276101d6821b8258b50c28f53209db9d588424e50102000000d886d2c0a6a7b7d91d31cd79d6395a9314ce484ef1aab5a77a91683ba0611919551c2dbc369ba092e28b84d2d54e88ae2dd060fec60a9c0051adba0233df348224e70103000000aa4acbcf105d03e73ab393aa6227c5bba1c65c880be240b98175c21d71934d0e6b2763ec6af35d403764a56a4ce6cad623978141cd065fb9f89f3c4e2913fd8c24e70104000000ec43f63380097da3ffd0453684f3da6a3c26d6dd09ec76c06ec16d109f0c2b3b7d78226c2ef6279ffaa1bba644a82575830156804e425a36817e16bcc453888024e50105000000a63a6b5385a3b5991f259872608e5adbe41aa41835c72c200457cb61919d393c222e41187cda30be8d7f8661ea9ae1d6310b2f19bcbda51815bae6b12b088b8c24e501060000006a80b176d88acb02140385f788e128e4a67f97848074dde691d674d8e8cb191d1b2994d37d17d4bee2bcc523832b98fc3f4227e1ddc54cf4dcfdd41ade07e38824e50107000000020532162b48a2be92028352a84523d07036e767430e1dde4aec92efa64e155e74f7fbbb92ec95db26f115950a877efab4a1a30df074cf59c7cc244d950f1b8e24e501080000006c1864b2125754ffddfe8d6f60df4f4f342fda159a9b7ac407b34dfd17c9a532287ff9011bd9d587d98bb0543bb8b92ea854f1385672c76c733c54cea0bb498924e50109000000ec340ccf10147706d756441b1648ddb8b94b119e10f2996682c27d612df5d547d7506c11490121ae784f9306655425b6e81f4cba0fb8e43b2892b2cf4588a68f24e5010a000000f4d3ecd0f7c4b61d01ecbeb4bb06df50e483d57dfd7eeced80baf6d8ce9d2b0c594457e8b2c29a55558091bdb5632b535def00b9d3171b77ce4348037866b08724e7010b000000ce2cba80c37ae22e7b18bad4955949ab3bf897a56b10962c03cd13374a09f15342b14e8f9f89610326f4591ad8cd85d26b31128f8a5fb734991242ecb24f728824e5010c000000ec431a72f9684c632c21eba1798c25a7f50a20323a82288e3b8b70fcec65941acc3dcf8794966948aa288929f2857d1c6bb6ace040d76428f1aeed86992c688124e5010d000000383d447003f376f260094e480901c952f9e6f7898963f0ea9f2c182bcf970b38807310db0bb96bda55bbf2aa308e39c40f9216a01661ee7f285143ccf9692f8824e5010e0000007a7d6c9dca3c7fa7ae893defbccd66b4667c6bbfc343c9d28a82107df2b4774ecd1825a31f4ebd10c1ef99be9bd3a2ea1e82c9d5498ed9d74cf48dffe388b98324e7010f00000024aa634d5fe7eeee763b99bd866ebebe200276324725e0fd4805ef8c8ea12e0dfd31821e04853e387ad5e0d0784dbb8fceabda017c18708cad4b1deacd39a58b24e701100000006edb6f3c9d893bbb12ef1d96cbb6b2c0056c85efcc2209b946a6493c875b671db57fa876570554e9e2125aaddfb78329c5904c3a395f50c93172cb6439529c8424e501110000004a0a3ba9408d28223b760c0c45858d07c40a73b9d6d571ab556c03687404c330c812e899eb55aaafab0f433caa8b1672a654aad12547f515096362b62b01ed8b24e501120000003cb4aebfd1885088d9b8fa5fffc03d7c0534ad854be79c4b79c312c64f8c5b57ca31bcb5d187074357c1141b860d76a6b8265234b48cb1f35fbcb3907bcb6b8b24e701130000006caab829a264c4111a3d5c25adf7a453beaf10ec1808e9e56781666fb4a8947c3dddebe5546c2659136d9b54cb7effb86e7fb674c6ec6ea1b0be58e424426a8e24e701140000006acbb3e3747dd3cc8da8b799825ac9acdda50f06a50683a78d98fa0974fc0c7d9466a23685dfb7e4beaa5f3d3ca823d59a418f69a576df97dc3daf7eb1186c8624e70115000000f4676fdc3ef1fd8e9335ee39037e259bfe47d3c44c281f1e65e24c8754f99433735a16bbf461f1caddefb2936217785db25f41ef0d2434e18ee24025a315058224e70116000000d00612c21d6b56d069bba06f93c4abba858ee451b77c54c97be96b425a82eb31813e55c7dbca3194189ade96148964a90c2da6a3c8bc6790bbaaa4e6e351098824e701170000009c6b8cc879a2392e7d355c1fe36e7e935ca34bdef19c8260cb0a05585ed13b6ea02c8a8309807dbdaeccc722d4857000f9d0dd924d02562a7ab116ea34fe4b8a24e50118000000e2cab7cd19724ca5dd6d8451e2029422b7182ab865a41a7424b92058602cac45fe1b3b683cd904f66bb3a30f0cda65c28848dffbb861b4734e6195a25d15ba8724e70119000000ccb1fc1afac473206a141c1ae6b396009b1c9b18e958dbd2ff3ecdcf49de800a2b49d32e21f4b48ee612bea0e2c79a4033832bfbac8301e47b7466d0ce8d6c8724e7011a000000c29e7059a38a50559fc8b788eb39b4222427fc8505bce5e9ec909b32317801015e6603dc610cd4980d53682b44954dc882ec1b2410e6ee62396f08f320b3468c24e7011b00000028ecbd92be9f51dcfeaea071e13972e510b78dfecdc378e381be8ffb9ff0697e3b8487a9aa611d251cfc8135b4bcfe97c62870a887ec0532356b869953020a8e24e5011c000000623b8905d098e1be6b3e8a27f7c9d166d57276981447829f76b827a3ce092e560f459ace810b0e5fb56b67c3081afd36fc30d4d1f5a01a3319f6333ea7593e8e24e5011d00000074a390dec4d88662d690e7ac19e109c6bfc05d48462918e60f31f07415925d4987e9760e07e29b726365ccacb5ddbb226e8817b85b298d39c84c79db67df6c8124e7011e00000046111b603d728bd7ccc2d9f61268c0b24b7f709001fd2dc5389a74797021b240d2c71165f106fc0168be101c05f594d73b7f621bbf201c514d042ead4477b28624e7011f000000d0c54ec78326b880088b86fc2be9f189299d1a8a7b2ea7ec08d5ef7c57ba83074f1342900dc808b7f63223d1274d018e1c5ca2c1ec1a5d0402c6d0a8f7f3148324e70120000000947bb9cc6c1ed2c88ba722fcc863e4e5858adefe47eead172883ba23b46e4d031c1e0ccf6ee8417d93e1ec4897c34efc4a5f4f5e5a0858e7176c284a0f915e8c24e5012100000026637a5c715a6b9811b6fe0ed40ad9c682a67c6331c4ce64fb3433c976b80c3365aa283ba85e5789a010617da58b28d52378bde135506250fde6b35f2a6efe8724e7012200000084c8c3bc09469d8ce5ff553cdaeea7d5872c5b8ba2f0e60f17e8e072a2545e5ecda680e8c268284def421a166b1b3523450e69206662891c0dbf11c9443e0c8b24e70123000000c044e668ce3522a731adaecce85ebfcbe529801f8ce1a4076ddf27e0cf732d6ace24d0d4375bb3d3516069a6e347e33ea81fad337928f7f06d03bacb1c08688624e7012400000080f81db560c9ea46e6659f7f539c73e1be80e635f5fc79854525f6f6883c600198447d9b235746003dfcf0f2b683a377b91eeb4343b992c487796e846b727f8324e701250000009008cfae49b4a3157c30bbff6e32e1efa473d71bb6d101fb1e0edcde618e3063b07a0aedd3f7624fd71cec63f81de3d0d837f9d72edf6282cf6e234875dda18024e701260000007806a8eade36a4f7bb824a8ed3ee19e64411caf315fbcdeb4c709afaf81a106d504e713b4356c7dff25d00d07f65c7847c12e9843876c24033a5d23e6c40c480240200270000008a9428f41d3fdd6413602758a5b8658e4f40a2b26fa296ef7c38514b305f337aeca2686aff49e656c2f3dd676a9b2c0b5ff65c5101ab8209ed18e4d9c2d7348b24e50128000000d8e58bf175f49e98da8e49d3dfa1539fbb1a0cea98c47a40d949095385504623e20a60aeef90fce21e6428e48b481cf452b4e47acc1d7bd9d42ffdb885133e8924e50129000000ce093b859e143eb44826888c17c6dc8456543668b0637958ae6f962d1638a02093039cff3950172663f645f6c1db5e503579cc0905c4e924c6a35fbb26a0d08b24e7012a0000005e31978a3e353144f41818892d2b664d9fc2454d4b9db3923281228ceee87c453d9b3239488681c038e60356a30d8d558c0254561f3843c5b492aabc6623bc870000bc2924e71e51b4ebc3657e523f90ce68cce6d0d56cb50ff350e9e3a40762c9e822903d004fbffb5810aca70ff9e3d6560f496ca3b3beef098ab76d18e48283ec7c8ffa9b340eeeb98f740c3ab0241a51890e0e178ebc5633dd547ab1e7c89130a269507a0c0642414245b5010319000000df2c0811000000005ef4b3ef782dcf55f6908627668e7765b501877fc237cffe5b7fa4e7b1f16323662e712d38fe8b4cde838be86103551014cd55fcc201a580836de920e2afaa0b095f61f4b7a25e7a0b0f78f437b97ab00117c6baa0abccd353a6260be0637a030442454546840388660a70d906e4ff831f89296abeb9efa4bfc4b794a87c4ca2ecf65b6f52b97805424142450101d4748ed493c413ccfe6c4a08ef0dfbab6bb763ceeb6d552e72213fefe0ee9538ce2bd597a112c32b88d908ac07e38951996033344989bd8808d2406e9454318d")) //nolint:lll require.NoError(t, err) @@ -1013,8 +1013,7 @@ func TestInstance_ExecuteBlock_PaseoRuntime_PaseoBlock1008649(t *testing.T) { require.NoError(t, err) expectedRootNew := common.MustHexToHash("0xc75b6a15438acb997f925a09714092fc463af3ba44ab93654c89b775c44dfe13") - require.Equal(t, expectedRootNew, state.MustRoot()) - + require.Equal(t, expectedRootNew, state.Trie().MustHash()) } func TestInstance_ExecuteBlock_PolkadotBlock1089328(t *testing.T) { diff --git a/lib/sync/fullsync.go b/lib/sync/fullsync.go index a669eda976..c5ecd39684 100644 --- a/lib/sync/fullsync.go +++ b/lib/sync/fullsync.go @@ -11,6 +11,7 @@ import ( "time" "github.com/ChainSafe/gossamer/dot/network" + "github.com/ChainSafe/gossamer/dot/network/messages" "github.com/ChainSafe/gossamer/dot/peerset" "github.com/ChainSafe/gossamer/dot/types" "github.com/ChainSafe/gossamer/internal/database" @@ -63,7 +64,7 @@ type importer interface { // Full sync works by listening to announced blocks and requesting the blocks // from the announcing peers. type FullSyncStrategy struct { - requestQueue *requestsQueue[*network.BlockRequestMessage] + requestQueue *requestsQueue[*messages.BlockRequestMessage] unreadyBlocks *unreadyBlocks peers *peerViewSet badBlocks []string @@ -91,7 +92,7 @@ func NewFullSyncStrategy(cfg *FullSyncConfig) *FullSyncStrategy { // TODO: cap disjoitChains to don't grows indefinitely disjointChains: make([][]*types.BlockData, 0), }, - requestQueue: &requestsQueue[*network.BlockRequestMessage]{ + requestQueue: &requestsQueue[*messages.BlockRequestMessage]{ queue: list.New(), }, peers: &peerViewSet{ @@ -107,7 +108,7 @@ func (f *FullSyncStrategy) NextActions() ([]*syncTask, error) { if f.requestQueue.Len() > 0 { message, _ := f.requestQueue.PopFront() - return f.createTasks([]*network.BlockRequestMessage{message}), nil + return f.createTasks([]*messages.BlockRequestMessage{message}), nil } currentTarget := f.peers.getTarget() @@ -129,18 +130,18 @@ func (f *FullSyncStrategy) NextActions() ([]*syncTask, error) { targetBlockNumber = uint(currentTarget) } - ascendingBlockRequests := network.NewAscendingBlockRequests(startRequestAt, targetBlockNumber, - network.BootstrapRequestData) + ascendingBlockRequests := messages.NewAscendingBlockRequests(startRequestAt, targetBlockNumber, + messages.BootstrapRequestData) return f.createTasks(ascendingBlockRequests), nil } -func (f *FullSyncStrategy) createTasks(requests []*network.BlockRequestMessage) []*syncTask { +func (f *FullSyncStrategy) createTasks(requests []*messages.BlockRequestMessage) []*syncTask { tasks := make([]*syncTask, len(requests)) for idx, req := range requests { tasks[idx] = &syncTask{ request: req, - response: &network.BlockResponseMessage{}, + response: &messages.BlockResponseMessage{}, requestMaker: f.reqMaker, } } @@ -162,7 +163,7 @@ func (f *FullSyncStrategy) IsFinished(results []*syncTaskResult) (bool, []Change // if Gossamer didn't request the header, then the response should // only contain the missing parts that will complete the unreadyBlocks // and then with the blocks completed we should be able to import them - if reqRespData.req.RequestField(network.RequestedDataHeader) { + if reqRespData.req.RequestField(messages.RequestedDataHeader) { updatedFragment, ok := f.unreadyBlocks.updateDisjointFragments(reqRespData.responseData) if ok { validBlocks := validBlocksUnderFragment(highestFinalized.Number, updatedFragment) @@ -248,10 +249,10 @@ func (f *FullSyncStrategy) IsFinished(results []*syncTaskResult) (bool, []Change ) f.unreadyBlocks.newFragment(validFragment) - request := network.NewBlockRequest( + request := messages.NewBlockRequest( *variadic.Uint32OrHashFrom(validFragment[0].Header.ParentHash), - network.MaxBlocksInResponse, - network.BootstrapRequestData, network.Descending) + messages.MaxBlocksInResponse, + messages.BootstrapRequestData, messages.Descending) f.requestQueue.PushBack(request) } else { // inserting them in the queue to be processed after the main chain @@ -342,8 +343,8 @@ func (f *FullSyncStrategy) OnBlockAnnounce(from peer.ID, msg *network.BlockAnnou if !has { f.unreadyBlocks.newHeader(blockAnnounceHeader) - request := network.NewBlockRequest(*variadic.Uint32OrHashFrom(blockAnnounceHeaderHash), - 1, network.RequestedDataBody+network.RequestedDataJustification, network.Ascending) + request := messages.NewBlockRequest(*variadic.Uint32OrHashFrom(blockAnnounceHeaderHash), + 1, messages.RequestedDataBody+messages.RequestedDataJustification, messages.Ascending) f.requestQueue.PushBack(request) } @@ -351,7 +352,7 @@ func (f *FullSyncStrategy) OnBlockAnnounce(from peer.ID, msg *network.BlockAnnou } type RequestResponseData struct { - req *network.BlockRequestMessage + req *messages.BlockRequestMessage responseData []*types.BlockData } @@ -364,14 +365,14 @@ func validateResults(results []*syncTaskResult, badBlocks []string) (repChanges resultLoop: for _, result := range results { - request := result.request.(*network.BlockRequestMessage) + request := result.request.(*messages.BlockRequestMessage) if !result.completed { continue } - response := result.response.(*network.BlockResponseMessage) - if request.Direction == network.Descending { + response := result.response.(*messages.BlockResponseMessage) + if request.Direction == messages.Descending { // reverse blocks before pre-validating and placing in ready queue slices.Reverse(response.BlockData) } @@ -397,7 +398,7 @@ resultLoop: // only check if the responses forms a chain if the response contains the headers // of each block, othewise the response might only have the body/justification for // a block - if request.RequestField(network.RequestedDataHeader) && !isResponseAChain(response.BlockData) { + if request.RequestField(messages.RequestedDataHeader) && !isResponseAChain(response.BlockData) { logger.Warnf("response from %s is not a chain", result.who) repChanges = append(repChanges, Change{ who: result.who, @@ -519,13 +520,13 @@ func formsSequence(prev, next *types.BlockData) bool { } // validateResponseFields checks that the expected fields are in the block data -func validateResponseFields(req *network.BlockRequestMessage, blocks []*types.BlockData) error { +func validateResponseFields(req *messages.BlockRequestMessage, blocks []*types.BlockData) error { for _, bd := range blocks { - if req.RequestField(network.RequestedDataHeader) && bd.Header == nil { + if req.RequestField(messages.RequestedDataHeader) && bd.Header == nil { return fmt.Errorf("%w: %s", errNilHeaderInResponse, bd.Hash) } - if req.RequestField(network.RequestedDataBody) && bd.Body == nil { + if req.RequestField(messages.RequestedDataBody) && bd.Body == nil { return fmt.Errorf("%w: %s", errNilBodyInResponse, bd.Hash) } } diff --git a/lib/sync/fullsync_handle_block.go b/lib/sync/fullsync_handle_block.go index 7c7a563760..a22f44a5a7 100644 --- a/lib/sync/fullsync_handle_block.go +++ b/lib/sync/fullsync_handle_block.go @@ -168,7 +168,7 @@ func (b *blockImporter) handleBlock(block *types.Block, announceImportedBlock bo return err } - root := ts.MustRoot() + root := ts.Trie().MustHash() if !bytes.Equal(parent.StateRoot[:], root[:]) { panic("parent state root does not match snapshot state root") } diff --git a/lib/sync/fullsync_test.go b/lib/sync/fullsync_test.go index 4459ddd97a..29313383c5 100644 --- a/lib/sync/fullsync_test.go +++ b/lib/sync/fullsync_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/ChainSafe/gossamer/dot/network" + "github.com/ChainSafe/gossamer/dot/network/messages" "github.com/ChainSafe/gossamer/dot/types" "github.com/ChainSafe/gossamer/lib/common" "github.com/ChainSafe/gossamer/lib/common/variadic" @@ -63,11 +64,11 @@ func TestFullSyncNextActions(t *testing.T) { // the we should have 2 requests start from 1 and request 128 and another // request starting from 129 and requesting 128 require.Len(t, task, 2) - request := task[0].request.(*network.BlockRequestMessage) + request := task[0].request.(*messages.BlockRequestMessage) require.Equal(t, uint32(1), request.StartingBlock.Uint32()) require.Equal(t, uint32(128), *request.Max) - request = task[1].request.(*network.BlockRequestMessage) + request = task[1].request.(*messages.BlockRequestMessage) require.Equal(t, uint32(129), request.StartingBlock.Uint32()) require.Equal(t, uint32(128), *request.Max) }) @@ -78,35 +79,35 @@ func TestFullSyncNextActions(t *testing.T) { } cases := map[string]struct { - setupRequestQueue func(*testing.T) *requestsQueue[*network.BlockRequestMessage] + setupRequestQueue func(*testing.T) *requestsQueue[*messages.BlockRequestMessage] expectedTasksLen int - expectedTasks []*network.BlockRequestMessage + expectedTasks []*messages.BlockRequestMessage }{ "should_have_one_from_request_queue_and_one_from_target_chasing": { - setupRequestQueue: func(t *testing.T) *requestsQueue[*network.BlockRequestMessage] { - request := network.NewAscendingBlockRequests( + setupRequestQueue: func(t *testing.T) *requestsQueue[*messages.BlockRequestMessage] { + request := messages.NewAscendingBlockRequests( 129, 129+128, - network.BootstrapRequestData) + messages.BootstrapRequestData) require.Len(t, request, 1) - rq := &requestsQueue[*network.BlockRequestMessage]{queue: list.New()} + rq := &requestsQueue[*messages.BlockRequestMessage]{queue: list.New()} for _, req := range request { rq.PushBack(req) } return rq }, expectedTasksLen: 2, - expectedTasks: []*network.BlockRequestMessage{ + expectedTasks: []*messages.BlockRequestMessage{ { - RequestedData: network.BootstrapRequestData, + RequestedData: messages.BootstrapRequestData, StartingBlock: *variadic.Uint32OrHashFrom(129), - Direction: network.Ascending, + Direction: messages.Ascending, Max: refTo(128), }, { - RequestedData: network.BootstrapRequestData, + RequestedData: messages.BootstrapRequestData, StartingBlock: *variadic.Uint32OrHashFrom(1), - Direction: network.Ascending, + Direction: messages.Ascending, Max: refTo(128), }, }, @@ -114,30 +115,30 @@ func TestFullSyncNextActions(t *testing.T) { // creating a amount of 4 requests, but since we have a max num of // request set to 2 (see FullSyncConfig) we should only have 2 tasks "should_have_two_tasks": { - setupRequestQueue: func(t *testing.T) *requestsQueue[*network.BlockRequestMessage] { - request := network.NewAscendingBlockRequests( + setupRequestQueue: func(t *testing.T) *requestsQueue[*messages.BlockRequestMessage] { + request := messages.NewAscendingBlockRequests( 129, 129+(4*128), - network.BootstrapRequestData) + messages.BootstrapRequestData) require.Len(t, request, 4) - rq := &requestsQueue[*network.BlockRequestMessage]{queue: list.New()} + rq := &requestsQueue[*messages.BlockRequestMessage]{queue: list.New()} for _, req := range request { rq.PushBack(req) } return rq }, expectedTasksLen: 2, - expectedTasks: []*network.BlockRequestMessage{ + expectedTasks: []*messages.BlockRequestMessage{ { - RequestedData: network.BootstrapRequestData, + RequestedData: messages.BootstrapRequestData, StartingBlock: *variadic.Uint32OrHashFrom(129), - Direction: network.Ascending, + Direction: messages.Ascending, Max: refTo(128), }, { - RequestedData: network.BootstrapRequestData, + RequestedData: messages.BootstrapRequestData, StartingBlock: *variadic.Uint32OrHashFrom(257), - Direction: network.Ascending, + Direction: messages.Ascending, Max: refTo(128), }, }, @@ -179,11 +180,11 @@ func TestFullSyncIsFinished(t *testing.T) { err := yaml.Unmarshal(rawWestendBlocks, westendBlocks) require.NoError(t, err) - fstTaskBlockResponse := &network.BlockResponseMessage{} + fstTaskBlockResponse := &messages.BlockResponseMessage{} err = fstTaskBlockResponse.Decode(common.MustHexToBytes(westendBlocks.Blocks1To10)) require.NoError(t, err) - sndTaskBlockResponse := &network.BlockResponseMessage{} + sndTaskBlockResponse := &messages.BlockResponseMessage{} err = sndTaskBlockResponse.Decode(common.MustHexToBytes(westendBlocks.Blocks129To256)) require.NoError(t, err) @@ -193,8 +194,8 @@ func TestFullSyncIsFinished(t *testing.T) { // 1 -> 10 { who: peer.ID("peerA"), - request: network.NewBlockRequest(*variadic.Uint32OrHashFrom(1), 128, - network.BootstrapRequestData, network.Ascending), + request: messages.NewBlockRequest(*variadic.Uint32OrHashFrom(1), 128, + messages.BootstrapRequestData, messages.Ascending), completed: true, response: fstTaskBlockResponse, }, @@ -203,8 +204,8 @@ func TestFullSyncIsFinished(t *testing.T) { // 129 -> 256 { who: peer.ID("peerA"), - request: network.NewBlockRequest(*variadic.Uint32OrHashFrom(1), 128, - network.BootstrapRequestData, network.Ascending), + request: messages.NewBlockRequest(*variadic.Uint32OrHashFrom(1), 128, + messages.BootstrapRequestData, messages.Ascending), completed: true, response: sndTaskBlockResponse, }, @@ -252,17 +253,17 @@ func TestFullSyncIsFinished(t *testing.T) { require.Len(t, fs.unreadyBlocks.disjointChains, 1) require.Equal(t, fs.unreadyBlocks.disjointChains[0], sndTaskBlockResponse.BlockData) - expectedAncestorRequest := network.NewBlockRequest( + expectedAncestorRequest := messages.NewBlockRequest( *variadic.Uint32OrHashFrom(sndTaskBlockResponse.BlockData[0].Header.ParentHash), - network.MaxBlocksInResponse, - network.BootstrapRequestData, network.Descending) + messages.MaxBlocksInResponse, + messages.BootstrapRequestData, messages.Descending) message, ok := fs.requestQueue.PopFront() require.True(t, ok) require.Equal(t, expectedAncestorRequest, message) // ancestor search response - ancestorSearchResponse := &network.BlockResponseMessage{} + ancestorSearchResponse := &messages.BlockResponseMessage{} err = ancestorSearchResponse.Decode(common.MustHexToBytes(westendBlocks.Blocks1To128)) require.NoError(t, err) diff --git a/lib/sync/service.go b/lib/sync/service.go index 2a8dafe51c..1b968ad24c 100644 --- a/lib/sync/service.go +++ b/lib/sync/service.go @@ -10,6 +10,7 @@ import ( "time" "github.com/ChainSafe/gossamer/dot/network" + "github.com/ChainSafe/gossamer/dot/network/messages" "github.com/ChainSafe/gossamer/dot/peerset" "github.com/ChainSafe/gossamer/dot/types" "github.com/ChainSafe/gossamer/internal/log" @@ -185,8 +186,8 @@ func (s *SyncService) OnConnectionClosed(who peer.ID) { s.workerPool.removeWorker(who) } -func (s *SyncService) CreateBlockResponse(who peer.ID, req *network.BlockRequestMessage) ( - *network.BlockResponseMessage, error) { +func (s *SyncService) CreateBlockResponse(who peer.ID, req *messages.BlockRequestMessage) ( + *messages.BlockResponseMessage, error) { return nil, nil } diff --git a/lib/sync/worker_pool.go b/lib/sync/worker_pool.go index fbfe144cc9..a12bbb0e48 100644 --- a/lib/sync/worker_pool.go +++ b/lib/sync/worker_pool.go @@ -9,6 +9,7 @@ import ( "time" "github.com/ChainSafe/gossamer/dot/network" + "github.com/ChainSafe/gossamer/dot/network/messages" "github.com/libp2p/go-libp2p/core/peer" "golang.org/x/exp/maps" ) @@ -25,15 +26,15 @@ const ( type syncTask struct { requestMaker network.RequestMaker - request network.Message - response network.ResponseMessage + request messages.P2PMessage + response messages.P2PMessage } type syncTaskResult struct { who peer.ID completed bool - request network.Message - response network.ResponseMessage + request messages.P2PMessage + response messages.P2PMessage } type syncWorkerPool struct { diff --git a/pkg/trie/triedb/README.md b/pkg/trie/triedb/README.md new file mode 100644 index 0000000000..682c810d3d --- /dev/null +++ b/pkg/trie/triedb/README.md @@ -0,0 +1,114 @@ +# trieDB + + +`triedb` is a library that acts as a layer over a key-value database, formatting those data into a radix-16 trie compatible with [polkadot spec](https://spec.polkadot.network/chap-state#sect-state-storage). +It offers functionalities for writing and reading operations and uses lazy loading to fetch data from the database, as well as a caching system to optimize searches. + +## Main features + +- **Writes**: Basic functions to manipulate data in the trie. +- **Reads**: Basic functions to get data from the trie. +- **Lazy Loading**: Load data on demand. +- **Caching**: Enhances search performance. +- **Compatibility**: Works with any database implementing the `db.RWDatabase` interface and any cache implementing the `cache.TrieCache` interface. +- **Merkle proofs**: Create and verify merkle proofs. +- **Iterator**: Traverse the trie keys in order. + +## Usage + +### Create a Trie + +To create an empty trie: + +```go +trie := triedb.NewEmptyTrieDB(db) +``` + +### Insert Data + +To insert a key and its associated value: + +```go +err := trie.Put([]byte("key"), []byte("value")) +``` + +### Get Data + +To get the value associated with a key: + +```go +value := trie.Get([]byte("key")) +``` + +> Note: value will be empty `[]byte()` if there is no value for that key in the DB + + +### Remove Data + +To delete a key and its associated value: + +```go +trie.Delete([]byte("key")) +``` + +### Commit Data + +All modifications happen in memory until a commit is applied to the database. The commit is automatically applied whenever the root hash of the trie is calculated using: + +```go +rootHash, err := trie.Hash() +if err != nil { + // handle error +} +``` + +or + +```go +rootHash := trie.MustHash() +``` + +### Create a merkle proof + +To create a merkle proof you will need a `db` previously created using a trie, the `trieVersion` (v0, v1), the `rootHash` for the trie in that db and an slice of `keys` for which the proof will be created. + +```go +merkleProof, err := proof.NewMerkleProof(db, trieVersion, rootHash, keys) +``` + +### Verify merkle proofs + +In order to verify a merkle proof you can execute the `Verify` method over a previously created proof specifying the `trieVersion`, `rootHash` and the `items` you want to check, doing the following: + +```go +err = merkleProof.Verify(trieVersion, rootHash, items) +if err != nil { + fmt.Println("Invalid proof") +} +``` + +> Note: items is a slice of `proofItem` structure. + +### Iterator + +There are two ways to use the key iterator. +Iterating by keys + +```go +trieIterator := triedb.NewTrieDBIterator(trie) + +for key := iter.NextKey(); key != nil; key = iter.NextKey() { + fmt.Printf("key: %s", key) +} +``` + +Iterating by entries + +```go +trieIterator := triedb.NewTrieDBIterator(trie) + +for entry := iter.NextEntry(); entry != nil; entry = iter.NextEntry() { + fmt.Printf("key: %s, value: %s", entry.Key, entry.Value) +} +``` + diff --git a/scripts/p2p/common_p2p.go b/scripts/p2p/common_p2p.go new file mode 100644 index 0000000000..fd03ca3924 --- /dev/null +++ b/scripts/p2p/common_p2p.go @@ -0,0 +1,171 @@ +// Copyright 2024 ChainSafe Systems (ON) +// SPDX-License-Identifier: LGPL-3.0-only + +package p2p + +import ( + "encoding/json" + "fmt" + "io" + "log" + "os" + "path/filepath" + + "github.com/ChainSafe/gossamer/dot/network" + "github.com/ChainSafe/gossamer/dot/network/messages" + "github.com/ChainSafe/gossamer/internal/pubip" + "github.com/libp2p/go-libp2p" + "github.com/libp2p/go-libp2p/core/crypto" + "github.com/libp2p/go-libp2p/core/host" + lip2pnetwork "github.com/libp2p/go-libp2p/core/network" + "github.com/libp2p/go-libp2p/core/peer" + ma "github.com/multiformats/go-multiaddr" +) + +type ChainSpec struct { + Bootnodes []string `json:"bootnodes"` + ProtocolID string `json:"protocolId"` +} + +func SetupP2PClient() host.Host { + const port = 30333 + + // create multiaddress (without p2p identity) + listenAddress := fmt.Sprintf("/ip4/0.0.0.0/tcp/%d", port) + addr, err := ma.NewMultiaddr(listenAddress) + if err != nil { + log.Fatalf("creating multiaddress: %s", err.Error()) + } + + var externalAddr ma.Multiaddr + ip, err := pubip.Get() + if err != nil { + log.Fatalf("getting public ip: %s", err.Error()) + } + + externalAddr, err = ma.NewMultiaddr(fmt.Sprintf("/ip4/%s/tcp/%d", ip, port)) + if err != nil { + log.Fatalf("creating external address: %s", err.Error()) + } + + priv, _, err := crypto.GenerateKeyPair(crypto.Ed25519, -1) + if err != nil { + log.Fatalf("generating keypair: %s", err.Error()) + } + + opts := []libp2p.Option{ + libp2p.ListenAddrs(addr), + libp2p.DisableRelay(), + libp2p.Identity(priv), + libp2p.NATPortMap(), + libp2p.AddrsFactory(func(as []ma.Multiaddr) []ma.Multiaddr { + return append(as, externalAddr) + }), + } + + // create libp2p host instance + p2pHost, err := libp2p.New(opts...) + if err != nil { + log.Fatalf("instantiating libp2p host: %s", err.Error()) + } + + return p2pHost +} + +func ParseChainSpec(arg string) *ChainSpec { + chainSpecFile, err := os.Open(filepath.Clean(arg)) + if err != nil { + log.Fatalf("openning %s file: %s", arg, err.Error()) + } + + defer func() { + _ = chainSpecFile.Close() + }() + + rawChainSpec, err := io.ReadAll(chainSpecFile) + if err != nil { + log.Fatalf("reading %s file: %s", arg, err.Error()) + } + + cs := &ChainSpec{} + err = json.Unmarshal(rawChainSpec, cs) + if err != nil { + log.Fatalf("unmarshaling json: %s", err.Error()) + } + + return cs +} + +func ParseBootnodes(bootnodes []string) []peer.AddrInfo { + addrs := make([]peer.AddrInfo, 0, len(bootnodes)) + for _, bn := range bootnodes { + addrs = append(addrs, parsePeerAddress(bn)) + } + + return addrs +} + +func parsePeerAddress(arg string) peer.AddrInfo { + maddr, err := ma.NewMultiaddr(arg) + if err != nil { + log.Fatalf("parsing peer multiaddress: %s", err.Error()) + } + p, err := peer.AddrInfoFromP2pAddr(maddr) + if err != nil { + log.Fatalf("getting address info: %s", err.Error()) + } + return *p +} + +func ReadStream(stream lip2pnetwork.Stream) []byte { + responseBuf := make([]byte, network.MaxBlockResponseSize) + + length, _, err := network.ReadLEB128ToUint64(stream) + if err != nil { + log.Fatalf("reading response length: %s", err.Error()) + } + + if length == 0 { + return nil + } + + if length > network.MaxBlockResponseSize { + log.Fatalf("%s: max %d, got %d", network.ErrGreaterThanMaxSize, network.MaxBlockResponseSize, length) + } + + if length > uint64(len(responseBuf)) { + extraBytes := int(length) - len(responseBuf) + responseBuf = append(responseBuf, make([]byte, extraBytes)...) + } + + var tot int + for tot < int(length) { + n, err := stream.Read(responseBuf[tot:]) + if err != nil { + log.Fatalf("reading stream: %s", err.Error()) + } + tot += n + } + + if tot != int(length) { + log.Fatalf("%s: expected %d bytes, received %d bytes", network.ErrFailedToReadEntireMessage, length, tot) + } + + return responseBuf[:tot] +} + +func WriteStream(msg *messages.BlockRequestMessage, stream lip2pnetwork.Stream) { + encMsg, err := msg.Encode() + if err != nil { + log.Fatalf("encoding message: %s", err.Error()) + } + + msgLen := uint64(len(encMsg)) + lenBytes := network.Uint64ToLEB128(msgLen) + encMsg = append(lenBytes, encMsg...) + + _, err = stream.Write(encMsg) + if err != nil { + log.Fatalf("writing message: %s", err.Error()) + } +} diff --git a/scripts/retrieve_block/README.md b/scripts/retrieve_block/README.md index d77de09c42..5e1cd57162 100644 --- a/scripts/retrieve_block/README.md +++ b/scripts/retrieve_block/README.md @@ -37,7 +37,7 @@ if err != nil { panic(err) } -blockResponse := &network.BlockResponseMessage{} +blockResponse := &messages.BlockResponseMessage{} err := blockResponse.Decode(rawBlockResponse) if err != nil { panic(err) diff --git a/scripts/retrieve_block/retrieve_block.go b/scripts/retrieve_block/retrieve_block.go index 316135235d..6fab6cd17c 100644 --- a/scripts/retrieve_block/retrieve_block.go +++ b/scripts/retrieve_block/retrieve_block.go @@ -5,86 +5,27 @@ package main import ( "context" - "encoding/json" "fmt" - "io" "log" "os" - "path/filepath" "strconv" "strings" - "github.com/ChainSafe/gossamer/dot/network" - "github.com/ChainSafe/gossamer/internal/pubip" + "github.com/ChainSafe/gossamer/dot/network/messages" "github.com/ChainSafe/gossamer/lib/common" "github.com/ChainSafe/gossamer/lib/common/variadic" - "github.com/libp2p/go-libp2p" - "github.com/libp2p/go-libp2p/core/crypto" - "github.com/libp2p/go-libp2p/core/host" + "github.com/ChainSafe/gossamer/scripts/p2p" lip2pnetwork "github.com/libp2p/go-libp2p/core/network" - "github.com/libp2p/go-libp2p/core/peer" "github.com/libp2p/go-libp2p/core/protocol" - - ma "github.com/multiformats/go-multiaddr" ) -type chainSpec struct { - Bootnodes []string `json:"bootnodes"` - ProtocolID string `json:"protocolId"` -} - -func setupP2PClient() host.Host { - const port = 30333 - - // create multiaddress (without p2p identity) - listenAddress := fmt.Sprintf("/ip4/0.0.0.0/tcp/%d", port) - addr, err := ma.NewMultiaddr(listenAddress) - if err != nil { - log.Fatalf("creating multiaddress: %s", err.Error()) - } - - var externalAddr ma.Multiaddr - ip, err := pubip.Get() - if err != nil { - log.Fatalf("getting public ip: %s", err.Error()) - } - - externalAddr, err = ma.NewMultiaddr(fmt.Sprintf("/ip4/%s/tcp/%d", ip, port)) - if err != nil { - log.Fatalf("creating external address: %s", err.Error()) - } - - priv, _, err := crypto.GenerateKeyPair(crypto.Ed25519, -1) - if err != nil { - log.Fatalf("generating keypair: %s", err.Error()) - } - - opts := []libp2p.Option{ - libp2p.ListenAddrs(addr), - libp2p.DisableRelay(), - libp2p.Identity(priv), - libp2p.NATPortMap(), - libp2p.AddrsFactory(func(as []ma.Multiaddr) []ma.Multiaddr { - return append(as, externalAddr) - }), - } - - // create libp2p host instance - p2pHost, err := libp2p.New(opts...) - if err != nil { - log.Fatalf("instantiating libp2p host: %s", err.Error()) - } - - return p2pHost -} - -func buildRequestMessage(arg string) *network.BlockRequestMessage { +func buildRequestMessage(arg string) *messages.BlockRequestMessage { params := strings.Split(arg, ",") targetBlock := parseTargetBlock(params[0]) if len(params) == 1 { - return network.NewBlockRequest(targetBlock, 1, - network.BootstrapRequestData, network.Ascending) + return messages.NewBlockRequest(targetBlock, 1, + messages.BootstrapRequestData, messages.Ascending) } amount, err := strconv.Atoi(params[2]) @@ -94,11 +35,11 @@ func buildRequestMessage(arg string) *network.BlockRequestMessage { switch strings.ToLower(params[1]) { case "asc": - return network.NewBlockRequest(targetBlock, uint32(amount), - network.BootstrapRequestData, network.Ascending) + return messages.NewBlockRequest(targetBlock, uint32(amount), + messages.BootstrapRequestData, messages.Ascending) case "desc": - return network.NewBlockRequest(targetBlock, uint32(amount), - network.BootstrapRequestData, network.Descending) + return messages.NewBlockRequest(targetBlock, uint32(amount), + messages.BootstrapRequestData, messages.Descending) } log.Fatalf("not supported direction: %s, use 'asc' for ascending or 'desc' for descending", params[1]) @@ -120,111 +61,13 @@ func parseTargetBlock(arg string) variadic.Uint32OrHash { return *v } -func parseChainSpec(arg string) *chainSpec { - chainSpecFile, err := os.Open(filepath.Clean(arg)) - if err != nil { - log.Fatalf("openning %s file: %s", arg, err.Error()) - } - - defer func() { - _ = chainSpecFile.Close() - }() - - rawChainSpec, err := io.ReadAll(chainSpecFile) - if err != nil { - log.Fatalf("reading %s file: %s", arg, err.Error()) - } - - cs := &chainSpec{} - err = json.Unmarshal(rawChainSpec, cs) - if err != nil { - log.Fatalf("unmarshaling json: %s", err.Error()) - } - - return cs -} - -func parseBootnodes(bootnodes []string) []peer.AddrInfo { - addrs := make([]peer.AddrInfo, 0, len(bootnodes)) - for _, bn := range bootnodes { - addrs = append(addrs, parsePeerAddress(bn)) - } - - return addrs -} - -func parsePeerAddress(arg string) peer.AddrInfo { - maddr, err := ma.NewMultiaddr(arg) - if err != nil { - log.Fatalf("parsing peer multiaddress: %s", err.Error()) - } - p, err := peer.AddrInfoFromP2pAddr(maddr) - if err != nil { - log.Fatalf("getting address info: %s", err.Error()) - } - return *p -} - -func writeMessageOnStream(msg *network.BlockRequestMessage, stream lip2pnetwork.Stream) { - encMsg, err := msg.Encode() - if err != nil { - log.Fatalf("encoding message: %s", err.Error()) - } - - msgLen := uint64(len(encMsg)) - lenBytes := network.Uint64ToLEB128(msgLen) - encMsg = append(lenBytes, encMsg...) - - _, err = stream.Write(encMsg) - if err != nil { - log.Fatalf("writing message: %s", err.Error()) - } -} - -func readStream(stream lip2pnetwork.Stream) []byte { - responseBuf := make([]byte, network.MaxBlockResponseSize) - - length, _, err := network.ReadLEB128ToUint64(stream) - if err != nil { - log.Fatalf("reading response length: %s", err.Error()) - } - - if length == 0 { - return nil - } - - if length > network.MaxBlockResponseSize { - log.Fatalf("%s: max %d, got %d", network.ErrGreaterThanMaxSize, network.MaxBlockResponseSize, length) - } - - if length > uint64(len(responseBuf)) { - extraBytes := int(length) - len(responseBuf) - responseBuf = append(responseBuf, make([]byte, extraBytes)...) - } - - var tot int - for tot < int(length) { - n, err := stream.Read(responseBuf[tot:]) - if err != nil { - log.Fatalf("reading stream: %s", err.Error()) - } - tot += n - } - - if tot != int(length) { - log.Fatalf("%s: expected %d bytes, received %d bytes", network.ErrFailedToReadEntireMessage, length, tot) - } - - return responseBuf[:tot] -} - func waitAndStoreResponse(stream lip2pnetwork.Stream, outputFile string) bool { - output := readStream(stream) + output := p2p.ReadStream(stream) if len(output) == 0 { return false } - blockResponse := &network.BlockResponseMessage{} + blockResponse := &messages.BlockResponseMessage{} err := blockResponse.Decode(output) if err != nil { log.Fatalf("could not decode block response message: %s", err.Error()) @@ -259,16 +102,16 @@ func main() { go run retrieve_block.go [number or hash],[direction],[number of blocks] [network chain spec] [output file]`) } + p2pHost := p2p.SetupP2PClient() + chain := p2p.ParseChainSpec(os.Args[2]) + bootnodes := p2p.ParseBootnodes(chain.Bootnodes) + requestMessage := buildRequestMessage(os.Args[1]) - p2pHost := setupP2PClient() ctx, cancel := context.WithCancel(context.Background()) defer cancel() - chain := parseChainSpec(os.Args[2]) - bootnodes := parseBootnodes(chain.Bootnodes) protocolID := protocol.ID(fmt.Sprintf("/%s/sync/2", chain.ProtocolID)) - for _, bootnodesAddr := range bootnodes { log.Println("connecting...") err := p2pHost.Connect(ctx, bootnodesAddr) @@ -284,7 +127,7 @@ func main() { } defer stream.Close() //nolint:errcheck - writeMessageOnStream(requestMessage, stream) + p2p.WriteStream(requestMessage, stream) if !waitAndStoreResponse(stream, os.Args[3]) { continue } diff --git a/scripts/retrieve_block/retrieve_block_test.go b/scripts/retrieve_block/retrieve_block_test.go index 7ec4dc109a..2324fee644 100644 --- a/scripts/retrieve_block/retrieve_block_test.go +++ b/scripts/retrieve_block/retrieve_block_test.go @@ -6,7 +6,7 @@ package main import ( "testing" - "github.com/ChainSafe/gossamer/dot/network" + "github.com/ChainSafe/gossamer/dot/network/messages" "github.com/ChainSafe/gossamer/lib/common" "github.com/ChainSafe/gossamer/lib/common/variadic" "github.com/stretchr/testify/require" @@ -15,41 +15,41 @@ import ( func TestBuildRequestMessage(t *testing.T) { testcases := []struct { arg string - expected *network.BlockRequestMessage + expected *messages.BlockRequestMessage }{ { arg: "10", - expected: network.NewBlockRequest( + expected: messages.NewBlockRequest( *variadic.Uint32OrHashFrom(uint(10)), 1, - network.BootstrapRequestData, network.Ascending), + messages.BootstrapRequestData, messages.Ascending), }, { arg: "0x9b0211aadcef4bb65e69346cfd256ddd2abcb674271326b08f0975dac7c17bc7", - expected: network.NewBlockRequest(*variadic.Uint32OrHashFrom( + expected: messages.NewBlockRequest(*variadic.Uint32OrHashFrom( common.MustHexToHash("0x9b0211aadcef4bb65e69346cfd256ddd2abcb674271326b08f0975dac7c17bc7")), - 1, network.BootstrapRequestData, network.Ascending), + 1, messages.BootstrapRequestData, messages.Ascending), }, { arg: "0x9b0211aadcef4bb65e69346cfd256ddd2abcb674271326b08f0975dac7c17bc7,asc,20", - expected: network.NewBlockRequest(*variadic.Uint32OrHashFrom( + expected: messages.NewBlockRequest(*variadic.Uint32OrHashFrom( common.MustHexToHash("0x9b0211aadcef4bb65e69346cfd256ddd2abcb674271326b08f0975dac7c17bc7")), - 20, network.BootstrapRequestData, network.Ascending), + 20, messages.BootstrapRequestData, messages.Ascending), }, { arg: "1,asc,20", - expected: network.NewBlockRequest(*variadic.Uint32OrHashFrom(uint(1)), - 20, network.BootstrapRequestData, network.Ascending), + expected: messages.NewBlockRequest(*variadic.Uint32OrHashFrom(uint(1)), + 20, messages.BootstrapRequestData, messages.Ascending), }, { arg: "0x9b0211aadcef4bb65e69346cfd256ddd2abcb674271326b08f0975dac7c17bc7,desc,20", - expected: network.NewBlockRequest(*variadic.Uint32OrHashFrom( + expected: messages.NewBlockRequest(*variadic.Uint32OrHashFrom( common.MustHexToHash("0x9b0211aadcef4bb65e69346cfd256ddd2abcb674271326b08f0975dac7c17bc7")), - 20, network.BootstrapRequestData, network.Descending), + 20, messages.BootstrapRequestData, messages.Descending), }, { arg: "1,desc,20", - expected: network.NewBlockRequest(*variadic.Uint32OrHashFrom(uint(1)), - 20, network.BootstrapRequestData, network.Descending), + expected: messages.NewBlockRequest(*variadic.Uint32OrHashFrom(uint(1)), + 20, messages.BootstrapRequestData, messages.Descending), }, }