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

Open
wants to merge 52 commits into
base: node-split-poc
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
271da0f
wip build proposals
acud Oct 17, 2024
738938e
wip
acud Oct 21, 2024
7b19bc9
api and make gen
acud Oct 21, 2024
d80b554
wip
acud Oct 22, 2024
db8920a
makegen
acud Oct 22, 2024
315e498
wip
acud Oct 22, 2024
cedb73b
wip
acud Oct 22, 2024
add533a
wip
acud Oct 22, 2024
d9d5557
wip
acud Oct 22, 2024
fb1da1d
signers
acud Oct 22, 2024
31f2831
wip
acud Oct 22, 2024
23c0379
prints
acud Oct 22, 2024
5d2d7b7
logger
acud Oct 22, 2024
9721022
housekeeping
acud Oct 22, 2024
9fa34d4
setup
acud Oct 24, 2024
c3e8dea
setup
acud Oct 24, 2024
5e42745
config
acud Oct 24, 2024
409baaa
compose-ports
acud Oct 24, 2024
5a03710
chmod
acud Oct 24, 2024
3843e22
print coinbase
acud Oct 24, 2024
4590513
build
acud Oct 24, 2024
49ef08c
smesh
acud Oct 24, 2024
8cda487
unsmesh
acud Oct 24, 2024
a40c685
just rand shuffle
acud Oct 24, 2024
73da8a2
docker
acud Oct 24, 2024
0bbe0eb
one
acud Oct 24, 2024
8d2ec42
cleanups
acud Oct 24, 2024
6c101c1
Merge branch 'node-split-poc' into proposal-building
acud Nov 1, 2024
51f85aa
fix
acud Nov 1, 2024
7766c23
cleanups
acud Nov 1, 2024
cd78aa8
lint
acud Nov 1, 2024
127dc05
add test
acud Nov 4, 2024
700dfb8
improve error handling
acud Nov 4, 2024
443e296
improve remote proposals
acud Nov 4, 2024
20c5991
remove concurrency for BuildFor
acud Nov 5, 2024
0095c5c
add logging
acud Nov 5, 2024
7882b98
compose-setup
acud Nov 5, 2024
7ec8114
start.sh
acud Nov 5, 2024
1f0486d
remove context
acud Nov 5, 2024
b6e8d4c
start
acud Nov 5, 2024
931acbb
cleanup
acud Nov 5, 2024
13cb81f
improve logging hopefully, improve hare error handling when theres no…
acud Nov 5, 2024
ee6f033
wip
acud Nov 5, 2024
bcf20ef
log
acud Nov 5, 2024
cae6886
dont initialize twice
acud Nov 5, 2024
b9a0079
handle no eligiblities
acud Nov 5, 2024
71cd5f4
wip
acud Nov 5, 2024
37b05e9
add a map to check for the elgibilities
acud Nov 5, 2024
4809290
wip
acud Nov 5, 2024
1b4d4e6
wip
acud Nov 6, 2024
51f5fc0
handle nilnil
acud Nov 6, 2024
d6bb858
fix test
acud Nov 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion activation/activation.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,10 @@ 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
7 changes: 4 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,10 @@
"logging": {
"trtl": "WARN",
"beacon": "ERROR",
"proposalBuilder": "ERROR",
"atxBuilder": "DEBUG",
"hare": "DEBUG"
"proposalBuilder": "DEBUG",
"atxBuilder": "ERROR",
"hare": "ERROR",
"nodeServiceClient": "ERROR"
},
"main": {
"node-service-address": "http://0.0.0.0:9099",
Expand Down
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: ${IMAGE}
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
7 changes: 4 additions & 3 deletions activation_service_poc/start.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ cd activation_service_poc
export IMAGE=$(docker images | head -n 2 | tail -n 1 | awk '{print $3}')

TIME=$(date -u -d '2 minutes' "+%Y-%m-%dT%H:%M:%S%:z")
jq ".genesis.\"genesis-time\" |= \"$TIME\"" config.standalone.client.json
jq ".genesis.\"genesis-time\" |= \"$TIME\"" config.standalone.node-service.json
for file in config.standalone.client.json config.standalone.node-service.json;do
jq ".genesis.\"genesis-time\" |= \"$TIME\"" "$file" > temp.json && mv temp.json "$file"
done

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.

67 changes: 57 additions & 10 deletions api/node/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"bytes"
"context"
"encoding/hex"
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -133,22 +134,30 @@
externalRef0.HareIter(round.Iter),
externalRef0.HareRound(round.Round))
if err != nil {
return nil, err
return nil, fmt.Errorf("get hare message: %w", err)

Check warning on line 137 in api/node/client/client.go

View check run for this annotation

Codecov / codecov/patch

api/node/client/client.go#L137

Added line #L137 was not covered by tests
}
if resp.StatusCode != http.StatusOK {
switch resp.StatusCode {
case http.StatusOK:
bytes, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("read all: %w", err)
}

Check warning on line 144 in api/node/client/client.go

View check run for this annotation

Codecov / codecov/patch

api/node/client/client.go#L143-L144

Added lines #L143 - L144 were not covered by tests
return bytes, nil

case http.StatusNoContent:
// no message to return, special case, return nil,nil
// and the caller should assume there's no message to process,
// therefore hare probably terminated.
return nil, nil
default:

Check warning on line 152 in api/node/client/client.go

View check run for this annotation

Codecov / codecov/patch

api/node/client/client.go#L147-L152

Added lines #L147 - L152 were not covered by tests
return nil, fmt.Errorf("unexpected status: %s", resp.Status)
}
bytes, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("read all: %w", err)
}
return bytes, nil
}

