Skip to content

Commit

Permalink
Merge branch 'development' into ed/create_dot_unit_tests_b
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardmack committed Apr 4, 2022
2 parents c6e136d + 9efde47 commit d894db6
Show file tree
Hide file tree
Showing 67 changed files with 1,742 additions and 480 deletions.
32 changes: 16 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,28 @@ jobs:
platform: [macos-latest, ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- uses: actions/setup-go@v2
with:
go-version: 1.18
stable: true
check-latest: true

- name: Set cache variables
id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- uses: actions/checkout@v3

# cache go build cache
- name: Cache go modules
- name: Go build cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-build

# cache go mod cache
- name: Cache go modules
- name: Go modules cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
Expand All @@ -65,28 +65,28 @@ jobs:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- uses: actions/setup-go@v2
with:
go-version: 1.18
stable: true
check-latest: true

- name: Set cache variables
id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- uses: actions/checkout@v3

# cache go build cache
- name: Cache go modules
- name: Go build cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-build

# cache go mod cache
- name: Cache go modules
- name: Go modules cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/code-cov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,28 @@ jobs:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- uses: actions/setup-go@v2
with:
go-version: 1.18
stable: true
check-latest: true

- name: Set cache variables
id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- uses: actions/checkout@v3

# cache go build cache
- name: Cache go modules
- name: Go build cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-build

# cache go mod cache
- name: Cache go modules
- name: Go modules cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
Expand Down
17 changes: 8 additions & 9 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,28 @@ jobs:
]
runs-on: ubuntu-latest
steps:
- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- uses: actions/setup-go@v2
with:
go-version: 1.18
stable: true
check-latest: true

- name: Set cache variables
id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- uses: actions/checkout@v3

# cache go build cache
- name: Cache go modules
- name: Go build cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-build

# cache go mod cache
- name: Cache go modules
- name: Go modules cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
Expand Down
17 changes: 8 additions & 9 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,28 @@ jobs:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- uses: actions/setup-go@v2
with:
go-version: 1.18
stable: true
check-latest: true

- name: Set cache variables
id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- uses: actions/checkout@v3

# cache go build cache
- name: Cache go modules
- name: Go build cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-build

