Skip to content

Commit

Permalink
Merge branch 'origin/grarco/basic-fee' (#962)
Browse files Browse the repository at this point in the history
* origin/grarco/basic-fee:
  changelog: add #962
  Fixes unit tests
  Fixes process proposal fee token
  Fixes fee value in tx contruction
  Adds fee burning and checks
  changed to 0.12.2
  Namada 0.12.2
  release: cherry-pick release improvements
  changelog: add #952
  prepare_proposal: update comment to reflect hotfix
  prepare_proposal: use TxRecord struct on ABCI++ build
  missed a chain-id addition
  Prioritize wrapper txs during proposal construction
  Hot fix PrepareProposal
  added chain id and fixed install docs
  update pseudocode
  General housekeeping
  Reward distribution: general improvements
  Cubic slashing: general writing improvements
  Cubic slashing: add new improved pseudocode blurb (Rust-style)
  Cubic slashing: clarify slash iteration procedure and equation
  Cubic slashing: fix and improve plot
  quick fix to cubic slash
  changelog: add #911
  changelog: add #876
  test/core: run less cases on `update_epoch_after_its_duration` test
  changelog: add #945
  ci: install cargo-about on release step
  make-package.sh: include license information in tarball
  release: add configuration for cargo-about
  changelog: add #943
  make-package.sh: don't attempt to include matchmaker
  Namada 0.12.1
  changelog: add #942
  vp_verify_masp: avoid panicking unwrap()s
  changed the docker link (again)
  Changed the first header of pages to H1 in 2 occasions in Namada Specs
  Replaced non-breaking space with space to fix faulty formatting
  fix transfer args
  • Loading branch information
tzemanovic committed Dec 28, 2022
2 parents 842bcd5 + db0cac3 commit 02c41e8
Show file tree
Hide file tree
Showing 52 changed files with 434 additions and 217 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/improvements/962-basic-fee.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Added a basic fee implementation for testnet.
([#962](https://github.com/anoma/namada/pull/962))
2 changes: 2 additions & 0 deletions .changelog/unreleased/testing/876-faster-epoch-test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Run fewer cases on update_epoch_after_its_duration, for a faster test suite.
([#876](https://github.com/anoma/namada/pull/876))
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Use the correct options (--gas-amount, --gas-
token) in the ledger_txs_and_queries E2E test.
([#911](https://github.com/anoma/namada/pull/911))
2 changes: 2 additions & 0 deletions .changelog/v0.12.1/bug-fixes/942-vp-verify-masp-failure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Avoid panicking unwrap()s in vp_verify_masp, to prevent crashing the node on
malformed transactions. ([#942](https://github.com/anoma/namada/pull/942))
2 changes: 2 additions & 0 deletions .changelog/v0.12.1/summary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Namada 0.12.1 is a hotfix release, fixing a node crash on malformed
transactions to the MASP.
2 changes: 2 additions & 0 deletions .changelog/v0.12.2/bug-fixes/952-hotfix-prepare-proposal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Limit block space to under Tendermint's limit, and limit transactions included
in a block by their size. ([#952](https://github.com/anoma/namada/pull/952))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Don't attempt to include matchmaker DLLs, which no longer exist, in release
packages. ([#943](https://github.com/anoma/namada/pull/943))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Include license information in release binary tarballs.
([#945](https://github.com/anoma/namada/pull/945))
2 changes: 2 additions & 0 deletions .changelog/v0.12.2/summary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Namada 0.12.2 is a hotfix release, limiting transactions included in a
block by size.
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ jobs:
~/.cargo/git
key: ${{ runner.os }}-namada-release-${{ matrix.namada_cache_version }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-namada-release-${{ matrix.namada_cache_version }}
- name: Install cargo-about
run: |
cargo install --version 0.5.2 cargo-about
- name: Start sccache server
run: sccache --start-server
- name: ${{ matrix.make.name }}
Expand Down
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# CHANGELOG

## v0.12.2

Namada 0.12.2 is a hotfix release, limiting transactions included in a
block by size.

### BUG FIXES

- Limit block space to under Tendermint's limit, and limit transactions included
in a block by their size. ([#952](https://github.com/anoma/namada/pull/952))

### MISCELLANEOUS

- Don't attempt to include matchmaker DLLs, which no longer exist, in release
packages. ([#943](https://github.com/anoma/namada/pull/943))
- Include license information in release binary tarballs.
([#945](https://github.com/anoma/namada/pull/945))

## v0.12.1

Namada 0.12.1 is a hotfix release, fixing a node crash on malformed
transactions to the MASP.

### BUG FIXES

- Avoid panicking unwrap()s in vp_verify_masp, to prevent crashing the node on
malformed transactions. ([#942](https://github.com/anoma/namada/pull/942))

## v0.12.0

Namada 0.12.0 is a scheduled minor release.
Expand Down
20 changes: 10 additions & 10 deletions Cargo.lock

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

22 changes: 22 additions & 0 deletions about.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Third Party Licenses

Overview of licenses:

{{#each overview}}
{{{name}}} ({{count}})
{{/each}}

All license text:

{{#each licenses}}
{{{name}}}

Used by:

{{#each used_by}}
{{crate.name}} {{crate.version}}
<{{#if crate.repository}}{{crate.repository}}{{else}}https://crates.io/crates/{{crate.name}}{{/if}}>
{{/each}}

{{{text}}}
{{/each}}
17 changes: 17 additions & 0 deletions about.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
accepted = [
"MIT",
"0BSD",
"ISC",
"Unlicense",
"BSD-2-Clause",
"BSD-3-Clause",
"CC0-1.0",
"MPL-2.0",
"GPL-3.0",
"OSL-3.0",
"OpenSSL",
"Unicode-DFS-2016",
"Apache-2.0 WITH LLVM-exception",
"Apache-2.0",
"NOASSERTION",
]
2 changes: 1 addition & 1 deletion apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license = "GPL-3.0"
name = "namada_apps"
readme = "../README.md"
resolver = "2"
version = "0.12.0"
version = "0.12.2"
default-run = "namada"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
3 changes: 2 additions & 1 deletion apps/src/lib/client/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use namada::proto::Tx;
use namada::types::address::{Address, ImplicitAddress};
use namada::types::key::*;
use namada::types::storage::Epoch;
use namada::types::token::Amount;
use namada::types::transaction::{hash_tx, Fee, WrapperTx};

use super::rpc;
Expand Down Expand Up @@ -174,7 +175,7 @@ pub async fn sign_wrapper(
let tx = {
WrapperTx::new(
Fee {
amount: args.fee_amount,
amount: Amount::from(100),
token: ctx.get(&args.fee_token),
},
keypair,
Expand Down
109 changes: 102 additions & 7 deletions apps/src/lib/node/ledger/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
use namada::ledger::pos::types::into_tm_voting_power;
use namada::ledger::protocol;
use namada::ledger::storage::write_log::StorageModification;
use namada::ledger::storage_api::StorageRead;
use namada::types::storage::{BlockHash, BlockResults, Header};
use namada::types::token::Amount;

use super::governance::execute_governance_proposals;
use super::*;
Expand Down Expand Up @@ -128,9 +131,80 @@ where
}

let mut tx_event = match &tx_type {
TxType::Wrapper(_wrapper) => {
self.storage.tx_queue.push(_wrapper.clone());
Event::new_tx_event(&tx_type, height.0)
TxType::Wrapper(wrapper) => {
let mut tx_event = Event::new_tx_event(&tx_type, height.0);

// Charge fee
let fee_payer =
if wrapper.pk != address::masp_tx_key().ref_to() {
wrapper.fee_payer()
} else {
address::masp()
};

let balance_key = token::balance_key(
&self.storage.native_token,
&fee_payer,
);
let balance: Amount =
match self.write_log.read(&balance_key).0 {
Some(wal_mod) => {
// Read from WAL
if let StorageModification::Write { value } =
wal_mod
{
Amount::try_from_slice(value).unwrap()
} else {
Amount::default()
}
}
None => {
// Read from storage
let balance = StorageRead::read(
&self.storage,
&balance_key,
);
// Storage read must not fail, but there might
// be no value, in which
// case default (0) is returned
balance
.expect(
"Storage read in the protocol must \
not fail",
)
.unwrap_or_default()
}
};

let balance: u64 = balance.into();
match balance.checked_sub(100) {
Some(v) => {
self.write_log
.write(
&balance_key,
Amount::from(v).try_to_vec().unwrap(),
)
.unwrap();
}
None => {
// Burn remaining funds
self.write_log
.write(
&balance_key,
Amount::from(0).try_to_vec().unwrap(),
)
.unwrap();
tx_event["log"] =
"Insufficient balance for fee".into();
tx_event["code"] = ErrorCodes::InvalidTx.into();

response.events.push(tx_event);
continue;
}
}

self.storage.tx_queue.push(wrapper.clone());
tx_event
}
TxType::Decrypted(inner) => {
// We remove the corresponding wrapper tx from the queue
Expand Down Expand Up @@ -348,15 +422,26 @@ mod test_finalize_block {
let keypair = gen_keypair();
let mut processed_txs = vec![];
let mut valid_wrappers = vec![];

// Add unshielded balance for fee paymenty
let balance_key = token::balance_key(
&shell.storage.native_token,
&Address::from(&keypair.ref_to()),
);
shell
.storage
.write(&balance_key, Amount::from(1000).try_to_vec().unwrap())
.unwrap();

// create some wrapper txs
for i in 1..5 {
for i in 1u64..5 {
let raw_tx = Tx::new(
"wasm_code".as_bytes().to_owned(),
Some(format!("transaction data: {}", i).as_bytes().to_owned()),
);
let wrapper = WrapperTx::new(
Fee {
amount: i.into(),
amount: 100.into(),
token: shell.storage.native_token.clone(),
},
&keypair,
Expand Down Expand Up @@ -529,6 +614,16 @@ mod test_finalize_block {
let mut processed_txs = vec![];
let mut valid_txs = vec![];

// Add unshielded balance for fee paymenty
let balance_key = token::balance_key(
&shell.storage.native_token,
&Address::from(&keypair.ref_to()),
);
shell
.storage
.write(&balance_key, Amount::from(1000).try_to_vec().unwrap())
.unwrap();

// create two decrypted txs
let mut wasm_path = top_level_directory();
wasm_path.push("wasm_for_tests/tx_no_op.wasm");
Expand All @@ -545,7 +640,7 @@ mod test_finalize_block {
);
let wrapper_tx = WrapperTx::new(
Fee {
amount: 0.into(),
amount: 100.into(),
token: shell.storage.native_token.clone(),
},
&keypair,
Expand Down Expand Up @@ -576,7 +671,7 @@ mod test_finalize_block {
);
let wrapper_tx = WrapperTx::new(
Fee {
amount: 0.into(),
amount: 100.into(),
token: shell.storage.native_token.clone(),
},
&keypair,
Expand Down
Loading

0 comments on commit 02c41e8

Please sign in to comment.