Skip to content

Commit

Permalink
Merge branch 'develop' into feat/tls
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverbundalo committed Mar 12, 2024
2 parents 339ed1d + c681a63 commit 6ff4220
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 60 deletions.
25 changes: 21 additions & 4 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ builds:
- CC=o64-clang
- CXX=o64-clang++
ldflags:
-s -w -X 'github.com/${GITHUB_REPOSITORY}/versioning.Version=v{{ .Version }}'
-s -w
-X 'github.com/0xPolygon/polygon-edge/versioning.Version=v{{ .Version }}'
-X 'github.com/0xPolygon/polygon-edge/versioning.Commit={{ .Commit }}'
-X 'github.com/0xPolygon/polygon-edge/versioning.Branch={{ .Branch }}'
-X 'github.com/0xPolygon/polygon-edge/versioning.BuildTime={{ .Date }}'

- id: darwin-arm64
main: ./main.go
Expand All @@ -30,7 +34,11 @@ builds:
- CC=oa64-clang
- CXX=oa64-clang++
ldflags:
-s -w -X 'github.com/${GITHUB_REPOSITORY}/versioning.Version=v{{ .Version }}'
-s-w
-X 'github.com/0xPolygon/polygon-edge/versioning.Version=v{{ .Version }}'
-X 'github.com/0xPolygon/polygon-edge/versioning.Commit={{ .Commit }}'
-X 'github.com/0xPolygon/polygon-edge/versioning.Branch={{ .Branch }}'
-X 'github.com/0xPolygon/polygon-edge/versioning.BuildTime={{ .Date }}'

- id: linux-amd64
main: ./main.go
Expand All @@ -44,7 +52,11 @@ builds:
- CXX=g++
ldflags:
# We need to build a static binary because we are building in a glibc based system and running in a musl container
-s -w -linkmode external -extldflags "-static" -X 'github.com/${GITHUB_REPOSITORY}/versioning.Version=v{{ .Version }}'
-s -w
-linkmode external -extldflags "-static" -X 'github.com/0xPolygon/polygon-edge/versioning.Version=v{{ .Version }}'
-linkmode external -extldflags "-static" -X 'github.com/0xPolygon/polygon-edge/versioning.Commit={{ .Commit }}'
-linkmode external -extldflags "-static" -X 'github.com/0xPolygon/polygon-edge/versioning.Branch={{ .Branch }}'
-linkmode external -extldflags "-static" -X 'github.com/0xPolygon/polygon-edge/versioning.BuildTime={{ .Date }}'
tags:
- netgo
- osusergo
Expand All @@ -61,7 +73,11 @@ builds:
- CXX=aarch64-linux-gnu-g++
ldflags:
# We need to build a static binary because we are building in a glibc based system and running in a musl container
-s -w -linkmode external -extldflags "-static" -X 'github.com/${GITHUB_REPOSITORY}/versioning.Version=v{{ .Version }}'
-s -w
-linkmode external -extldflags "-static" -X 'github.com/0xPolygon/polygon-edge/versioning.Version=v{{ .Version }}'
-linkmode external -extldflags "-static" -X 'github.com/0xPolygon/polygon-edge/versioning.Commit={{ .Commit }}'
-linkmode external -extldflags "-static" -X 'github.com/0xPolygon/polygon-edge/versioning.Branch={{ .Branch }}'
-linkmode external -extldflags "-static" -X 'github.com/0xPolygon/polygon-edge/versioning.BuildTime={{ .Date }}'
tags:
- netgo
- osusergo
Expand Down Expand Up @@ -110,3 +126,4 @@ docker_manifests:
- DOCKERHUB_ORGANIZATION/{{ .ProjectName }}:{{ .Version }}-amd64
- DOCKERHUB_ORGANIZATION/{{ .ProjectName }}:{{ .Version }}-arm64
skip_push: auto

