Skip to content

Commit 503c6a8

Browse files
authored
Merge branch 'main' into remove-pre-commit-hooks
2 parents 4955e78 + 6b91983 commit 503c6a8

File tree

17 files changed

+279
-137
lines changed

17 files changed

+279
-137
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Description
2+
3+
Please include a summary of the changes and the related issue.
4+
Please also include relevant motivation and context.
5+
List any dependencies that are required for this change.
6+
7+
Fixes # (issue) _if applicable_
8+
9+
## Type of change
10+
11+
Please delete options that are not relevant.
12+
13+
- [ ] Bug fix (non-breaking change which fixes an issue)
14+
- [ ] New feature (non-breaking change which adds functionality)
15+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
16+
- [ ] This change requires a documentation update
17+
18+
## How Has This Been Tested?
19+
20+
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.
21+
Please also list any relevant details for your test configuration
22+
23+
- [ ] Test A
24+
- [ ] Test B
25+
26+
**Test Configuration**: _if applicable_
27+
28+
* Firmware version:
29+
* Hardware:
30+
* Toolchain:
31+
* SDK:
32+
33+
## Checklist:
34+
35+
- [ ] My code follows the style guidelines of this project
36+
- [ ] I have performed a self-review of my code
37+
- [ ] I have commented my code, particularly in hard-to-understand areas
38+
- [ ] I have made corresponding changes to the documentation
39+
- [ ] My changes generate no new warnings
40+
- [ ] I have added tests that prove my fix is effective or that my feature works
41+
- [ ] New and existing unit tests pass locally with my changes
42+
- [ ] Any dependent changes have been merged and published in downstream modules

.github/workflows/nix.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ concurrency:
2626
group: ${{ github.sha }}
2727
cancel-in-progress: true
2828

