Skip to content

Commit

Permalink
Merge branch 'develop' into feat/116/demo-polka-storage-provider-dock…
Browse files Browse the repository at this point in the history
…erfile
  • Loading branch information
aidan46 authored Jul 9, 2024
2 parents cdb9f78 + 8024fa7 commit 011fc35
Show file tree
Hide file tree
Showing 11 changed files with 783 additions and 378 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
.AppleDouble
.LSOverride
.idea
.vscode
.vscode/*
# For team-wide VS Code configuration, like code-coverage extensions and previews
!.vscode/settings.json
# Recommended extensions for VS Code
!.vscode/extensions.json

# Rust .gitignore
# https://github.com/github/gitignore/blob/main/Rust.gitignore
Expand All @@ -21,3 +25,6 @@ target/

# reproducible local environment
.direnv

# code coverage
coverage/
14 changes: 14 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"recommendations": [
// Rust language support
"rust-lang.rust-analyzer",
// Justfile
"nefrob.vscode-just-syntax",
// TOML support
"tamasfe.even-better-toml",
// Code Coverage display inline, next to the code
"ryanluker.vscode-coverage-gutters",
// direnv, to use tool binaries from `nix` profile and set environment variables automatically
"mkhl.direnv",
]
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"coverage-gutters.coverageBaseDir": "coverage",
"coverage-gutters.coverageFileNames": [
"pallet-market.lcov.info",
"mater.lcov.info"
]
}
8 changes: 6 additions & 2 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
- [nix](https://nixos.org/download/) with [flakes](https://nixos.wiki/wiki/flakes) enabled (`echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf`)
- reasoning: every developer has the same version of development tools (rust, protoc, zombienet), directed by [flake.nix](./flake.nix)`.
- how it works? fasterthanli.me has [a whole series on it](https://fasterthanli.me/series/building-a-rust-service-with-nix/part-10).
- optional: [vscode extension for Nix](https://marketplace.visualstudio.com/items?itemName=jnoortheen.nix-ide)
- [direnv](https://direnv.net/) with a [shell hook](https://direnv.net/docs/hook.html)
- *VS Code only* [direnv extension](https://marketplace.visualstudio.com/items?itemName=mkhl.direnv) (uses the same tooling as rust-toolchain.toml defined).
- reasoning: when you enter a directory it uses everything defined in [.envrc](./.envrc), e.g. environment variables, `nix`, secrets.
- [cargo-llvm-cov](llvm coverage generator), produces coverage in `coverage/` directory.

> [!NOTE]
> `.vscode/settings.json` is part of the git repo, please add only necessary and life-saving things there (like Code Coverage configuration).
>
> [Recommended extensions](https://code.visualstudio.com/docs/editor/extension-marketplace#_workspace-recommended-extensions) are also part of the repo in `.vscode/extensions.json`.
## How it works?
Nix is a package manager, which sneakily downloads all of the dependencies and updates PATH when you launch it with `nix develop`.
Expand Down
11 changes: 11 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,14 @@ release: lint
testnet: release
zombienet -p native spawn zombienet/local-testnet.toml

# Must be in sync with .vscode/settings.json and have extension Coverage Gutters to display it in VS Code.
market-coverage:
mkdir -p coverage
cargo llvm-cov -p pallet-market --ignore-filename-regex "(mock|test)"
cargo llvm-cov -p pallet-market report --ignore-filename-regex "(mock|test)" --html --output-dir coverage/pallet-market
cargo llvm-cov -p pallet-market report --ignore-filename-regex "(mock|test)" --lcov --output-path coverage/pallet-market.lcov.info

mater-coverage:
cargo llvm-cov -p mater --ignore-filename-regex "(mock|test)"
cargo llvm-cov -p mater report --ignore-filename-regex "(mock|test)" --html --output-dir coverage/mater
cargo llvm-cov -p mater report --ignore-filename-regex "(mock|test)" --lcov --output-path coverage/mater.lcov.info
12 changes: 6 additions & 6 deletions flake.lock

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

1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
};
rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
buildInputs = with pkgs; [
cargo-llvm-cov
clang
pkg-config
rustToolchain
Expand Down
9 changes: 6 additions & 3 deletions pallets/market/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ pub mod pallet {
ArithmeticError, BoundedBTreeMap, RuntimeDebug,
},
traits::{
tokens::WithdrawReasons,
Currency,
ExistenceRequirement::{AllowDeath, KeepAlive},
Hooks, ReservableCurrency,
Hooks, ReservableCurrency, WithdrawReasons,
},
PalletId,
};
Expand Down Expand Up @@ -1133,7 +1132,11 @@ pub mod pallet {

let mut pending_proposals = PendingProposals::<T>::get();
for sector in sector_deals {
let proposals = Self::proposals_for_deals(sector.deal_ids)?;
let Ok(proposals) = Self::proposals_for_deals(sector.deal_ids) else {
log::error!("failed to find deals for sector: {}", sector.sector_number);
continue;
};

let sector_size = sector.sector_type.sector_size();
if let Err(e) = Self::validate_deals_for_sector(
&proposals,
Expand Down
5 changes: 3 additions & 2 deletions pallets/market/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl crate::Config for Test {
type OffchainPublic = AccountPublic;
type MaxDeals = ConstU32<32>;
type BlocksPerDay = ConstU64<1>;
type MinDealDuration = ConstU64<1>;
type MinDealDuration = ConstU64<2>;
type MaxDealDuration = ConstU64<30>;
type MaxDealsPerBlock = ConstU32<32>;
}
Expand Down Expand Up @@ -84,7 +84,7 @@ pub fn cid_of(data: &str) -> cid::Cid {
pub(crate) type DealProposalOf<T> =
DealProposal<<T as frame_system::Config>::AccountId, BalanceOf<T>, BlockNumberFor<T>>;

type ClientDealProposalOf<T> = ClientDealProposal<
pub(crate) type ClientDealProposalOf<T> = ClientDealProposal<
<T as frame_system::Config>::AccountId,
BalanceOf<T>,
BlockNumberFor<T>,
Expand All @@ -107,6 +107,7 @@ pub const INITIAL_FUNDS: u64 = 100;

/// Build genesis storage according to the mock runtime.
pub fn new_test_ext() -> sp_io::TestExternalities {
let _ = env_logger::try_init();
let mut t = system::GenesisConfig::<Test>::default()
.build_storage()
.unwrap()
Expand Down
Loading

0 comments on commit 011fc35

Please sign in to comment.