-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>
- Loading branch information
1 parent
618375d
commit a28960b
Showing
5 changed files
with
738 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package dsmr | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"google.golang.org/protobuf/proto" | ||
|
||
"github.com/ava-labs/avalanchego/ids" | ||
"github.com/ava-labs/avalanchego/network/p2p" | ||
"github.com/ava-labs/avalanchego/snow/engine/common" | ||
"github.com/ava-labs/hypersdk/proto/pb/dsmr" | ||
) | ||
|
||
var ( | ||
_ p2p.Handler = (*GetChunkHandler)(nil) | ||
_ p2p.Handler = (*GetChunkSignatureHandler)(nil) | ||
) | ||
|
||
type GetChunkHandler struct{} | ||
|
||
func (g GetChunkHandler) AppGossip(ctx context.Context, nodeID ids.NodeID, gossipBytes []byte) { | ||
return | ||
} | ||
|
||
func (g GetChunkHandler) AppRequest(ctx context.Context, nodeID ids.NodeID, deadline time.Time, requestBytes []byte) ([]byte, *common.AppError) { | ||
return nil, nil | ||
} | ||
|
||
// Receives a chunk, persists it, signs it, and replies w/ a signature | ||
// Producer sends chunks to peers for replication + collect signatures | ||
type GetChunkSignatureHandler struct { | ||
} | ||
|
||
func (g GetChunkSignatureHandler) AppGossip(context.Context, ids.NodeID, []byte) { | ||
return | ||
} | ||
|
||
func (g GetChunkSignatureHandler) AppRequest(_ context.Context, _ ids.NodeID, _ time.Time, appRequestBytes []byte) ([]byte, *common.AppError) { | ||
request := &dsmr.Chunk{} | ||
if err := proto.Unmarshal(appRequestBytes, request); err != nil { | ||
panic(err) | ||
} | ||
|
||
//TODO persist + sign | ||
//TODO conflicting? | ||
|
||
response := &dsmr.ChunkSignature{} | ||
responseBytes, err := proto.Marshal(response) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
return responseBytes, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (C) 2024, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
syntax = "proto3"; | ||
|
||
package dsmr; | ||
|
||
option go_package = "github.com/ava-labs/hypersdk/proto/pb/dsmr"; | ||
|
||
message Chunk { | ||
bytes producer = 1; | ||
uint64 expiry = 2; | ||
bytes beneficiary = 3; | ||
repeated Transaction transactions = 4; | ||
bytes signer = 5; | ||
bytes signature = 6; | ||
} | ||
|
||
message ChunkSignature { | ||
bytes chunk_id = 1; | ||
bytes producer = 2; | ||
uint64 expiry = 3; | ||
bytes signer = 4; // bls public key | ||
bytes signature = 5; | ||
} | ||
|
||
|
||
message Transaction { | ||
bytes bytes = 1; | ||
} | ||
|
||
message ChunkCertificate { | ||
bytes chunk_id = 1; | ||
bytes producer = 2; | ||
uint64 expiry = 3; | ||
bytes signers = 4; // bitset | ||
bytes signature = 5; | ||
} | ||
|
||
message ExecutedChunk { | ||
bytes chunk_id = 1; | ||
bytes beneficiary = 2; | ||
repeated Transaction transactions = 3; | ||
bytes warp_results = 4; // bitset | ||
} | ||
|
||
message GetChunkRequest { | ||
bytes chunk_id = 1; | ||
} | ||
|
||
//TODO chunk fault |
Oops, something went wrong.