Skip to content

Commit

Permalink
Merge #750
Browse files Browse the repository at this point in the history
750: Make genesis file relative to configuration yaml file fix r=Jimbo4350 a=Jimbo4350

Issue
-----------

- #611 

- This PR **results** in breaking changes to upstream dependencies.

Checklist
---------
- [x] This PR contains all the work required to resolve the linked issue.

- [x] I have committed clear and descriptive commits. Be considerate as somebody else will have to read these.

- [x] I have added the appropriate labels to this PR.


Co-authored-by: Jordan Millar <[email protected]>
  • Loading branch information
iohk-bors[bot] and Jimbo4350 authored Apr 6, 2020
2 parents 7d7f667 + ee9ad13 commit c253c30
Show file tree
Hide file tree
Showing 38 changed files with 169 additions and 498 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
/cabal.project.diff
/cabal.project.local
/cabal.project.old
dist-newstyle/
configuration/defaults/simpleview/genesis/
configuration/defaults/liveview/genesis/
/dist-newstyle/
dist/
*~
\#*
Expand Down
59 changes: 53 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ provided as
a [feature](https://github.com/input-output-hk/cardano-shell/blob/master/app/Cardano/Shell/Features/Logging.hs)
by the node shell to the other packages.

- The cardano-node is the top level for the node and
aggregates the other components from other packages: consensus, ledger and
networking, with configuration, CLI, logging and monitoring.

- The node no longer incorporates wallet or explorer functionality. The wallet
backend and explorer backend are separate components that run in separate
external processes that communicate with the node via local IPC.

## How to build

### Stack
Expand Down Expand Up @@ -71,7 +79,7 @@ Usage: cardano-node --topology FILEPATH --database-path FILEPATH

`--port` - Specify which port to assign to the node.

`--config` - Specify the filepath to the config `.yaml` file. This file is responsible for all the other node's required settings. See examples in `configuration` (e.g. `log-config-0.yaml`).
`--config` - Specify the filepath to the config `.yaml` file. This file is responsible for all the other node's required settings. See examples in `configuration` (e.g. [`config-0.yaml`](configuration/defaults/liveview/config-0.yaml)).


## Configuration `.yaml` files
Expand Down Expand Up @@ -173,8 +181,7 @@ Genesis delegation and related concepts are described in detail in:
https://hydra.iohk.io/job/Cardano/cardano-ledger-specs/byronLedgerSpec/latest/download-by-type/doc-pdf/ledger-spec

The canned `scripts/genesis.sh` example provides a nice set of defaults and
illustrates available options. Running it will produce a `./configuration/XXXXX` directory,
where `XXXXX` will be a 5-character prefix of the genesis hash.
illustrates available options.

## Key operations

Expand Down Expand Up @@ -245,15 +252,17 @@ The easiest way to create a transaction is via the `scripts/issue-genesis-utxo-e

`./scripts/issue-genesis-utxo-expenditure.sh transaction_file`

This will run `scripts/genesis.sh` if you do not have a genesis file and will create a tx file with the name `transaction_file`. The script `scripts/issue-genesis-utxo-expenditure.sh` has defaults for all the requirements of the `issue-genesis-utxo-expenditure` command.
NB: This by default creates a transaction based on `configuration/defaults/liveview/config-0.yaml`

If you do not have a `genesis_file` you can run `scripts/genesis.sh` which will create an example `genesis_file` for you. The script `scripts/issue-genesis-utxo-expenditure.sh` has defaults for all the requirements of the `issue-genesis-utxo-expenditure` command.

### Submission

The `submit-tx` subcommand provides the option of submitting a pre-signed
transaction, in its raw wire format (see GenTx for Byron transactions).

The canned `scripts/submit-tx.sh` script will submit the supplied transaction to a testnet
launched by `scripts/shelley-testnet-*.sh` family of scripts.
launched by `scripts/shelley-testnet-liveview.sh` script.

### Issuing UTxO expenditure (genesis and regular)

Expand Down Expand Up @@ -282,7 +291,7 @@ You can query the tip of your local node via the `get-tip` command as follows
1. Open `tmux`
2. Run `cabal build cardano-node`
3. Run `./scripts/shelley-testnet-live.sh`
4. `cabal exec cardano-cli -- get-tip --config configuration/log-config-0.liveview.yaml --socket-path socket/0`
4. `cabal exec cardano-cli -- get-tip --config configuration/defaults/liveview/config-0.yaml --socket-path socket/0`

You will see output from stdout in this format:
```
Expand All @@ -292,6 +301,44 @@ Slot: 6
Block number: 5
```

## Update proposals

There is currently only support to create a Byron update proposal:

```
cardano-cli create-byron-update-proposal --config NODE-CONFIGURATION
--signing-key FILEPATH
--protocol-version-major WORD16
--protocol-version-minor WORD16
--protocol-version-alt WORD8
--application-name STRING
--software-version-num WORD32
--system-tag STRING
--installer-hash HASH
--filepath FILEPATH
...
```
The mandatory arguments are `config`, `signing-key`, `protocol-version-major`, `protocol-version-minor`, `protocol-version-alt`, `application-name`, `software-version-num`, `system-tag`, `installer-hash` and `filepath`.

The remaining arguments are optional parameters you want to update in your update proposal.

You can also check your proposal's validity using the [`validate-cbor`](#validate-cbor-files) command.

See the [Byron specification](https://hydra.iohk.io/job/Cardano/cardano-ledger-specs/byronLedgerSpec/latest/download-by-type/doc-pdf/ledger-spec) for more details on update proposals.

You can submit your proposal using the `submit-byron-update-proposal` command.

Example:
```
cardano-cli submit-byron-update-proposal --config configuration/configuration-mainnet.yaml
--filepath my-update-proposal
--socket-path socket/0
```
The socket path must either be specified as an argument (`--socket-path`) or specified in the supplied config file.

See the [Byron specification](https://hydra.iohk.io/job/Cardano/cardano-ledger-specs/byronLedgerSpec/latest/download-by-type/doc-pdf/ledger-spec) for more deatils on update proposals.


# Development

run *ghcid* with: `ghcid -c "cabal v2-repl exe:cardano-node --reorder-goals"`
Expand Down
20 changes: 7 additions & 13 deletions cardano-config/src/Cardano/Config/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import qualified Data.IP as IP
import qualified Data.Text as T
import Data.Yaml (decodeFileThrow)
import Network.Socket (PortNumber)
import System.Directory (doesFileExist)
import System.FilePath ((</>), takeDirectory)

import qualified Cardano.Chain.Update as Update
Expand Down Expand Up @@ -163,7 +162,7 @@ instance FromJSON NodeConfiguration where
parseJSON = withObject "NodeConfiguration" $ \v -> do
nId <- v .:? "NodeId"
ptcl <- v .: "Protocol" .!= RealPBFT
genFile <- v .: "GenesisFile" .!= "configuration/genesis/genesis.json"
genFile <- v .: "GenesisFile" .!= "genesis/genesis.json"
numCoreNode <- v .:? "NumCoreNodes"
rNetworkMagic <- v .:? "RequiresNetworkMagic" .!= RequiresNoMagic
pbftSignatureThresh <- v .:? "PBftSignatureThreshold"
Expand Down Expand Up @@ -248,20 +247,15 @@ parseNodeConfigurationFP :: ConfigYamlFilePath -> IO NodeConfiguration
parseNodeConfigurationFP (ConfigYamlFilePath fp) = do
nc <- decodeFileThrow fp
let genFile = unGenesisFile $ ncGenesisFile nc
exists <- doesFileExist genFile
case exists of
-- Genesis file is an absolute path
True -> pure nc
-- Genesis file is a relative path (relative to configuration yaml filepath)
False -> do let d = takeDirectory fp
pure $ nc { ncGenesisFile = GenesisFile $ d </> genFile }

-- TODO: Make genesisfile relative to configuration file as above.
-- Make genesis file relative to configuration yaml filepath.
let d = takeDirectory fp
pure $ nc { ncGenesisFile = GenesisFile $ d </> genFile }

parseNodeConfiguration :: NodeProtocolMode -> IO NodeConfiguration
parseNodeConfiguration npm =
case npm of
MockProtocolMode (NodeMockCLI _ _ cy _) -> decodeFileThrow $ unConfigPath cy
RealProtocolMode (NodeCLI _ _ cy _) -> decodeFileThrow $ unConfigPath cy
MockProtocolMode (NodeMockCLI _ _ cy _) -> parseNodeConfigurationFP cy
RealProtocolMode (NodeCLI _ _ cy _) -> parseNodeConfigurationFP cy

-- TODO: we don't want ByronLegacy in Protocol. Let's wrap Protocol with another
-- sum type for cases where it's required.
Expand Down
Loading

0 comments on commit c253c30

Please sign in to comment.