Skip to content

Commit

Permalink
[move] account primitives to track abandoned property (#324)
Browse files Browse the repository at this point in the history
Co-authored-by: 0o-de-lally <[email protected]>
  • Loading branch information
sirouk and 0o-de-lally authored Jan 8, 2025
1 parent 362ea77 commit ecb415d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,6 @@ jobs:
# size and performance optimized binary with profile.cli
run: cargo b --release -p libra

# release bin
- name: libra publish
if: ${{ !contains(github.ref, 'ci-bins') }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/release/libra
tag: ${{ github.ref }}
overwrite: true
file_glob: true

# CI bin
- name: libra publish
if: ${{ contains(github.ref, 'ci-bins') }}
Expand Down
26 changes: 26 additions & 0 deletions framework/libra-framework/sources/ol_sources/activity.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

/// Maintains the version number for the blockchain.
module ol_framework::activity {
use std::signer;

friend diem_framework::transaction_validation;

struct Activity has key {
timestamp: u64,
}

fun lazy_initialize(user: &signer, timestamp: u64) {
if (!exists<Activity>(signer::address_of(user))) {
move_to<Activity>(user, Activity {
timestamp
})
}
}
public(friend) fun increment(user: &signer, timestamp: u64) acquires Activity {
lazy_initialize(user, timestamp);

let state = borrow_global_mut<Activity>(signer::address_of(user));
state.timestamp = timestamp;

}
}
10 changes: 7 additions & 3 deletions framework/libra-framework/sources/transaction_validation.move
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ module diem_framework::transaction_validation {
use std::vector;

use diem_framework::account;
// use diem_framework::diem_coin::DiemCoin;
use ol_framework::libra_coin::{Self, LibraCoin};
use diem_framework::chain_id;
use diem_framework::coin;
use diem_framework::system_addresses;
use diem_framework::timestamp;
use diem_framework::transaction_fee;

use ol_framework::libra_coin::{Self, LibraCoin};
use ol_framework::activity;
// use diem_std::debug::print;

friend diem_framework::genesis;
Expand Down Expand Up @@ -75,8 +75,9 @@ module diem_framework::transaction_validation {
txn_expiration_time: u64,
chain_id: u8,
) {
let time = timestamp::now_seconds();
assert!(
timestamp::now_seconds() < txn_expiration_time,
time < txn_expiration_time,
error::invalid_argument(PROLOGUE_ETRANSACTION_EXPIRED),
);
assert!(chain_id::get() == chain_id, error::invalid_argument(PROLOGUE_EBAD_CHAIN_ID));
Expand Down Expand Up @@ -113,6 +114,8 @@ module diem_framework::transaction_validation {
);
let balance = libra_coin::balance(transaction_sender);
assert!(balance >= max_transaction_fee, error::invalid_argument(PROLOGUE_ECANT_PAY_GAS_DEPOSIT));

activity::increment(&sender, time);
}

fun module_prologue(
Expand Down Expand Up @@ -204,6 +207,7 @@ module diem_framework::transaction_validation {
// later redistribution.
transaction_fee::collect_fee(addr, transaction_fee_amount);
};

// Increment sequence number
account::increment_sequence_number(addr);
}
Expand Down

0 comments on commit ecb415d

Please sign in to comment.