Skip to content

[Core] Restructure repo to follow industry golang standards#412

Closed
Gustavobelfort wants to merge 5 commits intomainfrom
feat/golang-standard-structure
Closed

[Core] Restructure repo to follow industry golang standards#412
Gustavobelfort wants to merge 5 commits intomainfrom
feat/golang-standard-structure

Conversation

@Gustavobelfort
Copy link
Contributor

@Gustavobelfort Gustavobelfort commented Dec 20, 2022

Description

This refactors the codebase to follow the standards outlined in https://github.com/golang-standards/project-layout.
Additionally some changes on the Makefile were applied to make it mode readable and maintainable.

Issue

Fixes #379

Type of change

Please mark the relevant option(s):

  • New feature, functionality or library
  • Bug fix
  • Code health or cleanup
  • Major breaking change
  • Documentation
  • Other

List of changes

  • Refactor codebase to follow golang project layout standards
  • QOL changes to make the Makefile more readable and maintainable by splitting it into multiple domain oriented files
    • The new sub makefiles are locates at ./scripts
  • Updated documentation pointing to internal packages
  • Updated golang codebase to take in account the new package location
  • Updated the protobuf files and its corresponding scripts to build correctly with the new package paths

Testing

  • make develop_test
  • LocalNet w/ all of the steps outlined in the README

Required Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have tested my changes using the available tooling
  • I have updated the corresponding CHANGELOG

If Applicable Checklist

  • I have updated the corresponding README(s); local and/or global
  • I have added tests that prove my fix is effective or that my feature works
  • I have added, or updated, mermaid.js diagrams in the corresponding README(s)
  • I have added, or updated, documentation and mermaid.js diagrams in shared/docs/* if I updated shared/*README(s)

@Gustavobelfort Gustavobelfort changed the title FEAT: Restructure repo to follow industry golang standards [WIP] Restructure repo to follow industry golang standards Dec 20, 2022
@Gustavobelfort Gustavobelfort self-assigned this Dec 26, 2022
@Gustavobelfort Gustavobelfort added the core Core infrastructure - protocol related label Dec 26, 2022
@Gustavobelfort Gustavobelfort linked an issue Dec 26, 2022 that may be closed by this pull request
4 tasks
@Gustavobelfort Gustavobelfort marked this pull request as ready for review December 27, 2022 00:06
@Gustavobelfort Gustavobelfort changed the title [WIP] Restructure repo to follow industry golang standards [Core] Restructure repo to follow industry golang standards Dec 27, 2022
@Olshansk Olshansk added the code health Nice to have code improvement label Dec 28, 2022
Copy link
Collaborator

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely a hard change to review.

I'm not the biggest fan of everything but open to having the discussion.

  1. Left some comments around naming decisions.

  2. We started committing mocked files and generated files that we did not before

  3. When I tried to run the tests it did not work for me. Did it pass for you?

  4. This library isn't exactly an SDK, so is there really a reason to have 90% of the codebase under internal just because that's what the best practices say? Have you looked at how other blockchain Go projects (Cosmos, Tendermint, Flow, Celestia, et al) do it?

Screenshot 2023-01-03 at 3 49 28 PM

.PHONY: client_connect
client_connect: docker_check ## Connect to the running client debugging daemon
docker exec -it client /bin/bash -c "go run -tags=debug app/client/*.go debug"
docker exec -it client /bin/bash -c "go run -tags=debug cmd/p1/*.go debug"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so sure about renaming app/client to cmd/p1.

Is this the golang standard?

p1 is the binary name we selected, but what if we choose to rename it? E.g. after v0 is deprecated and v1 is live, we might name it pocket instead. I felt like client was general enough.

@@ -1,22 +1,11 @@
include build.mk
include scripts/build.mk
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big fan of this but just not that you might hit some merge conflicts soon. Shouldn't be an issue but just FYI

@@ -0,0 +1,546 @@
// Package rpc provides primitives to interact with the openapi HTTP API.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we include this file in main before this change?

"github.com/pokt-network/pocket/app"
"github.com/pokt-network/pocket/shared/codec"
typesUtil "github.com/pokt-network/pocket/utility/types"
app "github.com/pokt-network/pocket/cmd"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bit weird.

If app is a good semantic name for it, then I'd argue we shouldn't rename cmd to app.

Why the change?

var (
_ modules.RPCModule = &rpcModule{}
)
var _ modules.RPCModule = &rpcModule{}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really think rpc should be under internal?

@@ -0,0 +1,7 @@
syntax = "proto3";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why git didn't treat this as a mv while it did for most of the others?

@@ -0,0 +1,188 @@
// Code generated by MockGen. DO NOT EDIT.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we start committing mocked files now?

We did not do so before and shouldn't start doing it now.

@Olshansk
Copy link
Collaborator

Olshansk commented Feb 7, 2023

Summarised some comments here for whoever picks this up in the future.

@Olshansk Olshansk closed this Feb 7, 2023
@Olshansk Olshansk deleted the feat/golang-standard-structure branch June 2, 2023 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code health Nice to have code improvement core Core infrastructure - protocol related

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Core] Follow industry standards for Golang project folder structure

2 participants