29+
env:
30+
ECR_REGISTRY: 432820653916.dkr.ecr.eu-central-1.amazonaws.com
31+
S3_CACHE: s3://iog-catalyst-nix-cache?region=eu-central-1
32+
2933
jobs:
3034
discover:
3135
outputs:
@@ -47,11 +51,13 @@ jobs:
4751
name: ${{ matrix.target.cell }} - ${{ matrix.target.name }}
4852
runs-on: ubuntu-latest
4953
steps:
50-
- run: |
51-
config="$HOME/.docker/config.json"
52-
mkdir -p "${config%/*}"
53-
jq -n --arg token "${{ secrets.DOCKER_AUTH_TOKEN }}" '{ "auths": { "registry.ci.iog.io": { auth: $token } } }' > "$config"
54-
chmod 0600 "$config"
54+
- name: Configure Registry
55+
run: |
56+
aws ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin "${{ env.ECR_REGISTRY }}"
57+
env:
58+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
59+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
60+
AWS_DEFAULT_REGION: eu-central-1
5561
- uses: divnix/std-action/run@main
5662
with:
5763
extra_nix_config: |
@@ -60,7 +66,7 @@ jobs:
6066
nix_key: ${{ secrets.NIX_SIGNING_KEY }}
6167
s3_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
6268
s3_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
63-
cache: s3://iog-catalyst-cache?region=eu-central-1
69+
cache: ${{ env.S3_CACHE }}
6470
build-packages:
6571
if: always()
6672
needs:
@@ -81,7 +87,7 @@ jobs:
8187
nix_key: ${{ secrets.NIX_SIGNING_KEY }}
8288
s3_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
8389
s3_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
84-
cache: s3://iog-catalyst-cache?region=eu-central-1
90+
cache: ${{ env.S3_CACHE }}
8591
build-devshells:
8692
if: always()
8793
needs:
@@ -102,4 +108,4 @@ jobs:
102108
nix_key: ${{ secrets.NIX_SIGNING_KEY }}
103109
s3_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
104110
s3_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
105-
cache: s3://iog-catalyst-cache?region=eu-central-1
111+
cache: ${{ env.S3_CACHE }}

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
nixConfig = {
7676
extra-substituters = [
7777
"https://cache.iog.io"
78-
"https://iog-catalyst-cache.s3.eu-central-1.amazonaws.com"
78+
"https://iog-catalyst-nix-cache.s3.eu-central-1.amazonaws.com"
7979
];
8080
extra-trusted-public-keys = [
8181
"hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="

nix/jormungandr/containers.nix

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
inherit (inputs.cells.lib) constants;
77
l = nixpkgs.lib // builtins;
88

9-
mkOCI = name: namespace:
9+
mkOCI = name: let
10+
operable = cell.operables.${name};
11+
in
1012
std.lib.ops.mkStandardOCI {
11-
name = "${constants.registry}/${name}-${namespace}";
12-
operable = cell.operables."${name}-${namespace}";
13+
inherit operable;
14+
name = "${constants.registry}/${name}";
1315
debug = true;
1416
};
15-
in
16-
{}
17-
// constants.mapToNamespaces {prefix = "jormungandr";} (mkOCI "jormungandr")
17+
in {
18+
jormungandr = mkOCI "jormungandr";
19+
}

nix/jormungandr/operables.nix

Lines changed: 57 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -7,70 +7,68 @@
77
inherit (inputs.cells.lib) constants;
88
l = nixpkgs.lib // builtins;
99

10-
mkOperable = package: namespace: let
11-
artifacts' = artifacts."artifacts-${namespace}";
12-
in
13-
std.lib.ops.mkOperable {
14-
inherit package;
15-
# TODO: Remove all the bitte stuff
16-
runtimeScript = ''
17-
ulimit -n 1024
10+
package = cell.packages.jormungandr;
11+
in {
12+
jormungandr = std.lib.ops.mkOperable {
13+
inherit package;
14+
# TODO: Remove all the bitte stuff
15+
# TODO: update artifact path to correct mount path
16+
runtimeScript = ''
17+
ulimit -n 1024
1818
19-
nodeConfig="$NOMAD_TASK_DIR/node-config.json"
20-
runConfig="$NOMAD_TASK_DIR/running.json"
21-
runYaml="$NOMAD_TASK_DIR/running.yaml"
19+
nodeConfig="$NOMAD_TASK_DIR/node-config.json"
20+
runConfig="$NOMAD_TASK_DIR/running.json"
21+
runYaml="$NOMAD_TASK_DIR/running.yaml"
2222
23-
chmod u+rwx -R "$NOMAD_TASK_DIR" || true
23+
chmod u+rwx -R "$NOMAD_TASK_DIR" || true
2424
25-
function convert () {
26-
chmod u+rwx -R "$NOMAD_TASK_DIR" || true
27-
cp "$nodeConfig" "$runConfig"
28-
remarshal --if json --of yaml "$runConfig" > "$runYaml"
29-
}
25+
function convert () {
26+
chmod u+rwx -R "$NOMAD_TASK_DIR" || true
27+
cp "$nodeConfig" "$runConfig"
28+
remarshal --if json --of yaml "$runConfig" > "$runYaml"
29+
}
3030
31-
if [ "$RESET" = "true" ]; then
32-
echo "RESET is given, will start from scratch..."
33-
rm -rf "$STORAGE_DIR"
34-
elif [ -d "$STORAGE_DIR" ]; then
35-
echo "$STORAGE_DIR found, not restoring from backup..."
36-
else
37-
echo "$STORAGE_DIR not found, restoring backup..."
31+
if [ "$RESET" = "true" ]; then
32+
echo "RESET is given, will start from scratch..."
33+
rm -rf "$STORAGE_DIR"
34+
elif [ -d "$STORAGE_DIR" ]; then
35+
echo "$STORAGE_DIR found, not restoring from backup..."
36+
else
37+
echo "$STORAGE_DIR not found, restoring backup..."
3838
39-
restic restore latest \
40-
--verbose=5 \
41-
--no-lock \
42-
--tag "$NAMESPACE" \
43-
--target / \
44-
|| echo "couldn't restore backup, continue startup procedure..."
45-
fi
39+
restic restore latest \
40+
--verbose=5 \
41+
--no-lock \
42+
--tag "$NAMESPACE" \
43+
--target / \
44+
|| echo "couldn't restore backup, continue startup procedure..."
45+
fi
4646
47-
set +x
48-
echo "waiting for $REQUIRED_PEER_COUNT peers"
49-
until [ "$(jq -e -r '.p2p.trusted_peers | length' < "$nodeConfig" || echo 0)" -ge "$REQUIRED_PEER_COUNT" ]; do
50-
sleep 1
51-
done
52-
set -x
47+
set +x
48+
echo "waiting for $REQUIRED_PEER_COUNT peers"
49+
until [ "$(jq -e -r '.p2p.trusted_peers | length' < "$nodeConfig" || echo 0)" -ge "$REQUIRED_PEER_COUNT" ]; do
50+
sleep 1
51+
done
52+
set -x
5353
54-
convert
54+
convert
5555
56-
if [ -n "$PRIVATE" ]; then
57-
echo "Running with node with secrets..."
58-
exec jormungandr \
59-
--storage "$STORAGE_DIR" \
60-
--config "$NOMAD_TASK_DIR/running.yaml" \
61-
--genesis-block "${artifacts'}/block0.bin" \
62-
--secret "$NOMAD_SECRETS_DIR/bft-secret.yaml" \
63-
"$@" || true
64-
else
65-
echo "Running with follower node..."
66-
exec jormungandr \
67-
--storage "$STORAGE_DIR" \
68-
--config "$NOMAD_TASK_DIR/running.yaml" \
69-
--genesis-block "${artifacts'}/block0.bin" \
70-
"$@" || true
71-
fi
72-
'';
73-
};
74-
in
75-
{}
76-
// constants.mapToNamespaces {prefix = "jormungandr";} (mkOperable cell.packages.jormungandr)
56+
if [ -n "$PRIVATE" ]; then
57+
echo "Running with node with secrets..."
58+
exec ${l.getExe package} \
59+
--storage "$STORAGE_DIR" \
60+
--config "$NOMAD_TASK_DIR/running.yaml" \
61+
--genesis-block "artifacts/block0.bin" \
62+
--secret "$NOMAD_SECRETS_DIR/bft-secret.yaml" \
63+
"$@" || true
64+
else
65+
echo "Running with follower node..."
66+
exec ${l.getExe package} \
67+
--storage "$STORAGE_DIR" \
68+
--config "$NOMAD_TASK_DIR/running.yaml" \
69+
--genesis-block "artifacts/block0.bin" \
70+
"$@" || true
71+
fi
72+
'';
73+
};
74+
}

nix/lib/constants.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
in rec {
2323
inherit envs events;
2424
namespaces = l.flatten (l.map (event: mkNamespaces event) events);
25-
registry = "registry.ci.iog.io";
25+
registry = "432820653916.dkr.ecr.eu-central-1.amazonaws.com";
2626

2727
mapToNamespaces = {
2828
prefix ? "",

nix/vit-servicing-station/containers.nix

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
inherit (inputs.cells.lib) constants;
77
l = nixpkgs.lib // builtins;
88

9-
mkOCI = name: namespace:
9+
mkOCI = name: let
10+
operable = cell.operables.${name};
11+
in
1012
std.lib.ops.mkStandardOCI {
11-
name = "${constants.registry}/${name}-${namespace}";
12-
operable = cell.operables."${name}-${namespace}";
13+
inherit operable;
14+
name = "${constants.registry}/${name}";
1315
debug = true;
1416
};
15-
in
16-
{}
17-
// constants.mapToNamespaces {prefix = "vit-servicing-station-server";} (mkOCI "vit-servicing-station-server")
17+
in {
18+
vit-servicing-station-server = mkOCI "vit-servicing-station-server";
19+
}

nix/vit-servicing-station/operables.nix

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,24 @@
77
inherit (inputs.cells.lib) constants;
88
l = nixpkgs.lib // builtins;
99

10-
mkVitOperable = package: namespace: let
11-
artifacts' = artifacts."artifacts-${namespace}";
10+
mkSimpleOperable = {
11+
name,
12+
runtimeInputs ? [],
13+
args ? [],
14+
}: let
15+
package = cell.packages.${name};
1216
in
1317
std.lib.ops.mkOperable {
14-
inherit package;
15-
runtimeInputs = [
16-
artifacts'
17-
];
18+
inherit package runtimeInputs;
1819
runtimeScript = std.lib.ops.mkOperableScript {
19-
inherit package;
20-
args = {
21-
"--in-settings-file" = "/local/station-config.json";
22-
};
20+
inherit args package;
2321
};
2422
};
25-
in
26-
{}
27-
// constants.mapToNamespaces {prefix = "vit-servicing-station-server";} (mkVitOperable cell.packages.vit-servicing-station-server)
23+
in {
24+
vit-servicing-station-server = mkSimpleOperable {
25+
name = "vit-servicing-station-server";
26+
args = {
27+
"--in-settings-file" = "/local/station-config.json";
28+
};
29+
};
30+
}

src/chain-wallet-libs/bindings/wallet-core/src/tx_builder.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,47 @@ use chain_impl_mockchain::{
55
header::BlockDate,
66
transaction::{Input, Payload, Transaction},
77
};
8-
use wallet::{EitherAccount, Settings};
8+
use std::{collections::HashMap, str::FromStr};
9+
use wallet::{AccountId, EitherAccount, Settings};
910

1011
use crate::Error;
1112

1213
pub struct TxBuilder<P: Payload> {
1314
builder: wallet::TransactionBuilder<P>,
15+
inputs: HashMap<AccountId, (Input, SpendingCounter)>,
1416
}
1517

1618
impl<P: Payload> TxBuilder<P> {
1719
pub fn new(settings: Settings, valid_until: BlockDate, payload: P) -> Self {
1820
let builder = wallet::TransactionBuilder::new(settings, payload, valid_until);
19-
Self { builder }
21+
Self {
22+
builder,
23+
inputs: HashMap::new(),
24+
}
2025
}
2126

2227
pub fn build_tx(
2328
mut self,
24-
account_bytes: &[u8],
29+
account_id_hex: String,
2530
spending_counter: SpendingCounter,
2631
) -> Result<Self, Error> {
32+
let account_id = AccountId::from_str(&account_id_hex)
33+
.map_err(|e| Error::wallet_transaction().with(e))?;
34+
35+
// It is needed to provide a 1 extra input as we are generating it later, but should take into account at this place.
36+
let value = self.builder.estimate_fee_with(1, 0);
37+
let input = Input::from_account_public_key(account_id.into(), value);
38+
self.inputs.insert(account_id, (input, spending_counter));
39+
Ok(self)
40+
}
41+
42+
pub fn sign_tx(mut self, account_bytes: &[u8]) -> Result<Self, Error> {
2743
let account = EitherAccount::new_from_key(
2844
SecretKey::from_binary(account_bytes)
2945
.map_err(|e| Error::wallet_transaction().with(e))?,
3046
);
31-
// It is needed to provide a 1 extra input as we are generating it later, but should take into account at this place.
32-
let value = self.builder.estimate_fee_with(1, 0);
33-
let input = Input::from_account_public_key(account.account_id().into(), value);
47+
48+
let (input, spending_counter) = self.inputs.get(&account.account_id()).ok_or_else(|| Error::invalid_input("Cannot find corresponded input to the provided account, make sure that you have correctly execute build_tx function first"))?.clone();
3449
let witness_builder = account.witness_builder(spending_counter);
3550
self.builder.add_input(input, witness_builder);
3651
Ok(self)

0 commit comments

Comments
 (0)