# cache go mod cache
- name: Cache go modules
- name: Go modules cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
Expand Down
2 changes: 1 addition & 1 deletion cmd/gossamer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ defined in [lib/runtime/wasmer/exports.go](../../lib/runtime/wasmer/exports.go).
Gossamer publishes telemetry data and also includes an embedded Prometheus server that reports metrics. The metrics
capabilities are defined in the [dot/metrics](../../dot/metrics) package and build on
[the metrics library that is included with Go Ethereum](https://github.com/ethereum/go-ethereum/blob/master/metrics/README.md).
The default listening address for Prometheus metrics is `localhost:9090`, and Gossamer allows the user to configure this parameter with the
The default listening address for Prometheus metrics is `localhost:9876`, and Gossamer allows the user to configure this parameter with the
`--metrics-address` command-line parameter. The Gossamer telemetry server publishes telemetry data that is compatible with
[Polkadot Telemetry](https://github.com/paritytech/substrate-telemetry) and
[its helpful UI](https://telemetry.polkadot.io/).
3 changes: 0 additions & 3 deletions dot/core/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ var (
// ErrEmptyRuntimeCode is returned when the storage :code is empty
ErrEmptyRuntimeCode = errors.New("new :code is empty")

// ErrNilDigestHandler is returned when the DigestHandler interface is nil
ErrNilDigestHandler = errors.New("cannot have nil DigestHandler")

errNilCodeSubstitutedState = errors.New("cannot have nil CodeSubstitutedStat")
)

Expand Down
5 changes: 0 additions & 5 deletions dot/core/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"path/filepath"
"testing"

"github.com/ChainSafe/gossamer/dot/digest"
"github.com/ChainSafe/gossamer/dot/network"
"github.com/ChainSafe/gossamer/dot/state"
"github.com/ChainSafe/gossamer/internal/log"
Expand All @@ -32,10 +31,6 @@ func NewTestService(t *testing.T, cfg *Config) *Service {
cfg = &Config{}
}

if cfg.DigestHandler == nil {
cfg.DigestHandler = &digest.Handler{} // only for nil check in NewService
}

if cfg.Keystore == nil {
cfg.Keystore = keystore.NewGlobalKeystore()
kp, err := sr25519.GenerateKeypair()
Expand Down
7 changes: 1 addition & 6 deletions dot/core/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/ChainSafe/gossamer/lib/transaction"
)

//go:generate mockgen -destination=mock_core_test.go -package $GOPACKAGE . BlockState,StorageState,TransactionState,Network,EpochState,CodeSubstitutedState,DigestHandler
//go:generate mockgen -destination=mock_core_test.go -package $GOPACKAGE . BlockState,StorageState,TransactionState,Network,EpochState,CodeSubstitutedState

// BlockState interface for block state methods
type BlockState interface {
Expand Down Expand Up @@ -87,8 +87,3 @@ type CodeSubstitutedState interface {
LoadCodeSubstitutedBlockHash() common.Hash
StoreCodeSubstitutedBlockHash(hash common.Hash) error
}

// DigestHandler is the interface for the consensus digest handler
type DigestHandler interface {
HandleDigests(header *types.Header)
}
8 changes: 0 additions & 8 deletions dot/core/messages_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ func TestService_HandleBlockProduced(t *testing.T) {
Keystore: keystore.NewGlobalKeystore(),
}

digestHandler := NewMockDigestHandler(ctrl)
digestHandler.EXPECT().HandleDigests(gomock.AssignableToTypeOf(new(types.Header)))
cfg.DigestHandler = digestHandler

s := NewTestService(t, cfg)
err := s.Start()
require.NoError(t, err)
Expand Down Expand Up @@ -137,9 +133,6 @@ func TestService_HandleTransactionMessage(t *testing.T) {
telemetryMock := NewMockClient(ctrl)
telemetryMock.EXPECT().SendMessage(gomock.Any()).AnyTimes()

digestHandler := NewMockDigestHandler(ctrl)
digestHandler.EXPECT().HandleDigests(gomock.AssignableToTypeOf(new(types.Header)))

net := NewMockNetwork(ctrl)
net.EXPECT().GossipMessage(gomock.AssignableToTypeOf(new(network.TransactionMessage))).AnyTimes()
net.EXPECT().IsSynced().Return(true).AnyTimes()
Expand All @@ -151,7 +144,6 @@ func TestService_HandleTransactionMessage(t *testing.T) {
cfg := &Config{
Keystore: ks,
TransactionState: state.NewTransactionState(telemetryMock),
DigestHandler: digestHandler,
Network: net,
}

Expand Down
37 changes: 1 addition & 36 deletions dot/core/mock_core_test.go

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

10 changes: 0 additions & 10 deletions dot/core/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ type Service struct {
storageState StorageState
transactionState TransactionState
net Network
digestHandler DigestHandler

// map of code substitutions keyed by block hash
codeSubstitute map[common.Hash]string
Expand All @@ -71,7 +70,6 @@ type Config struct {
Network Network
Keystore *keystore.GlobalKeystore
Runtime runtime.Instance
DigestHandler DigestHandler

CodeSubstitutes map[common.Hash]string
CodeSubstitutedState CodeSubstitutedState
Expand All @@ -96,10 +94,6 @@ func NewService(cfg *Config) (*Service, error) {
return nil, ErrNilNetwork
}

if cfg.DigestHandler == nil {
return nil, ErrNilDigestHandler
}

if cfg.CodeSubstitutedState == nil {
return nil, errNilCodeSubstitutedState
}
Expand All @@ -121,7 +115,6 @@ func NewService(cfg *Config) (*Service, error) {
blockAddCh: blockAddCh,
codeSubstitute: cfg.CodeSubstitutes,
codeSubstitutedState: cfg.CodeSubstitutedState,
digestHandler: cfg.DigestHandler,
}

return srv, nil
Expand Down Expand Up @@ -218,9 +211,6 @@ func (s *Service) handleBlock(block *types.Block, state *rtstorage.TrieState) er
logger.Debugf("imported block %s and stored state trie with root %s",
block.Header.Hash(), state.MustRoot())

// handle consensus digests
s.digestHandler.HandleDigests(&block.Header)

rt, err := s.blockState.GetRuntime(&block.Header.ParentHash)
if err != nil {
return err
Expand Down
7 changes: 0 additions & 7 deletions dot/core/service_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,6 @@ func TestAnnounceBlock(t *testing.T) {
Network: net,
}

digestHandler := NewMockDigestHandler(ctrl)
digestHandler.EXPECT().HandleDigests(gomock.AssignableToTypeOf(new(types.Header)))
cfg.DigestHandler = digestHandler

s := NewTestService(t, cfg)
err := s.Start()
require.NoError(t, err)
Expand Down Expand Up @@ -583,9 +579,6 @@ func TestService_GetRuntimeVersion(t *testing.T) {
func TestService_HandleSubmittedExtrinsic(t *testing.T) {
cfg := &Config{}
ctrl := gomock.NewController(t)
digestHandler := NewMockDigestHandler(ctrl)
digestHandler.EXPECT().HandleDigests(gomock.AssignableToTypeOf(new(types.Header)))
cfg.DigestHandler = digestHandler

net := NewMockNetwork(ctrl)
net.EXPECT().GossipMessage(gomock.AssignableToTypeOf(new(network.TransactionMessage)))
Expand Down
Loading

0 comments on commit d894db6

Please sign in to comment.