Skip to content

Commit

Permalink
Merge branch 'issues/352/state_sync' into issues/829/state_sync_test
Browse files Browse the repository at this point in the history
  • Loading branch information
Olshansk committed Jul 21, 2023
2 parents 7edc9eb + c9fe524 commit 608826a
Show file tree
Hide file tree
Showing 37 changed files with 793 additions and 105 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ permissions:

env:
# Even though we can test against multiple versions, this one is considered a target version.
TARGET_GOLANG_VERSION: "1.19"
TARGET_GOLANG_VERSION: "1.20"
PROTOC_VERSION: "3.19.4"

jobs:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ on:

env:
# Even though we can test against multiple versions, this one is considered a target version.
TARGET_GOLANG_VERSION: "1.19"
TARGET_GOLANG_VERSION: "1.20"
PROTOC_VERSION: "3.19.4"

jobs:
test-multiple-go-versions:
runs-on: custom-runner
strategy:
matrix:
go: ["1.19"] # As we are relying on generics, we can't go lower than 1.18.
go: ["1.20"] # As we are relying on generics, we can't go lower than 1.18.
fail-fast: false
name: Go ${{ matrix.go }} test
steps:
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ linters-settings:
failOn: dsl
rules: "build/linters/*.go"
run:
go: "1.19"
go: "1.20"
skip-dirs:
- build/linters
build-tags:
Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,32 @@ The official implementation of the [V1 Pocket Network Protocol Specification](ht

\*_Please note that V1 protocol is currently under development and see [pocket-core](https://github.com/pokt-network/pocket-core) for the version that is currently live on mainnet._\*

## Implementation

Official Golang implementation of the Pocket Network v1 Protocol.

<div>
<a href="https://godoc.org/github.com/pokt-network/pocket"><img src="https://img.shields.io/badge/godoc-reference-blue.svg"/></a>
<a href="https://goreportcard.com/report/github.com/pokt-network/pocket"><img src="https://goreportcard.com/badge/github.com/pokt-network/pocket"/></a>
<a href="https://golang.org"><img src="https://img.shields.io/badge/golang-v1.20-green.svg"/></a>
<a href="https://github.com/tools/godep" ><img src="https://img.shields.io/badge/godep-dependency-71a3d9.svg"/></a>
</div>

## Overview

<div>
<a href="https://discord.gg/pokt"><img src="https://img.shields.io/discord/553741558869131266"></a>
<a href="https://github.com/pokt-network/pocket/releases"><img src="https://img.shields.io/github/release-pre/pokt-network/pocket.svg"/></a>
<!-- <a href="https://circleci.com/gh/pokt-network/pocket"><img src="https://circleci.com/gh/pokt-network/pocket.svg?style=svg"/></a> -->
<a href="https://github.com/pokt-network/pocket/pulse"><img src="https://img.shields.io/github/contributors/pokt-network/pocket.svg"/></a>
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-blue.svg"/></a>
<a href="https://github.com/pokt-network/pocket/pulse"><img src="https://img.shields.io/github/last-commit/pokt-network/pocket.svg"/></a>
<a href="https://github.com/pokt-network/pocket/pulls"><img src="https://img.shields.io/github/issues-pr/pokt-network/pocket.svg"/></a>
<a href="https://github.com/pokt-network/pocket/releases"><img src="https://img.shields.io/badge/platform-linux%20%7C%20macos-pink.svg"/></a>
<a href="https://github.com/pokt-network/pocket/issues"><img src="https://img.shields.io/github/issues/pokt-network/pocket.svg"/></a>
<a href="https://github.com/pokt-network/pocket/issues"><img src="https://img.shields.io/github/issues-closed/pokt-network/pocket.svg"/></a>
</div>

## Getting Started

---
Expand Down
2 changes: 1 addition & 1 deletion build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ OS = $(shell uname | tr A-Z a-z)
GOARCH = $(shell go env GOARCH)

## The expected golang version; crashes if the local env is different
GOLANG_VERSION ?= 1.18
GOLANG_VERSION ?= 1.20

## Build variables
BUILD_DIR ?= bin
Expand Down
4 changes: 2 additions & 2 deletions build/Dockerfile.client
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GOLANG_IMAGE_VERSION=golang:1.19-alpine3.16
ARG GOLANG_IMAGE_VERSION=golang:1.20-alpine3.16

FROM ${GOLANG_IMAGE_VERSION} AS builder

Expand All @@ -14,4 +14,4 @@ RUN apk add --no-cache bash
# Hot reloading
RUN go install github.com/cespare/reflex@latest

CMD ["/bin/bash"]
CMD ["/bin/bash"]
2 changes: 1 addition & 1 deletion build/Dockerfile.debian.dev
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Purpose of this container image is to ship pocket binary with additional
# tools such as dlv, curl, etc.

ARG TARGET_GOLANG_VERSION=1.19
ARG TARGET_GOLANG_VERSION=1.20

FROM golang:${TARGET_GOLANG_VERSION}-bullseye AS builder

Expand Down
2 changes: 1 addition & 1 deletion build/Dockerfile.debian.prod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Purpose of this container image is to ship pocket binary with minimal dependencies.

ARG TARGET_GOLANG_VERSION=1.19
ARG TARGET_GOLANG_VERSION=1.20

FROM golang:${TARGET_GOLANG_VERSION}-bullseye AS builder

Expand Down
2 changes: 1 addition & 1 deletion build/Dockerfile.localdev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GOLANG_IMAGE_VERSION=golang:1.19-alpine3.16
ARG GOLANG_IMAGE_VERSION=golang:1.20-alpine3.16

FROM ${GOLANG_IMAGE_VERSION} AS builder

Expand Down
6 changes: 3 additions & 3 deletions build/localnet/manifests/configs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1688,7 +1688,7 @@ data:
"address": "00104055c00bed7c983a48aac7dc6335d7c607a7",
"public_key": "dfe357de55649e6d2ce889acf15eb77e94ab3c5756fe46d3c7538d37f27f115e",
"chains": ["0001"],
"service_url": "validator-001-pocket:42069",
"service_url": "http://validator-001-pocket:50832",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -1699,7 +1699,7 @@ data:
"address": "001022b138896c4c5466ac86b24a9bbe249905c2",
"public_key": "56915c1270bc8d9280a633e0be51647f62388a851318381614877ef2ed84a495",
"chains": ["0001"],
"service_url": "servicer-001-pocket:42069",
"service_url": "http://servicer-001-pocket:50832",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -1710,7 +1710,7 @@ data:
"address": "00202cd8f828a3818da2d24356984120f1cc3e8e",
"public_key": "6435e4d5d1ace32f187ea0cd571dc4fda767638d69dcec3b5a6ac952777d142d",
"chains": ["0001"],
"service_url": "servicer-002-pocket:42069",
"service_url": "http://servicer-002-pocket:50832",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand Down
6 changes: 3 additions & 3 deletions charts/pocket/templates/configmap-genesis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1694,7 +1694,7 @@ data:
"address": "00104055c00bed7c983a48aac7dc6335d7c607a7",
"public_key": "dfe357de55649e6d2ce889acf15eb77e94ab3c5756fe46d3c7538d37f27f115e",
"chains": ["0001"],
"service_url": "validator-001-pocket:42069",
"service_url": "http://validator-001-pocket:50832",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -1705,7 +1705,7 @@ data:
"address": "001022b138896c4c5466ac86b24a9bbe249905c2",
"public_key": "56915c1270bc8d9280a633e0be51647f62388a851318381614877ef2ed84a495",
"chains": ["0001"],
"service_url": "servicer-001-pocket:42069",
"service_url": "http://servicer-001-pocket:50832",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -1716,7 +1716,7 @@ data:
"address": "00202cd8f828a3818da2d24356984120f1cc3e8e",
"public_key": "6435e4d5d1ace32f187ea0cd571dc4fda767638d69dcec3b5a6ac952777d142d",
"chains": ["0001"],
"service_url": "servicer-002-pocket:42069",
"service_url": "http://servicer-002-pocket:50832",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand Down
130 changes: 130 additions & 0 deletions docs/development/CODE_REVIEW_GUIDELINES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Pocket's Code Development & Review Guidelines <!-- omit in toc -->

_This document is a living document and will be updated as the team learns and grows._

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

- [Code Quality](#code-quality)
- [Code Reviews](#code-reviews)
- [Code Review Guidelines](#code-review-guidelines)
- [Expectations](#expectations)
- [Best Practices](#best-practices)
- [Smaller PRs](#smaller-prs)
- [Ordering Commits](#ordering-commits)
- [Approving PRs](#approving-prs)
- [Review Comments](#review-comments)
- [Figure 1: Inline Github Comment](#figure-1-inline-github-comment)
- [Figure 2: Line Comment Dialog](#figure-2-line-comment-dialog)
- [Finishing a Review](#finishing-a-review)
- [Figure 3: Submitting A Review](#figure-3-submitting-a-review)
- [Merging](#merging)

## Code Quality

_tl;dr Code Quality is an art moreso than a science._

`Code Quality` can be a vague concept, as it usually addresses what is more the `art` side (vs. the `science` side) of software development. In this document, we outline a framework to guide that human judgement towards -- collectively -- `better code`.

There are often several _technically correct_ ways to address a problem -- that is, the correct answer or behavior is produced.
Selecting the "_best_" solution is often a matter of style. Sometimes, the best solution is one that fits the surrounding code in the most cohesive way.

Terms like `maintainability` or `readability` are used; these address the ability of other contributors to understand and improve the code. Unlike correctness or performance concepts, there's no single metric or mathematical solution that can be optimized to achieve better code quality. Thus, we rely on human judgement.

For decades, the `IETF` (Internet Engineering Task Force) has used the motto `rough consensus and running code`. This motto encapsulates (`running code`) that developers' core output is still software: if there is no code that runs and produces correct results, we have nothing. It also encapsulates (`rough consensus`) that we may not always precisely agree and that's okay.

## Code Reviews

_tl;dr Code Reviews are a necessary evil, and there are no specific guidelines that will university apply everywhere all the time._

One tactic often employed to produce `maintainable` or `more-readable` code is a `code review`. These can take many shapes and forms and often have goals beyond simply `code quality``.

Broadly speaking, code reviews involve developers looking at some proposed new code (or code changes). This is _usually_ developers other than the author (although a `self-review` can also be employed). In many projects, such attention is a scarce commodity: most programmers would rather write code than read someone else's.

Remember, writing code is the **fun part** but reading code is **work part**, so try to make it as easy for the reviewer as possible.

### Code Review Guidelines

All participants must adhere to the overall idea that the review is an attempt to achieve `better`` code. This is a vague statement on purpose.

Participants must be cautious in their criticism and generous with praise.

Participants must remember the scarcity of another developer's attention.

### Expectations

**Pull Request Authors:** The author is responsible for tracking up-to-date next actions for a Pull Request to progress towards being merged.

**Reviewers:** Reviewers should prefer engaging in code review over starting new work (i.e. taking planned work items that haven't been started yet).

**Reviewers (and prospective reviewers)** are encouraged to engage in reviews of codebases outside the projects and technologies they use on a day-to-day basis (but not expected to provide an approving review).

### Best Practices

#### Smaller PRs

Consider if it could be broken into smaller Pull Requests. If it is clear that it can be, summarize your thinking on how in your Review.

#### Ordering Commits

If the commits be (re)organized (i.e. reordered and/or amended) such that there is a commit at which the tests are passing prior to the conclusion of the main change, that's a signal that there's likely a logic split which can be made at that point in such a (re)arrangement.

#### Approving PRs

Use the following guidelines to evaluate whether a Pull Request should be approved:

- _Every_ Pull Request should have tests or justification otherwise; esp. bug fixes.
- _Every_ Pull Request should have at least 1 approval from a team member internal or external to the project. Exceptions made by repository maintainer(s), as necessary, on a case-by-case basis.

### Review Comments

_tl;dr Use `SOS`, `TECHDEBT`, `TECHDEBT(XXX)`, `NIT` if you think it'll help the author get context on the next steps._

When leaving review comments, consider if any of the following characterizations applies and prefix the comment, respectively:

- `NIT`: Comment is a nitpick
- `TECHDEBT`: Comment should have a TECHDEBT comment w/o a ticket
- `TECHDEBT(XXX)`: Comment should have a TECHDEBT comment but imporant enough that it requires a ticket to track the work in the near future
- `SOS`: Show Stopper. You feel strongly enought that it needs to be addressed now.

During review, submit feedback using line comments (Fig1); prefer `Add\[ing a\] single comment` over `Start[ing] a review` (Fi2). Once a review has been started, the option to add single comments is removed. Preferring single comments allows feedback to happen even in the event of an interrupted review.

### Figure 1: Inline Github Comment

![github_line_comment.png](./assets/github_line_comment.png)

### Figure 2: Line Comment Dialog

![line_comment_dialog_start.png](./assets/line_comment_dialog_start.png)

**Referencing Issues Across Repositories:** When referencing issues from one repository, in another's Issues and Pull Requests, GitHub supports automatic links in markdown using the following format: `<org name>/<repo name>#<issue or PR number>`.

### Finishing a Review

Write a summary of your observations and consider including positive remarks in addition to any constructive criticism.

If you observe a deviation from these practices or another reason that this change should not be merged, select `request changes` and include a summary of the observation(s), as well as any practice(s) you find them to be in conflict with, in the review body (Fig3).

If you don't feel comfortable giving approval or requesting changes but want to share a summary or observations of larger patterns in the codebase or the company, select "Comment" and submit your review (C).

Confirm that all items in the `required checklist` are checked or not applicable.

If you believe the Pull Request looks good to merge, select "Approve" and submit your review (Fig3).

### Figure 3: Submitting A Review

![submit_review.png](./assets/submit_review.png)

### Merging

1. Utilize the `Squash & Merge` feature (maintain a clean history)
2. Copy the `Github PR Description` into the commit message (add sufficient detail)

**Authors are core members or regular external contributors:**

- Core member needs to approve PR
- Author should merge in the PR themselves (following instructions above)

**Authors are non-regular external contributors:**

- Core member needs to approve PR
- Core member can merge PR on behalf of contributor (following instructions above)
35 changes: 35 additions & 0 deletions docs/development/GOLANG_UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Checklist to upgrade Go version

A short guide for carrying out Go version upgrades to Pocket V1

## Previous upgrades

A list of upgrades from the past, which can be used as a reference.

* 1.20 upgrade: [#910](https://github.com/pokt-network/pocket/pull/910)

## File Locations

- [ ] go.mod
- [ ] build.mk
- [ ] Makefile
- [ ] README.md
- [ ] .golangci.yml
- [ ] .github/workflows
- [ ] main.yml
- [ ] golangci-lint.yml
- [ ] build/
- [ ] Dockerfile.client
- [ ] Dockerfile.debian.dev
- [ ] Dockerfile.debian.prod
- [ ] Dockerfile.localdev
- [ ] docs/development
- [ ] README.md

## Testing

- [ ] LocalNet builds and runs locally
- [ ] LocalNet E2E tests pass
- [ ] GitHub Actions CI tests pass
- [ ] Remote network (such as DevNet) is functional and E2E tests pass
- [ ] Update this document with current Pocket Go version
15 changes: 14 additions & 1 deletion docs/development/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Please note that this repository is under very active development and breaking c
- [Profiling](#profiling)
- [Code Organization](#code-organization)
- [Maintaining Documentation](#maintaining-documentation)
- [Code Review Guidelines](#code-review-guidelines)
- [Documentation Resources and Implementation](#documentation-resources-and-implementation)
- [Your Project Dashboard](#your-project-dashboard)
- [Github Labels](#github-labels)
Expand Down Expand Up @@ -55,7 +56,7 @@ which protoc-go-inject-tag && echo "protoc-go-inject-tag Installed"
# protoc-go-inject-tag Installed

go version
# go version go1.18.1 darwin/arm64
# go version go1.20.5 darwin/arm64

mockgen --version
# v1.6.0
Expand Down Expand Up @@ -320,6 +321,18 @@ To keep the Wiki organized, a comment is added at the end of each `.md` file. Fo

If you are adding a new `.md` file for documentation please included a similar comment. Use your best judgment for the category and subcategory if its a new directory. Otherwise, copy the comment from a similar file in the directory and choose a relevant filename.

## Code Review Guidelines

- [Code Quality](./CODE_REVIEW_GUIDELINES.md#code-quality)
- [Code Reviews](./CODE_REVIEW_GUIDELINES.md#code-reviews)
- [Code Review Guidelines](./CODE_REVIEW_GUIDELINES.md#code-review-guidelines)
- [Expectations](./CODE_REVIEW_GUIDELINES.md#expectations)
- [Best Practices](./CODE_REVIEW_GUIDELINES.md#best-practices)
- [Reviewing](./CODE_REVIEW_GUIDELINES.md#reviewing)
- [Starting a Review](./CODE_REVIEW_GUIDELINES.md#starting-a-review)
- [Finishing a Review](./CODE_REVIEW_GUIDELINES.md#finishing-a-review)
- [Merging](./CODE_REVIEW_GUIDELINES.md#merging)

## Documentation Resources and Implementation

### Your Project Dashboard
Expand Down
Binary file added docs/development/assets/github_line_comment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/development/assets/submit_review.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/pokt-network/pocket

go 1.18
go 1.20

// TECHDEBT: remove once upstream PR is merged (see: https://github.com/cosmos/ics23/pull/153)
replace github.com/cosmos/ics23/go => github.com/h5law/ics23/go v0.0.0-20230619152251-56d948cafb83
Expand Down
2 changes: 1 addition & 1 deletion ibc/store/provable_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ func newTreeStoreMock(t *testing.T,

ctrl := gomock.NewController(t)
treeStoreMock := mockModules.NewMockTreeStoreModule(ctrl)
treeStoreMock.EXPECT().GetModuleName().Return(modules.TreeStoreModuleName).AnyTimes()
treeStoreMock.EXPECT().GetModuleName().Return(modules.TreeStoreSubmoduleName).AnyTimes()
treeStoreMock.EXPECT().SetBus(gomock.Any()).Return().AnyTimes()
treeStoreMock.EXPECT().GetBus().Return(bus).AnyTimes()

Expand Down
2 changes: 2 additions & 0 deletions p2p/transport_encryption_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build test

package p2p

import (
Expand Down
Loading

0 comments on commit 608826a

Please sign in to comment.