Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node split: proposal building #6400

Draft
wants to merge 27 commits into
base: smeshing-service
Choose a base branch
from
Draft
2 changes: 1 addition & 1 deletion activation/activation.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ func (b *Builder) PublishActivationTx(ctx context.Context, sig *signing.EdSigner
)
size, err := b.broadcast(ctx, atx)
if err == nil {
b.logger.Info("atx published", log.ZShortStringer("atx_id", atx.ID()), zap.Int("size", size))
b.logger.Info("atx published", log.ZShortStringer("atx_id", atx.ID()), zap.Stringer("coinbase", b.Coinbase()), zap.Int("size", size))
break
}

Expand Down
6 changes: 3 additions & 3 deletions activation_service_poc/config.standalone.client.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"logging": {
"trtl": "WARN",
"beacon": "ERROR",
"proposalBuilder": "ERROR",
"atxBuilder": "DEBUG",
"hare": "DEBUG"
"proposalBuilder": "DEBUG",
"atxBuilder": "ERROR",
"hare": "ERROR"
},
"main": {
"node-service-address": "http://0.0.0.0:9099",
Expand Down
32 changes: 32 additions & 0 deletions activation_service_poc/config.standalone.client2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"preset": "standalone",
"api": {
"grpc-public-listener": "0.0.0.0:9082",
"grpc-private-listener": "0.0.0.0:9083"
},
"genesis": {
"genesis-time": "2024-09-25T13:00:00.000Z"
},
"logging": {
"trtl": "WARN",
"beacon": "ERROR",
"proposalBuilder": "DEBUG",
"atxBuilder": "ERROR",
"hare": "ERROR"
},
"main": {
"node-service-address": "http://0.0.0.0:9099",
"data-folder": "/tmp/spacemesh-client2",
"filelock": "/tmp/spacemesh-client2/node.lock",
"poet-servers": [
{
"address": "http://127.0.0.1:10011"
}
]
},
"smeshing": {
"smeshing-opts": {
"smeshing-opts-datadir": "/tmp/spacemesh-client2/post-data"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@
"trtl": "WARN",
"beacon": "ERROR",
"proposalBuilder": "ERROR",
"hare": "DEBUG"
"hare": "ERROR"
},
"hare3": {
"enable": true
},
"main": {
"data-folder": "/tmp/spacemesh-node-service",
"filelock": "/tmp/spacemesh-node-service/node.lock"
},
"smeshing": {
"smeshing-opts": {
"smeshing-opts-datadir": "/tmp/spacemesh-node-service/post-data"
}
}
}
5 changes: 4 additions & 1 deletion activation_service_poc/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ services:

node-service:
image: spacemeshos/go-spacemesh-dev:activation-service-poc.0
command: ["-c", "/config.json", "--smeshing-opts-datadir", "/tmp/spacemesh-node-post"]
command: ["-c", "/config.json"]
volumes:
- /tmp/spacemesh-node-service:/tmp/spacemesh-node-service
- ./config.standalone.node-service.json:/config.json
networks:
- spacemesh-net
ports:
- 9092:9092
- 9093:9093

networks:
spacemesh-net:
Expand Down
4 changes: 2 additions & 2 deletions activation_service_poc/start.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ cd activation_service_poc

IMAGE=$(docker images | head -n 2 | tail -n 1 | awk '{print $3}')
sed -i "s/image.*/image:\ $IMAGE/g" docker-compose.yml
TIME=$(date -u -d '2 minutes' "+%Y-%m-%dT%H:%M:%S%:z")
TIME=$(date -u -d '1 minutes' "+%Y-%m-%dT%H:%M:%S%:z")
sed -i "s/\"genesis-time\".*/\"genesis-time\"\:\"$TIME\"/g" config.standalone.client.json
sed -i "s/\"genesis-time\".*/\"genesis-time\"\:\"$TIME\"/g" config.standalone.node-service.json

rm -rf /tmp/spacemesh*
rm -rf /tmp/space*
docker compose up
105 changes: 105 additions & 0 deletions api/node/client/client.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions api/node/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"encoding/hex"
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -190,3 +191,36 @@ func (s *NodeService) Beacon(ctx context.Context, epoch types.EpochID) (types.Be
copy(v[:], bytes)
return v, nil
}

func (s *NodeService) Proposal(ctx context.Context, layer types.LayerID, node types.NodeID) (*types.Proposal, uint64, error) {
resp, err := s.client.GetProposalLayerNode(ctx, externalRef0.LayerID(layer), node.String())
if err != nil {
return nil, 0, err
}
switch resp.StatusCode {
case http.StatusOK:
case http.StatusNoContent:
// special case - no error but also no proposal, means
// we're no eligibile this epoch with this node ID
return nil, 0, nil
default:
return nil, 0, fmt.Errorf("unexpected status: %s", resp.Status)
}

bytes, err := io.ReadAll(resp.Body)
if err != nil {
return nil, 0, fmt.Errorf("read all: %w", err)
}

prop := types.Proposal{}
codec.MustDecode(bytes, &prop)
atxNonce := resp.Header.Get("x-spacemesh-atx-nonce")
if atxNonce == "" {
return nil, 0, errors.New("atx nonce header not found")
}
nonce, err := strconv.ParseUint(atxNonce, 10, 64)
if err != nil {
return nil, 0, fmt.Errorf("nonce parse: %w", err)
}
return &prop, nonce, nil
}
28 changes: 28 additions & 0 deletions api/node/node_service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,32 @@ paths:
format: binary
"204":
description: did not find a message to retrieve
/proposal/{layer}/{node}:
get:
summary: Get a partial proposal for a given node in a layer
tags:
- "proposals"
parameters:
- in: path
name: layer
required: true
schema:
$ref: "models/components.yaml#/components/schemas/LayerID"
- in: path
name: node
required: true
schema:
$ref: "models/components.yaml#/components/schemas/NodeID"
responses:
"200":
description: successfully created a partial proposal
content:
application/octet-stream:
schema:
type: string
format: binary
"204":
description: no eligibilities for this node in this epoch
"500":
description: could not generate proposal

Loading
Loading