1 change: 0 additions & 1 deletion consensus/polybft/consensus_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ func (c *consensusRuntime) initStakeManager(logger hcf.Logger, dbTx *bolt.Tx) er
func (c *consensusRuntime) initGovernanceManager(logger hcf.Logger, dbTx *bolt.Tx) error {
governanceManager, err := newGovernanceManager(
c.config.genesisParams,
c.config.GenesisConfig,
logger.Named("governance-manager"),
c.state,
c.config.blockchain,
Expand Down
8 changes: 4 additions & 4 deletions consensus/polybft/governance_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ type governanceManager struct {
}

// newGovernanceManager is a constructor function for governance manager
func newGovernanceManager(genesisParams *chain.Params, genesisConfig *PolyBFTConfig,
func newGovernanceManager(genesisParams *chain.Params,
logger hclog.Logger,
state *State,
blockhain blockchainBackend,
Expand Down Expand Up @@ -459,7 +459,7 @@ func isForkParamsEvent(event contractsapi.EventAbi) (types.Hash, *big.Int, bool)
}

// parseGovernanceEvent parses provided log to correct governance event
func parseGovernanceEvent(h *types.Header, log *ethgo.Log) (contractsapi.EventAbi, bool, error) {
func parseGovernanceEvent(log *ethgo.Log) (contractsapi.EventAbi, bool, error) {
var (
checkpointIntervalEvent contractsapi.NewCheckpointBlockIntervalEvent
epochSizeEvent contractsapi.NewEpochSizeEvent
Expand Down Expand Up @@ -546,7 +546,7 @@ func (g *governanceManager) GetLogFilters() map[types.Address][]types.Hash {
}

func (g *governanceManager) ProcessLog(header *types.Header, log *ethgo.Log, dbTx *bolt.Tx) error {
event, isGovernanceEvent, err := parseGovernanceEvent(header, log)
event, isGovernanceEvent, err := parseGovernanceEvent(log)
if err != nil {
return err
}
Expand All @@ -567,7 +567,7 @@ func (g *governanceManager) ProcessLog(header *types.Header, log *ethgo.Log, dbT
)

return g.state.GovernanceStore.insertGovernanceEvent(
extra.Checkpoint.EpochNumber, header.Number, event, dbTx)
extra.Checkpoint.EpochNumber, event, dbTx)
}

// unmarshalGovernanceEvent unmarshals given raw event to desired type
Expand Down
10 changes: 5 additions & 5 deletions consensus/polybft/governance_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func TestGovernanceManager_PostEpoch(t *testing.T) {
baseFeeChangeDenomEvent := &contractsapi.NewBaseFeeChangeDenomEvent{BaseFeeChangeDenom: big.NewInt(100)}
epochRewardEvent := &contractsapi.NewEpochRewardEvent{Reward: big.NewInt(10000)}

require.NoError(t, state.GovernanceStore.insertGovernanceEvent(1, 7, baseFeeChangeDenomEvent, nil))
require.NoError(t, state.GovernanceStore.insertGovernanceEvent(1, 7, epochRewardEvent, nil))
require.NoError(t, state.GovernanceStore.insertGovernanceEvent(1, baseFeeChangeDenomEvent, nil))
require.NoError(t, state.GovernanceStore.insertGovernanceEvent(1, epochRewardEvent, nil))

// no initial config was saved, so we expect an error
require.ErrorIs(t, governanceManager.PostEpoch(&PostEpochRequest{
Expand Down Expand Up @@ -88,7 +88,7 @@ func TestGovernanceManager_PostBlock(t *testing.T) {
})

chainParams := &chain.Params{Engine: map[string]interface{}{ConsensusName: genesisPolybftConfig}}
governanceManager, err := newGovernanceManager(chainParams, genesisPolybftConfig,
governanceManager, err := newGovernanceManager(chainParams,
hclog.NewNullLogger(), state, blockchainMock, nil)
require.NoError(t, err)

Expand Down Expand Up @@ -122,14 +122,14 @@ func TestGovernanceManager_PostBlock(t *testing.T) {
})

chainParams := &chain.Params{Engine: map[string]interface{}{ConsensusName: genesisPolybftConfig}}
governanceManager, err := newGovernanceManager(chainParams, genesisPolybftConfig,
governanceManager, err := newGovernanceManager(chainParams,
hclog.NewNullLogger(), state, blockchainMock, nil)
require.NoError(t, err)

// this cheats that we have this fork in code
governanceManager.allForksHashes[newForkHash] = newForkName

require.NoError(t, state.GovernanceStore.insertGovernanceEvent(1, newForkBlock.Uint64(),
require.NoError(t, state.GovernanceStore.insertGovernanceEvent(1,
&contractsapi.NewFeatureEvent{
Feature: newForkHash, Block: newForkBlock,
}, nil))
Expand Down
3 changes: 1 addition & 2 deletions consensus/polybft/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/0xPolygon/polygon-edge/consensus/polybft/validator"
"github.com/0xPolygon/polygon-edge/consensus/polybft/wallet"
"github.com/0xPolygon/polygon-edge/types"
"github.com/hashicorp/go-hclog"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -155,7 +154,7 @@ func newTestState(tb testing.TB) *State {
tb.Fatal(err)
}

state, err := newState(path.Join(dir, "my.db"), hclog.NewNullLogger(), make(chan struct{}))
state, err := newState(path.Join(dir, "my.db"), make(chan struct{}))
if err != nil {
tb.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion consensus/polybft/polybft.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ func (p *Polybft) Initialize() error {
return fmt.Errorf("failed to create data directory. Error: %w", err)
}

stt, err := newState(filepath.Join(p.dataDir, stateFileName), p.logger, p.closeCh)
stt, err := newState(filepath.Join(p.dataDir, stateFileName), p.closeCh)
if err != nil {
return fmt.Errorf("failed to create state instance. Error: %w", err)
}
Expand Down
3 changes: 1 addition & 2 deletions consensus/polybft/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"

"github.com/0xPolygon/polygon-edge/helper/common"
"github.com/hashicorp/go-hclog"
bolt "go.etcd.io/bbolt"
)

Expand Down Expand Up @@ -47,7 +46,7 @@ type State struct {
}

// newState creates new instance of State
func newState(path string, logger hclog.Logger, closeCh chan struct{}) (*State, error) {
func newState(path string, closeCh chan struct{}) (*State, error) {
db, err := bolt.Open(path, 0666, nil)
if err != nil {
return nil, err
Expand Down
3 changes: 1 addition & 2 deletions consensus/polybft/state_store_governance.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ func (g *GovernanceStore) initialize(tx *bolt.Tx) error {

// insertGovernanceEvent inserts governance event to bolt db
// each epoch has a list of events that happened in it
func (g *GovernanceStore) insertGovernanceEvent(epoch, block uint64,
event contractsapi.EventAbi, dbTx *bolt.Tx) error {
func (g *GovernanceStore) insertGovernanceEvent(epoch uint64, event contractsapi.EventAbi, dbTx *bolt.Tx) error {
insertFn := func(tx *bolt.Tx) error {
if forkHash, forkBlock, isForkEvent := isForkParamsEvent(event); isForkEvent {
forkParamsBucket := tx.Bucket(forkParamsEventsBucket)
Expand Down
7 changes: 3 additions & 4 deletions consensus/polybft/state_store_governance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func TestGovernanceStore_InsertAndGetEvents(t *testing.T) {
t.Parallel()

epoch := uint64(11)
block := uint64(111)
state := newTestState(t)

// NetworkParams events
Expand Down Expand Up @@ -61,7 +60,7 @@ func TestGovernanceStore_InsertAndGetEvents(t *testing.T) {
allEvents = append(allEvents, forkParamsEvents...)

for _, e := range allEvents {
require.NoError(t, state.GovernanceStore.insertGovernanceEvent(epoch, block, e, nil))
require.NoError(t, state.GovernanceStore.insertGovernanceEvent(epoch, e, nil))
}

// test for an epoch that didn't have any events
Expand All @@ -87,8 +86,8 @@ func TestGovernanceStore_InsertAndGetEvents(t *testing.T) {
newFeatureEventTwo := &contractsapi.UpdatedFeatureEvent{Feature: types.BytesToHash([]byte("OxSomeFeature3")),
Block: big.NewInt(130_000)}

require.NoError(t, state.GovernanceStore.insertGovernanceEvent(epoch, block+1, sprintSizeEvent, nil))
require.NoError(t, state.GovernanceStore.insertGovernanceEvent(epoch, block+1, newFeatureEventTwo, nil))
require.NoError(t, state.GovernanceStore.insertGovernanceEvent(epoch, sprintSizeEvent, nil))
require.NoError(t, state.GovernanceStore.insertGovernanceEvent(epoch, newFeatureEventTwo, nil))

eventsRaw, err = state.GovernanceStore.getNetworkParamsEvents(epoch, nil)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion e2e-polybft/e2e/consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ func TestE2E_Consensus_EIP1559Check(t *testing.T) {

client := cluster.Servers[0].JSONRPC().Eth()

waitUntilBalancesChanged := func(acct ethgo.Address, initialBalance *big.Int) error {
waitUntilBalancesChanged := func(_ ethgo.Address, initialBalance *big.Int) error {
err := cluster.WaitUntil(30*time.Second, 1*time.Second, func() bool {
balance, err := client.GetBalance(recipient, ethgo.Latest)
if err != nil {
Expand Down
16 changes: 6 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,22 @@ require (
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80
google.golang.org/grpc v1.62.0
google.golang.org/protobuf v1.32.0
gopkg.in/DataDog/dd-trace-go.v1 v1.60.0
gopkg.in/DataDog/dd-trace-go.v1 v1.61.0
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce
gopkg.in/yaml.v3 v3.0.1
pgregory.net/rapid v1.1.0
)

require github.com/docker/distribution v2.8.3+incompatible // indirect

require (
cloud.google.com/go/compute v1.23.3 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v1.1.5 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/DataDog/appsec-internal-go v1.4.0 // indirect
github.com/DataDog/appsec-internal-go v1.4.1 // indirect
github.com/DataDog/datadog-agent/pkg/obfuscate v0.48.0 // indirect
github.com/DataDog/datadog-agent/pkg/remoteconfig/state v0.48.1 // indirect
github.com/DataDog/datadog-go/v5 v5.3.0 // indirect
github.com/DataDog/go-libddwaf/v2 v2.2.3 // indirect
github.com/DataDog/go-libddwaf/v2 v2.3.1 // indirect
github.com/DataDog/go-tuf v1.0.2-0.5.2 // indirect
github.com/DataDog/gostackparse v0.7.0 // indirect
github.com/DataDog/sketches-go v1.4.2 // indirect
Expand All @@ -84,15 +82,16 @@ require (
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/ebitengine/purego v0.5.2 // indirect
github.com/ebitengine/purego v0.6.0-alpha.5 // indirect
github.com/elastic/gosigar v0.14.2 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/flynn/noise v1.0.0 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect
github.com/go-jose/go-jose/v3 v3.0.1 // indirect
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
Expand Down Expand Up @@ -207,8 +206,6 @@ require (
go.uber.org/mock v0.3.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
go4.org/intern v0.0.0-20230525184215-6c62f75575cb // indirect
go4.org/unsafe/assume-no-moving-gc v0.0.0-20231121144256-b99613f794b6 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/exp/typeparams v0.0.0-20240213143201-ec583247a57a // indirect
golang.org/x/mod v0.15.0 // indirect
Expand All @@ -223,6 +220,5 @@ require (
google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
gotest.tools/v3 v3.0.2 // indirect
inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a // indirect
lukechampine.com/blake3 v1.2.1 // indirect
)
Loading

0 comments on commit 6ff4220

Please sign in to comment.