Skip to content

Commit

Permalink
Merge with main
Browse files Browse the repository at this point in the history
  • Loading branch information
Olshansk committed Aug 1, 2023
2 parents 9d840ed + 09d3c82 commit 9118167
Show file tree
Hide file tree
Showing 26 changed files with 853 additions and 181 deletions.
4 changes: 2 additions & 2 deletions app/client/cli/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ func newDebugSubCommands() []*cobra.Command {
// newDebugUICommand returns the cobra CLI for the Debug UI interface.
func newDebugUICommand() *cobra.Command {
return &cobra.Command{
Aliases: []string{"dui", "debug"},
Use: "DebugUI",
Aliases: []string{"dui"},
Short: "Debug utility with an interactive UI for development purposes",
Long: "Opens a shell-driven selection UI to view and select from a list of debug actions for development purposes",
Args: cobra.MaximumNArgs(0),
Expand Down Expand Up @@ -239,7 +239,7 @@ func handleSelect(cmd *cobra.Command, selection string) {
}
broadcastDebugMessage(cmd, m)
default:
logger.Global.Error().Msg("Selection not yet implemented...")
logger.Global.Error().Str("selection", selection).Msg("Selection not yet implemented...")
}
}

Expand Down
88 changes: 88 additions & 0 deletions docs/devlog/devlog12.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Pocket V1 DevLog #12 <!-- omit in toc -->

**Date Published**: July 31st, 2023

We have kept the goals and details in this document short, but feel free to reach out to @Olshansk in the [core-dev-chat](https://discord.com/channels/553741558869131266/986789914379186226) for additional details, links & resources.

## Table of Contents <!-- omit in toc -->

- [Iteration 21 Goals \& Results](#iteration-21-goals--results)
- [V0](#v0)
- [V1](#v1)
- [Utility - E2E Trustless Relay Demo](#utility---e2e-trustless-relay-demo)
- [Infrastructure - DevNet Dashboard](#infrastructure---devnet-dashboard)
- [Product - TestNet MVP](#product---testnet-mvp)
- [Screenshots](#screenshots)
- [Iteration 21 - Completed](#iteration-21---completed)
- [V1 Results](#v1-results)
- [Iteration 21 - Planned](#iteration-21---planned)
- [Contribute to V1 🧑‍💻](#contribute-to-v1-)
- [Links \& References](#links--references)

## Iteration 21 Goals & Results

**Iterate Dates**: July 15th - July 28th, 2023

```bash
# V1 Repo
git diff b55b6f96ca99a1e28ac133689949afa5f7e74c42 --stat
# 98 files changed, 3366 insertions(+), 655 deletions(-)
```

### V0

We have prepared the [release plan](https://www.notion.so/pocketnetwork/RC-0-10-4-Release-Plan-848c0c329e554a78a2aaf05bcaafb763?pvs=4) for `RC 0.10.4` with the helpful of everyone in the community!

### V1

Our goal, for the second iteration in a row, was **to finalize demos** as much as possible from the [previous iteration](https://github.com/pokt-network/pocket/blob/main/docs/devlog/devlog11.md).

🟡🟢 Like last week, we made progress on two more demos and give ourselves an overall score of `7/10` as we are tying together lots of lose ends.

#### Utility - E2E Trustless Relay Demo

@adshmh presented the first demo of an E2E Trustless Relay Demo

[Audio](https://drive.google.com/file/d/1bkrIPsDAuZYevJRgyiudml5YWUSUtTto/view?usp=drive_link)

[![asciicast](https://asciinema.org/a/599295.svg)](https://asciinema.org/a/599295)

#### Infrastructure - DevNet Dashboard

[Audio](https://drive.google.com/file/d/1rN2tXJ5qYXxmpnrU1Eo1dj_DRJjYJlDY/view?usp=drive_link]

Though it may be offline at the time of writing, you can access the DevNet Dashboard [here](https://devnet-first-dashboard.dev-us-east4-1.poktnodes.network:8443/)

![DevNet Dashboard](https://github.com/pokt-network/pocket/assets/1892194/98a57a86-26a6-4d08-a719-9f40dadcd658)

#### Product - TestNet MVP

@mokn himself presented his vision

[![TestNet MVP](https://github.com/pokt-network/pocket/assets/1892194/97eee0a7-2755-4b56-979b-783ac9c5b0a9)](https://drive.google.com/file/d/1ojkUv6Ds_GTGAdxtMdYujFpOnDgoXYII/view)

## Screenshots

Please note that everything that was not `Done` in `iteration21` is moving over to `iteration22`.

### Iteration 21 - Completed

#### V1 Results

![V1 Completed - 1](https://github.com/pokt-network/pocket/assets/1892194/776d5b75-0de6-43d3-800f-c7dddb04dbf3)
![V1 Completed - 2](https://github.com/pokt-network/pocket/assets/1892194/9940893f-b1b5-432a-ae9c-d949e540e739)

### Iteration 21 - Planned

![V1 Planned](https://github.com/pokt-network/pocket/assets/1892194/a1ac5624-b4a4-4d94-8812-615d8fe8d0e2)

## Contribute to V1 🧑‍💻

### Links & References

- [V1 Specifications](https://github.com/pokt-network/pocket-network-protocol)
- [V1 Repo](https://github.com/pokt-network/pocket)
- [V1 Wiki](https://github.com/pokt-network/pocket/wiki)
- [V1 Project Dashboard](https://github.com/pokt-network/pocket/projects?query=is%3Aopen)

<!-- GITHUB_WIKI: devlog/2023_07_31 -->
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ require (
github.com/rs/zerolog v1.27.0
github.com/spf13/cobra v1.6.0
github.com/spf13/viper v1.13.0
go.uber.org/multierr v1.9.0
golang.org/x/term v0.5.0
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.26.1
Expand Down Expand Up @@ -197,6 +196,7 @@ require (
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/dig v1.15.0 // indirect
go.uber.org/fx v1.18.2 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/oauth2 v0.4.0 // indirect
golang.org/x/sync v0.1.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions p2p/background/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ package background

import (
"context"
"errors"
"fmt"
"time"

dht "github.com/libp2p/go-libp2p-kad-dht"
pubsub "github.com/libp2p/go-libp2p-pubsub"
libp2pHost "github.com/libp2p/go-libp2p/core/host"
libp2pPeer "github.com/libp2p/go-libp2p/core/peer"
"go.uber.org/multierr"
"google.golang.org/protobuf/proto"

"github.com/pokt-network/pocket/logger"
Expand Down Expand Up @@ -129,7 +129,7 @@ func (rtr *backgroundRouter) Close() error {
topicCloseErr = err
}

return multierr.Append(
return errors.Join(
topicCloseErr,
rtr.kadDHT.Close(),
)
Expand Down
18 changes: 9 additions & 9 deletions p2p/config/config.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package config

import (
"errors"
"fmt"

"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/protocol"
"go.uber.org/multierr"

typesP2P "github.com/pokt-network/pocket/p2p/types"
"github.com/pokt-network/pocket/shared/crypto"
Expand Down Expand Up @@ -56,39 +56,39 @@ type RainTreeConfig struct {
// IsValid implements the respective member of the `RouterConfig` interface.
func (cfg *baseConfig) IsValid() (err error) {
if cfg.Addr == nil {
err = multierr.Append(err, fmt.Errorf("pokt address not configured"))
err = errors.Join(err, fmt.Errorf("pokt address not configured"))
}

if cfg.Host == nil {
err = multierr.Append(err, fmt.Errorf("host not configured"))
err = errors.Join(err, fmt.Errorf("host not configured"))
}

if cfg.Handler == nil {
err = multierr.Append(err, fmt.Errorf("handler not configured"))
err = errors.Join(err, fmt.Errorf("handler not configured"))
}
return err
}

// IsValid implements the respective member of the `RouterConfig` interface.
func (cfg *UnicastRouterConfig) IsValid() (err error) {
if cfg.Logger == nil {
err = multierr.Append(err, fmt.Errorf("logger not configured"))
err = errors.Join(err, fmt.Errorf("logger not configured"))
}

if cfg.Host == nil {
err = multierr.Append(err, fmt.Errorf("host not configured"))
err = errors.Join(err, fmt.Errorf("host not configured"))
}

if cfg.ProtocolID == "" {
err = multierr.Append(err, fmt.Errorf("protocol id not configured"))
err = errors.Join(err, fmt.Errorf("protocol id not configured"))
}

if cfg.MessageHandler == nil {
err = multierr.Append(err, fmt.Errorf("message handler not configured"))
err = errors.Join(err, fmt.Errorf("message handler not configured"))
}

if cfg.PeerHandler == nil {
err = multierr.Append(err, fmt.Errorf("peer handler not configured"))
err = errors.Join(err, fmt.Errorf("peer handler not configured"))
}
return err
}
Expand Down
7 changes: 3 additions & 4 deletions p2p/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/libp2p/go-libp2p"
libp2pHost "github.com/libp2p/go-libp2p/core/host"
"github.com/multiformats/go-multiaddr"
"go.uber.org/multierr"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"

Expand Down Expand Up @@ -182,12 +181,12 @@ func (m *p2pModule) Stop() error {
stakedActorRouterCloseErr = m.stakedActorRouter.Close()
}

routerCloseErrs := multierr.Append(
routerCloseErrs := errors.Join(
m.unstakedActorRouter.Close(),
stakedActorRouterCloseErr,
)

err := multierr.Append(
err := errors.Join(
routerCloseErrs,
m.host.Close(),
)
Expand Down Expand Up @@ -231,7 +230,7 @@ func (m *p2pModule) Broadcast(msg *anypb.Any) error {

unstakedBroadcastErr := m.unstakedActorRouter.Broadcast(poktEnvelopeBz)

return multierr.Append(stakedBroadcastErr, unstakedBroadcastErr)
return errors.Join(stakedBroadcastErr, unstakedBroadcastErr)
}

func (m *p2pModule) Send(addr cryptoPocket.Address, msg *anypb.Any) error {
Expand Down
7 changes: 4 additions & 3 deletions p2p/providers/peerstore_provider/peerstore_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package peerstore_provider
//go:generate mockgen -package=mock_types -destination=../../types/mocks/peerstore_provider_mock.go github.com/pokt-network/pocket/p2p/providers/peerstore_provider PeerstoreProvider

import (
"errors"

"github.com/pokt-network/pocket/logger"
typesP2P "github.com/pokt-network/pocket/p2p/types"
coreTypes "github.com/pokt-network/pocket/shared/core/types"
cryptoPocket "github.com/pokt-network/pocket/shared/crypto"
"github.com/pokt-network/pocket/shared/modules"
"go.uber.org/multierr"
)

const PeerstoreProviderSubmoduleName = "peerstore_provider"
Expand All @@ -35,12 +36,12 @@ func ActorsToPeerstore(abp PeerstoreProvider, actors []*coreTypes.Actor) (pstore
logger.Global.Warn().Err(err).Msg("ignoring ErrResolvingAddr - peer unreachable, not adding it to peerstore")
continue
} else if err != nil {
errs = multierr.Append(errs, err)
errs = errors.Join(errs, err)
continue
}

if err = pstore.AddPeer(networkPeer); err != nil {
errs = multierr.Append(errs, err)
errs = errors.Join(errs, err)
}
}
return pstore, errs
Expand Down
6 changes: 3 additions & 3 deletions p2p/utils/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package utils

import (
"context"
"errors"
"fmt"
"time"

libp2pHost "github.com/libp2p/go-libp2p/core/host"
libp2pProtocol "github.com/libp2p/go-libp2p/core/protocol"
"go.uber.org/multierr"

"github.com/pokt-network/pocket/logger"
typesP2P "github.com/pokt-network/pocket/p2p/types"
Expand All @@ -26,7 +26,7 @@ const (
func PopulateLibp2pHost(host libp2pHost.Host, pstore typesP2P.Peerstore) (err error) {
for _, peer := range pstore.GetPeerList() {
if addErr := AddPeerToLibp2pHost(host, peer); addErr != nil {
err = multierr.Append(err, addErr)
err = errors.Join(err, addErr)
}
}
return err
Expand Down Expand Up @@ -101,7 +101,7 @@ func Libp2pSendToPeer(host libp2pHost.Host, protocolID libp2pProtocol.ID, data [
}

if n, err := stream.Write(data); err != nil {
return multierr.Append(
return errors.Join(
fmt.Errorf("writing to stream: %w", err),
stream.Reset(),
)
Expand Down
22 changes: 14 additions & 8 deletions persistence/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,35 @@ type PostgresContext struct {
networkId string
}

func (p *PostgresContext) NewSavePoint(bytes []byte) error {
p.logger.Info().Bool("TODO", true).Msg("NewSavePoint not implemented")
// SetSavePoint generates a new Savepoint for this context.
func (p *PostgresContext) SetSavePoint() error {
if err := p.stateTrees.Savepoint(); err != nil {
return err
}
return nil
}

// TECHDEBT(#327): Guarantee atomicity betweens `prepareBlock`, `insertBlock` and `storeBlock` for save points & rollbacks.
func (p *PostgresContext) RollbackToSavePoint(bytes []byte) error {
p.logger.Info().Bool("TODO", true).Msg("RollbackToSavePoint not fully implemented")
return p.tx.Rollback(context.TODO())
// RollbackToSavepoint triggers a rollback for the current pgx transaction and the underylying submodule stores.
func (p *PostgresContext) RollbackToSavePoint() error {
ctx, _ := p.getCtxAndTx()
pgErr := p.tx.Rollback(ctx)
treesErr := p.stateTrees.Rollback()
return errors.Join(pgErr, treesErr)
}

// IMPROVE(#361): Guarantee the integrity of the state
// Full details in the thread from the PR review: https://github.com/pokt-network/pocket/pull/285#discussion_r1018471719
func (p *PostgresContext) ComputeStateHash() (string, error) {
stateHash, err := p.stateTrees.Update(p.tx, uint64(p.Height))
if err != nil {
return "", err
}
if err := p.stateTrees.Commit(); err != nil {
return "", err
}
p.stateHash = stateHash
return p.stateHash, nil
}

// TECHDEBT(#327): Make sure these operations are atomic
func (p *PostgresContext) Commit(proposerAddr, quorumCert []byte) error {
p.logger.Info().Int64("height", p.Height).Msg("About to commit block & context")

Expand Down
1 change: 1 addition & 0 deletions persistence/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var protocolActorSchemas = []types.ProtocolActorSchema{
types.ValidatorActor,
}

// TECHDEBT(#595): Properly handle context threading and passing for the entire persistence module
func (pg *PostgresContext) getCtxAndTx() (context.Context, pgx.Tx) {
return context.TODO(), pg.tx
}
Expand Down
4 changes: 4 additions & 0 deletions persistence/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.0.0.60] - 2023-07-11

- Adds savepoints and rollbacks implementation to TreeStore

## [0.0.0.60] - 2023-06-26

- Add place-holder for local context and servicer token usage support methods
Expand Down
Loading

0 comments on commit 9118167

Please sign in to comment.