Skip to content

Commit

Permalink
Merge branch 'master' into command-outout-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessio Treglia authored Apr 17, 2021
2 parents 541f44f + b4fc48c commit 9a60bda
Show file tree
Hide file tree
Showing 21 changed files with 665 additions and 32 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/check-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Check docs build
# This workflow runs when a PR is labeled with `docs`
# This will check if the docs build successfully by running `npm run build`
on:
pull_request:
types: [ labeled ]

jobs:
check-docs-build:
if: ${{ github.event.label.name == 'docs' }}

name: Check docs build
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2.3.1
with:
persist-credentials: false
fetch-depth: 0

- name: Install dependencies and build docs 🧱
run: |
cd docs
npm install
npm run build
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [\#8786](https://github.com/cosmos/cosmos-sdk/pull/8786) Enabled secp256r1 in x/auth.
* (rosetta) [\#8729](https://github.com/cosmos/cosmos-sdk/pull/8729) Data API fully supports balance tracking. Construction API can now construct any message supported by the application.
* [\#8754](https://github.com/cosmos/cosmos-sdk/pull/8875) Added support for reverse iteration to pagination.
* [#9088](https://github.com/cosmos/cosmos-sdk/pull/9088) Added implementation to ADR-28 Derived Addresses.

### Client Breaking Changes
* [\#8363](https://github.com/cosmos/cosmos-sdk/pull/8363) Addresses no longer have a fixed 20-byte length. From the SDK modules' point of view, any 1-255 bytes-long byte array is a valid address.
Expand Down Expand Up @@ -83,6 +84,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/bank) [\#8798](https://github.com/cosmos/cosmos-sdk/pull/8798) `GetTotalSupply` is removed in favour of `GetPaginatedTotalSupply`
* (x/bank/types) [\#9061](https://github.com/cosmos/cosmos-sdk/pull/9061) `AddressFromBalancesStore` now returns an error for invalid key instead of panic.



### State Machine Breaking

* (x/{bank,distrib,gov,slashing,staking}) [\#8363](https://github.com/cosmos/cosmos-sdk/issues/8363) Store keys have been modified to allow for variable-length addresses.
Expand Down
24 changes: 12 additions & 12 deletions docs/architecture/adr-028-public-key-addresses.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ type Addressable interface {
Address() []byte
}

func NewComposed(typ string, subaccounts []Addressable) []byte {
func Composed(typ string, subaccounts []Addressable) []byte {
addresses = map(subaccounts, \a -> LengthPrefix(a.Address()))
addresses = sort(addresses)
return address.Hash(typ, addresses[0] + ... + addresses[n])
Expand Down Expand Up @@ -175,7 +175,7 @@ func (multisig PubKey) Address() {
prefix := fmt.Sprintf("%s/%d", proto.MessageName(multisig), multisig.Threshold)

// use the Composed function defined above
return address.NewComposed(prefix, keys)
return address.Composed(prefix, keys)
}
```

Expand All @@ -185,14 +185,14 @@ NOTE: this section is not finalize and it's in active discussion.

In Basic Address section we defined a module account address as:

```
```go
address.Hash("module", moduleName)
```

We use `"module"` as a schema type for all module derived addresses. Module accounts can have sub accounts. The derivation process has a defined order: module name, submodule key, subsubmodule key.
Module account addresses are heavily used in the SDK so it makes sense to optimize the derivation process: instead of using of using `LengthPrefix` for the module name, we use a null byte (`'\x00'`) as a separator. This works, because null byte is not a part of a valid module name.

```
```go
func Module(moduleName string, key []byte) []byte{
return Hash("module", []byte(moduleName) + 0 + key)
}
Expand All @@ -208,24 +208,24 @@ If we want to create an address for a module account depending on more than one
btcAtomAMM := address.Module("amm", btc.Addrress() + atom.Address()})
```

We can continue the derivation process and can create an address for a submodule account.
#### Derived Addresses

```
func Submodule(address []byte, derivationKey []byte) {
return Hash("module", address + derivationKey)
We must be able to cryptographically derive one address from another one. The derivation process must guarantee hash properties, hence we use the already defined `Hash` function:

```go
func Derive(address []byte, derivationKey []byte) []byte {
return Hash(addres, derivationKey)
}
```

NOTE: if `address` is not a hash based address (with `LEN` length) then we should use `LengthPrefix`. An alternative would be to use one `Module` function, which takes a slice of keys and mapped with `LengthPrefix`. For final version we need to validate what's the most common use.

Note: `Module` is a special case of the more general _derived_ address, where we set the `"module"` string for the _from address_.

**Example** For a cosmwasm smart-contract address we could use the following construction:
```
smartContractAddr := Submodule(Module("cosmwasm", smartContractsNamespace), smartContractKey)
smartContractAddr := Derived(Module("cosmwasm", smartContractsNamespace), []{smartContractKey})
```



### Schema Types

A `typ` parameter used in `Hash` function SHOULD be unique for each account type.
Expand Down
2 changes: 1 addition & 1 deletion docs/building-modules/msg-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ This method takes care of marshaling the `res` parameter to protobuf and attachi

This diagram shows a typical structure of an `Msg` Service, and how the message propagates through the module.

![](../uml/transaction_flow.svg)
![Transaction flow](../uml/svg/transaction_flow.svg)

## Legacy Amino `Msg`s

Expand Down
2 changes: 1 addition & 1 deletion docs/core/ocap.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ gaia app.

The following diagram shows the current dependencies between keepers.

![](../uml/keeper_dependencies.svg)
![Keeper dependencies](../uml/svg/keeper_dependencies.svg)

## Next {hide}

Expand Down
2 changes: 0 additions & 2 deletions docs/pre.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ for D in ../x/*; do
done

cat ../x/README.md | sed 's/\.\/x/\/modules/g' | sed 's/spec\/README.md//g' | sed 's/\.\.\/docs\/building-modules\/README\.md/\/building-modules\/intro\.html/g' > ./modules/README.md

# plantuml -tsvg uml/*.puml
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
What happens after a transaction is unmarshalled and is processed by the SDK?

@startuml
'https://plantuml.com/sequence-diagram

Expand Down
File renamed without changes.
106 changes: 106 additions & 0 deletions docs/uml/svg/begin_redelegation_sequence.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
192 changes: 192 additions & 0 deletions docs/uml/svg/delegation_sequence.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9a60bda

Please sign in to comment.