Skip to content

Commit

Permalink
Merge branch 'development' into dependabot/go_modules/github.com/ethe…
Browse files Browse the repository at this point in the history
…reum/go-ethereum-1.10.9
  • Loading branch information
danforbes authored Oct 29, 2021
2 parents 525dac5 + 9c6283e commit 1081f75
Show file tree
Hide file tree
Showing 89 changed files with 1,716 additions and 4,640 deletions.
3 changes: 3 additions & 0 deletions .github/CODE_STYLE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Code style

🚧 work in progress! 🚧
2 changes: 2 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ The [Polkadot Runtime Specification](https://research.web3.foundation/en/latest/

One important distinction is that we are building the Polkadot Runtime Environment, not Polkadot itself. Given that, although a deep understanding of Polkadot is helpful, it's not critical to contribute to gossamer. To help understand how the Runtime Environment relates to Polkadot, check out this [talk that one of our team members gave at DotCon](https://www.youtube.com/watch?v=nYkbYhM5Yfk).

For coding style, you may refer to the [code style](CODE_STYLE.md) document which we keep up to date with coding style conventions we have for this repository.

## Contribution Steps

1. **Fork the gossamer repo.**
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ To start the polkadot node:

## Contribute

- Check out [Contributing Guidelines](.github/CONTRIBUTING.md)
- Check out [Contributing Guidelines](.github/CONTRIBUTING.md) and our [code style](.github/CODE_STYLE.md) document
- Have questions? Say hi on [Discord](https://discord.gg/Xdc5xjE)!

## Donate
Expand Down
4 changes: 0 additions & 4 deletions docs/docs/getting-started/overview/package-library.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ Gossamer packages can be categorized into **four package types**:

- the **runtime package** contains various wasm interpreters used to interpret the runtime. It currently contains `life` and `wasmer`; however, `wasmer` is the only interpreter that is fully supported at the moment. In the future, all interpreters will be fully supported.

#### `lib/scale`

- the **scale package** implements the SCALE codec.

#### `lib/services`

- the **services package** implements a common interface for node services.
Expand Down
4 changes: 3 additions & 1 deletion dot/core/messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ func TestService_HandleBlockProduced(t *testing.T) {

// simulate block sent from BABE session
digest := types.NewDigest()
err = digest.Add(*types.NewBabeSecondaryPlainPreDigest(0, 1).ToPreRuntimeDigest())
prd, err := types.NewBabeSecondaryPlainPreDigest(0, 1).ToPreRuntimeDigest()
require.NoError(t, err)
err = digest.Add(*prd)
require.NoError(t, err)

newBlock := types.Block{
Expand Down
13 changes: 7 additions & 6 deletions dot/core/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ func (s *Service) GetMetadata(bhash *common.Hash) ([]byte, error) {
// QueryStorage returns the key-value data by block based on `keys` params
// on every block starting `from` until `to` block, if `to` is not nil
func (s *Service) QueryStorage(from, to common.Hash, keys ...string) (map[common.Hash]QueryKeyValueChanges, error) {
if to == common.EmptyHash {
if to.IsEmpty() {
to = s.blockState.BestBlockHash()
}

Expand Down Expand Up @@ -606,19 +606,20 @@ func (s *Service) tryQueryStorage(block common.Hash, keys ...string) (QueryKeyVa

// GetReadProofAt will return an array with the proofs for the keys passed as params
// based on the block hash passed as param as well, if block hash is nil then the current state will take place
func (s *Service) GetReadProofAt(block common.Hash, keys [][]byte) (common.Hash, [][]byte, error) {
if common.EmptyHash.Equal(block) {
func (s *Service) GetReadProofAt(block common.Hash, keys [][]byte) (
hash common.Hash, proofForKeys [][]byte, err error) {
if block.IsEmpty() {
block = s.blockState.BestBlockHash()
}

stateRoot, err := s.blockState.GetBlockStateRoot(block)
if err != nil {
return common.EmptyHash, nil, err
return hash, nil, err
}

proofForKeys, err := s.storageState.GenerateTrieProof(stateRoot, keys)
proofForKeys, err = s.storageState.GenerateTrieProof(stateRoot, keys)
if err != nil {
return common.EmptyHash, nil, err
return hash, nil, err
}

return block, proofForKeys, nil
Expand Down
12 changes: 7 additions & 5 deletions dot/core/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ func TestAnnounceBlock(t *testing.T) {

// simulate block sent from BABE session
digest := types.NewDigest()
err = digest.Add(*types.NewBabeSecondaryPlainPreDigest(0, 1).ToPreRuntimeDigest())
prd, err := types.NewBabeSecondaryPlainPreDigest(0, 1).ToPreRuntimeDigest()
require.NoError(t, err)
err = digest.Add(*prd)
require.NoError(t, err)

newBlock := types.Block{
Expand Down Expand Up @@ -815,7 +817,7 @@ func TestGetReadProofAt(t *testing.T) {
storageState: mockStorageStage,
}

b, p, err := s.GetReadProofAt(common.EmptyHash, keysToProof)
b, p, err := s.GetReadProofAt(common.Hash{}, keysToProof)
require.NoError(t, err)
require.Equal(t, p, mockedProofs)
require.Equal(t, expectedBlockHash, b)
Expand All @@ -830,14 +832,14 @@ func TestGetReadProofAt(t *testing.T) {

mockBlockState := new(mocks.BlockState)
mockBlockState.On("GetBlockStateRoot", mockedBlockHash).
Return(common.EmptyHash, errors.New("problems while getting state root"))
Return(common.Hash{}, errors.New("problems while getting state root"))

s := &Service{
blockState: mockBlockState,
}

b, p, err := s.GetReadProofAt(mockedBlockHash, keysToProof)
require.Equal(t, common.EmptyHash, b)
require.True(t, b.IsEmpty())
require.Nil(t, p)
require.Error(t, err)
})
Expand All @@ -860,7 +862,7 @@ func TestGetReadProofAt(t *testing.T) {
}

b, p, err := s.GetReadProofAt(mockedBlockHash, keysToProof)
require.Equal(t, common.EmptyHash, b)
require.True(t, b.IsEmpty())
require.Nil(t, p)
require.Error(t, err)
})
Expand Down
11 changes: 8 additions & 3 deletions dot/digest/digest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,19 @@ func TestHandler_HandleBABEOnDisabled(t *testing.T) {
}

func createHeaderWithPreDigest(t *testing.T, slotNumber uint64) *types.Header {
babeHeader := types.NewBabePrimaryPreDigest(0, slotNumber, [32]byte{}, [64]byte{})
t.Helper()

enc := babeHeader.Encode()
babeHeader := types.NewBabeDigest()
err := babeHeader.Set(*types.NewBabePrimaryPreDigest(0, slotNumber, [32]byte{}, [64]byte{}))
require.NoError(t, err)

enc, err := scale.Marshal(babeHeader)
require.NoError(t, err)
d := &types.PreRuntimeDigest{
Data: enc,
}
digest := types.NewDigest()
err := digest.Add(*d)
err = digest.Add(*d)
require.NoError(t, err)

return &types.Header{
Expand Down
Loading

0 comments on commit 1081f75

Please sign in to comment.