Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

fix(MaxUid): Bump Zero past the max UID allocated by Boot loader #66

Merged
merged 6 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
# Outserv: Blockchain Search
# Outserv: Blockchain Search with GraphQL APIs

Outserv enables you to run production grade GraphQL Search APIs over any
blockchain data 10x faster than existing mechanisms.

Outserv is the only system which combines the power of a saerch engine, a cache
Outserv is the only system which combines the power of a search engine, a cache
engine and a GraphQL layer, thus replacing three different systems in
production.

Outserv makes it trivial for anyone to bring up a production grade
GraphQL tech stack -- which we consider to be an important step to web3
decentralization.
With a single executable binary, Outserv makes it trivial for anyone to bring up
a production grade GraphQL tech stack -- which I consider to be an important
step towards web3 decentralization.

![Outserv Comparison Image](/static/outserv.jpeg)

## Documentation: Installation and Usage
## Important Links

Please follow the documentation in
[https://docs.outcaste.io](https://docs.outcaste.io/docs/intro).
- Latest release is in `release/v22.07` branch.
- Read the announcement [blog post
here](https://manishrjain.com/outserv-graphql-blockchain-search).
- Follow the documentation at [https://docs.outcaste.io](https://docs.outcaste.io/docs/intro).
- See the [product roadmap here](https://github.com/outcaste-io/outserv/issues/61).
- Join the Outserv [Discord community](https://discord.gg/rmJnNd4XaV).
- Consult with me to figure if Outserv would be a good solution
for you via this [Calendly
link](https://calendly.com/manishrjain/consulting-on-outserv).

## Bugs / Feature Requests

Expand All @@ -25,7 +32,7 @@ following questions:

1. What is the problem you are trying to solve for?
2. What did you do?
3. What did you expect?
3. What did you expect to see?
4. What did you see instead?

## License
Expand Down
18 changes: 18 additions & 0 deletions outserv/cmd/alpha/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"context"
"embed"
"fmt"
"io/ioutil"
"log"
"math"
"net"
Expand All @@ -17,6 +18,7 @@ import (
"os"
"os/exec"
"os/signal"
"path"
"path/filepath"
"strconv"
"strings"
Expand Down Expand Up @@ -932,6 +934,22 @@ func run() {
// StartRaftNodes loads up DQL schema from disk. This is important step
// that's needed before GraphQL schema can be loaded in setupServer.
worker.StartRaftNodes(worker.State.WALstore, bindall)

// writeUIDFile in boot loader.
data, err := ioutil.ReadFile(path.Join(x.WorkerConfig.Dir.Posting, "max_uid"))
if err == nil {
str := strings.TrimSpace(string(data))
maxUid, err := strconv.ParseUint(str, 0, 64)
if err == nil {
glog.Infof("Found Max UID in p directory: %#x\n", maxUid)
x.Check(zero.BumpMaxUid(context.Background(), maxUid))
} else {
glog.Infof("Unable to parse max_uid. Got error: %v", err)
}
} else {
glog.Infof("No max_uid file found. Got error: %v\n", err)
}

atomic.AddUint32(&initDone, 1)

// initialization of the admin account can only be done after raft nodes are running
Expand Down
24 changes: 24 additions & 0 deletions zero/zero.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"crypto/tls"
"fmt"
"math"
"os"
"time"

Expand Down Expand Up @@ -298,6 +299,29 @@ func AssignUids(ctx context.Context, num uint32) (*pb.AssignedIds, error) {
return &pb.AssignedIds{StartId: end - uint64(num), EndId: end - 1}, nil
}

func BumpMaxUid(ctx context.Context, maxUid uint64) error {
for {
ms, err := LatestMembershipState(ctx)
if err != nil {
return errors.Wrapf(err, "while retrieving latest membership state")
}
if ms.MaxUID > maxUid {
glog.Infof("ms.MaxUID: %#x > maxUid: %#x. Returning from BumpMaxUid",
ms.MaxUID, maxUid)
return nil
}
ask := uint32(maxUid + 1 - ms.MaxUID)
if maxUid-ms.MaxUID >= math.MaxUint32 {
ask = uint32(math.MaxUint32)
}
glog.Infof("ms.MaxUID: %#x maxUid: %#x Assigning %#x UIDs\n",
ms.MaxUID, maxUid, ask)
if _, err := AssignUids(ctx, ask); err != nil {
return errors.Wrapf(err, "while assigning UIDS")
}
}
}

func AssignNsids(ctx context.Context, num uint32) (*pb.AssignedIds, error) {
prop := &pb.ZeroProposal{NumNsids: num}
st, err := ProposeAndWait(ctx, prop)
Expand Down