Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge feat 2.0 #4321

Merged
merged 18 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
5b5cc67
Added a new field in the block body to keep track of past finality si…
real-felix May 31, 2023
13e1ecb
Fix issues about past_finality_signature
real-felix Jun 1, 2023
c825413
Fix a few comments about past_finality_signatures
real-felix Jun 1, 2023
b2ec438
Merge branch 'feat-2.0' into 3911-past-finality-signature
real-felix Jun 1, 2023
9d03871
JsonBlockBody::past_finality_signatures is a Vec<u8>
real-felix Jun 7, 2023
f8d3040
Sanitize the value of the bits in PastFinalitySignatures::pack
real-felix Jun 8, 2023
799d0ee
Merge pull request #4004 from Boiethios/3911-past-finality-signature
fizyk20 Jun 13, 2023
c8285a0
Populate the PastFinalitySignatures field in the block body
real-felix Jun 8, 2023
d22c2a9
Merge pull request #4044 from Boiethios/3912-populate-finality-signat…
Jun 14, 2023
7300e22
Change the reward scheme to a blocks window instead of a delay
real-felix Jun 16, 2023
d875e3e
Merge pull request #4073 from Boiethios/window-instead-of-lag
AlexanderLimonov Jun 28, 2023
4e12d3b
Allow to query the total supply from the contract runtime
real-felix Aug 25, 2023
6aa5b74
Use `run_query` instead of having a specific query for total_supply
real-felix Aug 29, 2023
a8f5d14
Add the request to read the seignorage rate
real-felix Sep 1, 2023
3a9810f
Merge pull request #4243 from Boiethios/4221-query-total-supply
bradjohnl Sep 4, 2023
0602a26
Merge feat-2.0 feat-signature-rewards
real-felix Sep 27, 2023
bc3fa90
add execution of gossiped blocks
real-felix Oct 12, 2023
e5620ed
Naming and other small fixes
real-felix Oct 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ lint-smart-contracts:

.PHONY: audit-rs
audit-rs:
$(CARGO) audit --ignore RUSTSEC-2022-0093 --ignore RUSTSEC-2023-0044
$(CARGO) audit

