Skip to content

Commit

Permalink
Merge branch 'master' into feat/otel
Browse files Browse the repository at this point in the history
  • Loading branch information
thehowl authored Nov 6, 2024
2 parents e283640 + 2173b49 commit 7cd1546
Show file tree
Hide file tree
Showing 240 changed files with 7,316 additions and 5,560 deletions.
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
.dockerignore
build/
Dockerfile
misc/
misc/*
!misc/loop/
!misc/autocounterd/
docker-compose.yml
tests/docker-integration/

Expand Down
1 change: 1 addition & 0 deletions .github/golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ linters:
- misspell # Misspelled English words in comments
- makezero # Finds slice declarations with non-zero initial length
- importas # Enforces consistent import aliases
- govet # same as 'go vet'
- gosec # Security problems
- gofmt # Whether the code was gofmt-ed
- goimports # Unused imports
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/autocounterd.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: autocounterd

on:
pull_request:
branches:
- master
push:
paths:
- misc/autocounterd
Expand Down Expand Up @@ -41,7 +44,6 @@ jobs:
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./misc/autocounterd
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion .github/workflows/mod-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
- name: Check go.mod files are up to date
working-directory: ${{ inputs.modulepath }}
run: |
make tidy VERIFY_GO_SUMS=true
make tidy VERIFY_MOD_SUMS=true
1 change: 0 additions & 1 deletion .github/workflows/portal-loop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ jobs:
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./misc/loop
target: portalloopd
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/releaser-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create a dummy tag to avoid goreleaser failure
run: git tag v0.0.0 master

- uses: actions/setup-go@v5
with:
Expand All @@ -40,7 +42,7 @@ jobs:
with:
distribution: goreleaser-pro
version: ~> v2
args: release --clean --snapshot --nightly --config ./.github/goreleaser.yaml
args: release --clean --nightly --config ./.github/goreleaser.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/stale-bot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Close stale PRs"
on:
schedule:
- cron: "30 1 * * *"
permissions:
pull-requests: write
issues: write

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v9
with:
exempt-all-milestones: true
stale-pr-message: "This PR is stale because it has been open 3 months with no activity. Remove stale label or comment or this will be closed in 3 months."
close-pr-message: "This PR was closed because it has been stalled for 3 months with no activity."
days-before-pr-stale: 90
days-before-pr-close: 90
stale-issue-message: "This issue is stale because it has been open 6 months with no activity. Remove stale label or comment or this will be closed in 3 months."
close-issue-message: "This issue was closed because it has been stalled for 3 months with no activity."
days-before-issue-stale: 180
days-before-issue-close: 90
26 changes: 25 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,20 @@ RUN --mount=type=cache,target=/root/.cache/go-build go build -o ./
RUN --mount=type=cache,target=/root/.cache/go-build go build -o ./build/gnoweb ./gno.land/cmd/gnoweb
RUN --mount=type=cache,target=/root/.cache/go-build go build -o ./build/gno ./gnovm/cmd/gno

# build misc binaries
FROM golang:1.22-alpine AS build-misc
RUN go env -w GOMODCACHE=/root/.cache/go-build
WORKDIR /gnoroot
ENV GNOROOT="/gnoroot"
COPY . ./
RUN --mount=type=cache,target=/root/.cache/go-build go build -C ./misc/loop -o /gnoroot/build/portalloopd ./cmd
RUN --mount=type=cache,target=/root/.cache/go-build go build -C ./misc/autocounterd -o /gnoroot/build/autocounterd ./cmd

# Base image
FROM alpine:3.17 AS base
WORKDIR /gnoroot
ENV GNOROOT="/gnoroot"
RUN apk add ca-certificates
RUN apk add --no-cache ca-certificates
CMD [ "" ]

# alpine images
Expand Down Expand Up @@ -47,6 +56,21 @@ COPY --from=build-gno /opt/gno/src/gno.land/cmd/gnoweb /opt/gno/src/gnowe
EXPOSE 8888
ENTRYPOINT ["/usr/bin/gnoweb"]

# misc/loop
FROM docker AS portalloopd
WORKDIR /gnoroot
ENV GNOROOT="/gnoroot"
RUN apk add --no-cache ca-certificates bash curl jq
COPY --from=build-misc /gnoroot/build/portalloopd /usr/bin/portalloopd
ENTRYPOINT ["/usr/bin/portalloopd"]
CMD ["serve"]

# misc/autocounterd
FROM base AS autocounterd
COPY --from=build-misc /gnoroot/build/autocounterd /usr/bin/autocounterd
ENTRYPOINT ["/usr/bin/autocounterd"]
CMD ["start"]

# all, contains everything.
FROM base AS all
COPY --from=build-gno /gnoroot/build/* /usr/bin/
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile.release
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# This file is similar to Dockerfile, but assumes that the binaries have
# already been created, and as such doesn't `go build` them.

FROM alpine AS base

ENV GNOROOT="/gnoroot/"
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ install.gnodev:
$(MAKE) --no-print-directory -C ./contribs/gnodev install
@printf "\033[0;32m[+] 'gnodev' has been installed. Read more in ./contribs/gnodev/\033[0m\n"


# old aliases
.PHONY: install_gnokey
install_gnokey: install.gnokey
Expand Down
10 changes: 8 additions & 2 deletions contribs/gnodev/cmd/gnodev/setup_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func setupDevNode(

if devCfg.txsFile != "" { // Load txs files
var err error
nodeConfig.InitialTxs, err = parseTxs(devCfg.txsFile)
nodeConfig.InitialTxs, err = gnoland.ReadGenesisTxs(ctx, devCfg.txsFile)
if err != nil {
return nil, fmt.Errorf("unable to load transactions: %w", err)
}
Expand All @@ -35,7 +35,13 @@ func setupDevNode(

// Override balances and txs
nodeConfig.BalancesList = state.Balances
nodeConfig.InitialTxs = state.Txs

stateTxs := state.Txs
nodeConfig.InitialTxs = make([]gnoland.TxWithMetadata, len(stateTxs))

for index, nodeTx := range stateTxs {
nodeConfig.InitialTxs[index] = nodeTx
}

logger.Info("genesis file loaded", "path", devCfg.genesisFile, "txs", len(nodeConfig.InitialTxs))
}
Expand Down
23 changes: 0 additions & 23 deletions contribs/gnodev/cmd/gnodev/txs.go

This file was deleted.

2 changes: 1 addition & 1 deletion contribs/gnodev/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,6 @@ require (
google.golang.org/genproto/googleapis/api v0.0.0-20240822170219-fc7c04adadcd // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240822170219-fc7c04adadcd // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
4 changes: 2 additions & 2 deletions contribs/gnodev/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 17 additions & 9 deletions contribs/gnodev/pkg/dev/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type NodeConfig struct {
BalancesList []gnoland.Balance
PackagesPathList []PackagePath
Emitter emitter.Emitter
InitialTxs []std.Tx
InitialTxs []gnoland.TxWithMetadata
TMConfig *tmcfg.Config
SkipFailingGenesisTxs bool
NoReplay bool
Expand Down Expand Up @@ -84,7 +84,7 @@ type Node struct {
loadedPackages int

// state
initialState, state []std.Tx
initialState, state []gnoland.TxWithMetadata
currentStateIndex int
}

Expand Down Expand Up @@ -154,7 +154,7 @@ func (n *Node) GetRemoteAddress() string {

// GetBlockTransactions returns the transactions contained
// within the specified block, if any
func (n *Node) GetBlockTransactions(blockNum uint64) ([]std.Tx, error) {
func (n *Node) GetBlockTransactions(blockNum uint64) ([]gnoland.TxWithMetadata, error) {
n.muNode.RLock()
defer n.muNode.RUnlock()

Expand All @@ -163,21 +163,26 @@ func (n *Node) GetBlockTransactions(blockNum uint64) ([]std.Tx, error) {

// GetBlockTransactions returns the transactions contained
// within the specified block, if any
func (n *Node) getBlockTransactions(blockNum uint64) ([]std.Tx, error) {
func (n *Node) getBlockTransactions(blockNum uint64) ([]gnoland.TxWithMetadata, error) {
int64BlockNum := int64(blockNum)
b, err := n.client.Block(&int64BlockNum)
if err != nil {
return []std.Tx{}, fmt.Errorf("unable to load block at height %d: %w", blockNum, err) // nothing to see here
return []gnoland.TxWithMetadata{}, fmt.Errorf("unable to load block at height %d: %w", blockNum, err) // nothing to see here
}

txs := make([]std.Tx, len(b.Block.Data.Txs))
txs := make([]gnoland.TxWithMetadata, len(b.Block.Data.Txs))
for i, encodedTx := range b.Block.Data.Txs {
var tx std.Tx
if unmarshalErr := amino.Unmarshal(encodedTx, &tx); unmarshalErr != nil {
return nil, fmt.Errorf("unable to unmarshal amino tx, %w", unmarshalErr)
}

txs[i] = tx
txs[i] = gnoland.TxWithMetadata{
Tx: tx,
Metadata: &gnoland.GnoTxMetadata{
Timestamp: b.BlockMeta.Header.Time.Unix(),
},
}
}

return txs, nil
Expand Down Expand Up @@ -347,11 +352,14 @@ func (n *Node) SendTransaction(tx *std.Tx) error {
return nil
}

func (n *Node) getBlockStoreState(ctx context.Context) ([]std.Tx, error) {
func (n *Node) getBlockStoreState(ctx context.Context) ([]gnoland.TxWithMetadata, error) {
// get current genesis state
genesis := n.GenesisDoc().AppState.(gnoland.GnoGenesisState)

state := genesis.Txs[n.loadedPackages:] // ignore previously loaded packages
initialTxs := genesis.Txs[n.loadedPackages:] // ignore previously loaded packages

state := append([]gnoland.TxWithMetadata{}, initialTxs...)

lastBlock := n.getLatestBlockNumber()
var blocnum uint64 = 1
for ; blocnum <= lastBlock; blocnum++ {
Expand Down
5 changes: 2 additions & 3 deletions contribs/gnodev/pkg/dev/node_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/gnolang/gno/contribs/gnodev/pkg/events"
"github.com/gnolang/gno/gno.land/pkg/gnoland"
bft "github.com/gnolang/gno/tm2/pkg/bft/types"
"github.com/gnolang/gno/tm2/pkg/std"
)

var ErrEmptyState = errors.New("empty state")
Expand All @@ -29,7 +28,7 @@ func (n *Node) SaveCurrentState(ctx context.Context) error {
}

// Export the current state as list of txs
func (n *Node) ExportCurrentState(ctx context.Context) ([]std.Tx, error) {
func (n *Node) ExportCurrentState(ctx context.Context) ([]gnoland.TxWithMetadata, error) {
n.muNode.RLock()
defer n.muNode.RUnlock()

Expand All @@ -42,7 +41,7 @@ func (n *Node) ExportCurrentState(ctx context.Context) ([]std.Tx, error) {
return state[:n.currentStateIndex], nil
}

func (n *Node) getState(ctx context.Context) ([]std.Tx, error) {
func (n *Node) getState(ctx context.Context) ([]gnoland.TxWithMetadata, error) {
if n.state == nil {
var err error
n.state, err = n.getBlockStoreState(ctx)
Expand Down
24 changes: 14 additions & 10 deletions contribs/gnodev/pkg/dev/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"path/filepath"

"github.com/gnolang/gno/contribs/gnodev/pkg/address"
"github.com/gnolang/gno/gno.land/pkg/gnoland"
vmm "github.com/gnolang/gno/gno.land/pkg/sdk/vm"
gno "github.com/gnolang/gno/gnovm/pkg/gnolang"
"github.com/gnolang/gno/gnovm/pkg/gnomod"
Expand Down Expand Up @@ -118,7 +119,7 @@ func (pm PackagesMap) toList() gnomod.PkgList {
return list
}

func (pm PackagesMap) Load(fee std.Fee) ([]std.Tx, error) {
func (pm PackagesMap) Load(fee std.Fee) ([]gnoland.TxWithMetadata, error) {
pkgs := pm.toList()

sorted, err := pkgs.Sort()
Expand All @@ -127,7 +128,8 @@ func (pm PackagesMap) Load(fee std.Fee) ([]std.Tx, error) {
}

nonDraft := sorted.GetNonDraftPkgs()
txs := []std.Tx{}
txs := make([]gnoland.TxWithMetadata, 0, len(nonDraft))

for _, modPkg := range nonDraft {
pkg := pm[modPkg.Dir]
if pkg.Creator.IsZero() {
Expand All @@ -141,18 +143,20 @@ func (pm PackagesMap) Load(fee std.Fee) ([]std.Tx, error) {
}

// Create transaction
tx := std.Tx{
Fee: fee,
Msgs: []std.Msg{
vmm.MsgAddPackage{
Creator: pkg.Creator,
Deposit: pkg.Deposit,
Package: memPkg,
tx := gnoland.TxWithMetadata{
Tx: std.Tx{
Fee: fee,
Msgs: []std.Msg{
vmm.MsgAddPackage{
Creator: pkg.Creator,
Deposit: pkg.Deposit,
Package: memPkg,
},
},
},
}

tx.Signatures = make([]std.Signature, len(tx.GetSigners()))
tx.Tx.Signatures = make([]std.Signature, len(tx.Tx.GetSigners()))
txs = append(txs, tx)
}

Expand Down
Loading

0 comments on commit 7cd1546

Please sign in to comment.