func (s *NodeService) TotalWeight(ctx context.Context, layer types.LayerID) (uint64, error) {
resp, err := s.client.GetHareTotalWeightLayer(ctx, uint32(layer))
if err != nil {
return 0, err
return 0, fmt.Errorf("get total weight: %w", err)

Check warning on line 160 in api/node/client/client.go

View check run for this annotation

Codecov / codecov/patch

api/node/client/client.go#L160

Added line #L160 was not covered by tests
}
if resp.StatusCode != http.StatusOK {
return 0, fmt.Errorf("unexpected status: %s", resp.Status)
Expand All @@ -163,7 +172,7 @@
func (s *NodeService) MinerWeight(ctx context.Context, layer types.LayerID, node types.NodeID) (uint64, error) {
resp, err := s.client.GetHareWeightNodeIdLayer(ctx, node.String(), uint32(layer))
if err != nil {
return 0, err
return 0, fmt.Errorf("get miner weight: %w", err)

Check warning on line 175 in api/node/client/client.go

View check run for this annotation

Codecov / codecov/patch

api/node/client/client.go#L175

Added line #L175 was not covered by tests
}
if resp.StatusCode != http.StatusOK {
return 0, fmt.Errorf("unexpected status: %s", resp.Status)
Expand All @@ -179,7 +188,7 @@
v := types.Beacon{}
resp, err := s.client.GetHareBeaconEpoch(ctx, externalRef0.EpochID(epoch))
if err != nil {
return v, err
return v, fmt.Errorf("get hare beacon: %w", err)

Check warning on line 191 in api/node/client/client.go

View check run for this annotation

Codecov / codecov/patch

api/node/client/client.go#L191

Added line #L191 was not covered by tests
}
if resp.StatusCode != http.StatusOK {
return v, fmt.Errorf("unexpected status: %s", resp.Status)
Expand All @@ -191,3 +200,41 @@
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, fmt.Errorf("get proposal layer: %w", err)
}

Check warning on line 210 in api/node/client/client.go

View check run for this annotation

Codecov / codecov/patch

api/node/client/client.go#L209-L210

Added lines #L209 - L210 were not covered by tests
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)

Check warning on line 218 in api/node/client/client.go

View check run for this annotation

Codecov / codecov/patch

api/node/client/client.go#L213-L218

Added lines #L213 - L218 were not covered by tests
}

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

Check warning on line 224 in api/node/client/client.go

View check run for this annotation

Codecov / codecov/patch

api/node/client/client.go#L223-L224

Added lines #L223 - L224 were not covered by tests

prop := types.Proposal{}
err = codec.Decode(bytes, &prop)
if err != nil {
return nil, 0, fmt.Errorf("decode proposal: %w", err)
}

Check warning on line 230 in api/node/client/client.go

View check run for this annotation

Codecov / codecov/patch

api/node/client/client.go#L229-L230

Added lines #L229 - L230 were not covered by tests
atxNonce := resp.Header.Get("X-Spacemesh-Atx-Nonce")
if atxNonce == "" {
return nil, 0, errors.New("missing atx nonce")
}

Check warning on line 234 in api/node/client/client.go

View check run for this annotation

Codecov / codecov/patch

api/node/client/client.go#L233-L234

Added lines #L233 - L234 were not covered by tests
nonce, err := strconv.ParseUint(atxNonce, 10, 64)
if err != nil {
return nil, 0, fmt.Errorf("nonce parse: %w", err)
}

Check warning on line 238 in api/node/client/client.go

View check run for this annotation

Codecov / codecov/patch

api/node/client/client.go#L237-L238

Added lines #L237 - L238 were not covered by tests
return &prop, nonce, nil
}
Loading
Loading