.PHONY: audit-as
audit-as:
Expand Down
106 changes: 57 additions & 49 deletions execution_engine/src/engine_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ use casper_types::{
system::{
auction::{
BidAddr, BidKind, EraValidators, UnbondingPurse, ValidatorBid, WithdrawPurse,
ARG_ERA_END_TIMESTAMP_MILLIS, ARG_EVICTED_VALIDATORS, ARG_VALIDATOR,
ARG_ERA_END_TIMESTAMP_MILLIS, ARG_EVICTED_VALIDATORS, ARG_REWARDS_MAP,
ARG_VALIDATOR_PUBLIC_KEYS, AUCTION_DELAY_KEY, ERA_ID_KEY, LOCKED_FUNDS_PERIOD_KEY,
SEIGNIORAGE_RECIPIENTS_SNAPSHOT_KEY, UNBONDING_DELAY_KEY, VALIDATOR_SLOTS_KEY,
},
Expand Down Expand Up @@ -2295,7 +2295,7 @@ where
&self,
pre_state_hash: Digest,
protocol_version: ProtocolVersion,
proposer: PublicKey,
rewards: &BTreeMap<PublicKey, U512>,
next_block_height: u64,
time: u64,
) -> Result<Digest, StepError> {
Expand All @@ -2305,16 +2305,15 @@ where
Ok(Some(tracking_copy)) => Rc::new(RefCell::new(tracking_copy)),
};

let mut runtime_args = RuntimeArgs::new();
runtime_args.insert(ARG_VALIDATOR, proposer)?;

let executor = Executor::new(self.config().clone());

let system_account_addr = PublicKey::System.to_account_hash();
let virtual_system_contract_by_account = {
let system_account_addr = PublicKey::System.to_account_hash();

let virtual_system_contract_by_account = tracking_copy
.borrow_mut()
.get_addressable_entity_by_account_hash(protocol_version, system_account_addr)?;
tracking_copy
.borrow_mut()
.get_addressable_entity_by_account_hash(protocol_version, system_account_addr)?
};

let authorization_keys = {
let mut ret = BTreeSet::new();
Expand All @@ -2331,52 +2330,61 @@ where
DeployHash::new(Digest::hash(&bytes))
};

let distribute_accumulated_fees_stack = self.get_new_system_call_stack();
let system_account_hash = PublicKey::System.to_account_hash();
let (_, execution_result): (Option<()>, ExecutionResult) = executor.call_system_contract(
DirectSystemContractCall::DistributeAccumulatedFees,
RuntimeArgs::default(),
&virtual_system_contract_by_account,
ContractPackageKind::Account(system_account_hash),
authorization_keys.clone(),
system_account_hash,
BlockTime::default(),
deploy_hash,
gas_limit,
protocol_version,
Rc::clone(&tracking_copy),
Phase::Session,
distribute_accumulated_fees_stack,
// There should be no tokens transferred during rewards distribution.
U512::zero(),
);

if let Some(exec_error) = execution_result.take_error() {
return Err(StepError::DistributeAccumulatedFeesError(exec_error));
{
let distribute_accumulated_fees_stack = self.get_new_system_call_stack();
let (_, execution_result): (Option<()>, ExecutionResult) = executor
.call_system_contract(
DirectSystemContractCall::DistributeAccumulatedFees,
RuntimeArgs::default(),
&virtual_system_contract_by_account,
ContractPackageKind::Account(system_account_hash),
authorization_keys.clone(),
system_account_hash,
BlockTime::default(),
deploy_hash,
gas_limit,
protocol_version,
Rc::clone(&tracking_copy),
Phase::Session,
distribute_accumulated_fees_stack,
// There should be no tokens transferred during rewards distribution.
U512::zero(),
);

if let Some(exec_error) = execution_result.take_error() {
return Err(StepError::DistributeAccumulatedFeesError(exec_error));
}
}

let distribute_rewards_stack = self.get_new_system_call_stack();
{
let mut runtime_args = RuntimeArgs::new();
runtime_args.insert(ARG_REWARDS_MAP, rewards)?;
let distribute_rewards_stack = self.get_new_system_call_stack();

let (_, execution_result): (Option<()>, ExecutionResult) = executor.call_system_contract(
DirectSystemContractCall::DistributeRewards,
runtime_args,
&virtual_system_contract_by_account,
ContractPackageKind::Account(system_account_hash),
authorization_keys,
system_account_hash,
BlockTime::default(),
deploy_hash,
gas_limit,
protocol_version,
Rc::clone(&tracking_copy),
Phase::Session,
distribute_rewards_stack,
// There should be no tokens transferred during rewards distribution.
U512::zero(),
);
let (_, execution_result): (Option<()>, ExecutionResult) = executor
.call_system_contract(
DirectSystemContractCall::DistributeRewards,
runtime_args,
&virtual_system_contract_by_account,
ContractPackageKind::Account(system_account_hash),
authorization_keys,
system_account_hash,
BlockTime::default(),
deploy_hash,
gas_limit,
protocol_version,
Rc::clone(&tracking_copy),
Phase::Session,
distribute_rewards_stack,
// There should be no tokens transferred during rewards distribution.
U512::zero(),
);

if let Some(exec_error) = execution_result.take_error() {
return Err(StepError::DistributeError(exec_error));
if let Some(exec_error) = execution_result.take_error() {
return Err(StepError::DistributeError(exec_error));
}
}

let effects = tracking_copy.borrow().effects();
Expand Down
4 changes: 2 additions & 2 deletions execution_engine/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -932,8 +932,8 @@ where
runtime
.context
.charge_gas(auction_costs.distribute.into())?;
let proposer = Self::get_named_argument(runtime_args, auction::ARG_VALIDATOR)?;
runtime.distribute(proposer).map_err(Self::reverter)?;
let rewards = Self::get_named_argument(runtime_args, auction::ARG_REWARDS_MAP)?;
runtime.distribute(rewards).map_err(Self::reverter)?;
CLValue::from_t(()).map_err(Self::reverter)
})(),

Expand Down
Loading
Loading