Skip to content
This repository has been archived by the owner on Jan 27, 2025. It is now read-only.

Commit

Permalink
V5 devnet (#644)
Browse files Browse the repository at this point in the history
* devnet makefile

* ip addresses in devnet fixtures
  • Loading branch information
0o-de-lally authored Aug 24, 2021
1 parent 9bafd2c commit 15e97bd
Show file tree
Hide file tree
Showing 15 changed files with 136 additions and 57 deletions.
67 changes: 35 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ifndef RELEASE
RELEASE=$(shell curl -sL https://api.github.com/repos/OLSF/libra/releases/latest | jq -r '.assets[].browser_download_url')
endif

BINS= db-backup db-backup-verify db-restore libra-node miner ol txs stdlib
BINS= db-backup db-backup-verify db-restore diem-node miner ol txs stdlib



Expand Down Expand Up @@ -79,10 +79,10 @@ uninstall:
done

bins: stdlib
# Build and install genesis tool, libra-node, and miner
# Build and install genesis tool, diem-node, and miner
# NOTE: stdlib is built for cli bindings

cargo build -p libra-node -p miner -p backup-cli -p ol -p txs -p onboard --release
cargo build -p diem-node -p miner -p backup-cli -p ol -p txs -p onboard --release

stdlib:
cargo run --release -p diem-framework
Expand All @@ -94,7 +94,7 @@ install: mv-bin bin-path
mkdir ${USER_BIN_PATH} | true

cp -f ${SOURCE}/target/release/miner ${USER_BIN_PATH}/miner
cp -f ${SOURCE}/target/release/libra-node ${USER_BIN_PATH}/libra-node
cp -f ${SOURCE}/target/release/diem-node ${USER_BIN_PATH}/diem-node
cp -f ${SOURCE}/target/release/db-restore ${USER_BIN_PATH}/db-restore
cp -f ${SOURCE}/target/release/db-backup ${USER_BIN_PATH}/db-backup
cp -f ${SOURCE}/target/release/db-backup-verify ${USER_BIN_PATH}/db-backup-verify
Expand Down Expand Up @@ -137,17 +137,17 @@ init-backend:
curl -X POST -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/orgs/${REPO_ORG}/repos -d '{"name":"${REPO_NAME}", "private": "true", "auto_init": "true"}'

layout:
cargo run -p libra-genesis-tool --release -- set-layout \
cargo run -p diem-genesis-tool --release -- set-layout \
--shared-backend 'backend=github;repository_owner=${REPO_ORG};repository=${REPO_NAME};token=${DATA_PATH}/github_token.txt;namespace=common' \
--path ./ol/util/set_layout_${NODE_ENV}.toml
--path ./ol/devnet/set_layout_${NODE_ENV}.toml

root:
cargo run -p libra-genesis-tool --release -- libra-root-key \
cargo run -p diem-genesis-tool --release -- diem-root-key \
--validator-backend ${LOCAL} \
--shared-backend ${REMOTE}

treasury:
cargo run -p libra-genesis-tool --release -- treasury-compliance-key \
cargo run -p diem-genesis-tool --release -- treasury-compliance-key \
--validator-backend ${LOCAL} \
--shared-backend ${REMOTE}

Expand All @@ -174,42 +174,42 @@ register:
ACC=${ACC}-oper OWNER=${ACC} IP=${IP} make reg

init-test:
echo ${MNEM} | head -c -1 | cargo run -p libra-genesis-tool -- init --path=${DATA_PATH} --namespace=${ACC}
echo ${MNEM} | head -c -1 | cargo run -p diem-genesis-tool -- init --path=${DATA_PATH} --namespace=${ACC}

init:
cargo run -p libra-genesis-tool --release -- init --path=${DATA_PATH} --namespace=${ACC}
cargo run -p diem-genesis-tool --release -- init --path=${DATA_PATH} --namespace=${ACC}
# OWNER does this
# Submits proofs to shared storage
add-proofs:
cargo run -p libra-genesis-tool --release -- mining \
cargo run -p diem-genesis-tool --release -- mining \
--path-to-genesis-pow ${DATA_PATH}/blocks/block_0.json \
--shared-backend ${REMOTE}

# OPER does this
# Submits operator key to github, and creates local OPERATOR_ACCOUNT
oper-key:
cargo run -p libra-genesis-tool --release -- operator-key \
cargo run -p diem-genesis-tool --release -- operator-key \
--validator-backend ${LOCAL} \
--shared-backend ${REMOTE}

# OWNER does this
# Submits operator key to github, does *NOT* create the OWNER_ACCOUNT locally
owner-key:
cargo run -p libra-genesis-tool --release -- owner-key \
cargo run -p diem-genesis-tool --release -- owner-key \
--validator-backend ${LOCAL} \
--shared-backend ${REMOTE}

# OWNER does this
# Links to an operator on github, creates the OWNER_ACCOUNT locally
assign:
cargo run -p libra-genesis-tool --release -- set-operator \
cargo run -p diem-genesis-tool --release -- set-operator \
--operator-name ${OPER} \
--shared-backend ${REMOTE}

# OPER does this
# Submits signed validator registration transaction to github.
reg:
cargo run -p libra-genesis-tool --release -- validator-config \
cargo run -p diem-genesis-tool --release -- validator-config \
--owner-name ${OWNER} \
--chain-id ${CHAIN_ID} \
--validator-address "/ip4/${IP}/tcp/6180" \
Expand All @@ -220,25 +220,25 @@ reg:

# Helpers to verify the local state.
verify:
cargo run -p libra-genesis-tool --release -- verify \
cargo run -p diem-genesis-tool --release -- verify \
--validator-backend ${LOCAL}
# --genesis-path ${DATA_PATH}/genesis.blob

verify-gen:
cargo run -p libra-genesis-tool --release -- verify \
cargo run -p diem-genesis-tool --release -- verify \
--validator-backend ${LOCAL} \
--genesis-path ${DATA_PATH}/genesis.blob


#### GENESIS ####
# build-gen:
# cargo run -p libra-genesis-tool --release -- genesis \
# cargo run -p diem-genesis-tool --release -- genesis \
# --chain-id ${CHAIN_ID} \
# --shared-backend ${REMOTE} \
# --path ${DATA_PATH}/genesis.blob

genesis:
cargo run -p libra-genesis-tool --release -- files \
cargo run -p diem-genesis-tool --release -- files \
--chain-id ${CHAIN_ID} \
--validator-backend ${LOCAL} \
--data-path ${DATA_PATH} \
Expand All @@ -250,15 +250,15 @@ genesis:
#### NODE MANAGEMENT ####
start:
# run in foreground. Only for testing, use a daemon for net.
cargo run -p libra-node -- --config ${DATA_PATH}/validator.node.yaml
cargo run -p diem-node -- --config ${DATA_PATH}/validator.node.yaml

# Start a fullnode instead of a validator node
start-full:
cargo run -p libra-node -- --config ${DATA_PATH}/fullnode.node.yaml
cargo run -p diem-node -- --config ${DATA_PATH}/fullnode.node.yaml

daemon:
# your node's custom libra-node.service lives in ~/.0L. Take the template from libra/util and edit for your needs.
cp -f ~/.0L/libra-node.service /lib/systemd/system/
# your node's custom diem-node.service lives in ~/.0L. Take the template from libra/util and edit for your needs.
cp -f ~/.0L/diem-node.service /lib/systemd/system/

@if test -d ~/logs; then \
echo "WIPING SYSTEMD LOGS"; \
Expand All @@ -271,10 +271,10 @@ daemon:
chmod 777 ~/logs/node.log

systemctl daemon-reload
systemctl stop libra-node.service
systemctl start libra-node.service
systemctl stop diem-node.service
systemctl start diem-node.service
sleep 2
systemctl status libra-node.service &
systemctl status diem-node.service &
tail -f ~/logs/node.log

#### TEST SETUP ####
Expand Down Expand Up @@ -381,7 +381,7 @@ wipe:
srm ~/.bash_history

stop:
service libra-node stop
service diem-node stop

debug:
make smoke-onboard <<< $$'${MNEM}'
Expand Down Expand Up @@ -410,14 +410,17 @@ dev-wizard:
# REQUIRES there is a genesis.blob in the fixtures/genesis/<version> you are testing
MNEM='${MNEM}' cargo run -p onboard -- val --skip-mining --skip-fetch-genesis --chain-id 1 --github-org OLSF --repo dev-genesis --upstream-peer http://161.35.13.169:8080

#### DEVNET INFRASTRUCTURE ####
#### DEVNET RESTART ####
# usually do this on Alice, which has the dev-epoch-archive repo, and dev-genesis

# Do the ceremony: and also save the genesis fixtures, needs to happen before fix.
dev-register: clear fix register
# Do a dev genesis on each node after EVERY NODE COMPLETED registration.
dev-genesis: genesis dev-save-genesis fix-genesis

#### DEVNET INFRA ####
# To make reproducible devnet files.

# Save the files to mock infrastructure i.e. devnet github
dev-infra: dev-backup-archive dev-commit

Expand Down Expand Up @@ -446,17 +449,17 @@ sw: sw-build sw-start sw-init

## Build
sw-stdlib:
cd ${SOURCE} && cargo run -p diem-framework
cd ${SOURCE} && cargo run -p diem-framework --release

sw-build:
cargo build -p diem-node -p diem-swarm -p cli
cargo build -p diem-node -p diem-swarm -p cli --release

## Swarm
sw-start:
cd ${SOURCE} && cargo run -p diem-swarm -- --diem-node target/debug/diem-node -c ${DATA_PATH}/swarm_temp -n 1 -s --cli-path ${SOURCE}/target/debug/cli
cd ${SOURCE} && cargo run --release -p diem-swarm -- --diem-node target/debug/diem-node -c ${DATA_PATH}/swarm_temp -n 1 -s --cli-path ${SOURCE}/target/debug/cli

sw-init:
cd ${SOURCE} && cargo r -p ol -- --swarm-path ${DATA_PATH}/swarm_temp/ --swarm-persona alice init --source-path ~/libra
cd ${SOURCE} && cargo r --release -p ol -- --swarm-path ${DATA_PATH}/swarm_temp/ --swarm-persona alice init --source-path ~/libra

sw-miner:
cd ${SOURCE} && cargo r -p miner -- --swarm-path ${DATA_PATH}/swarm_temp --swarm-persona alice start
Expand Down
36 changes: 29 additions & 7 deletions language/diem-framework/modules/doc/AutoPay.md
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,11 @@ Attempt to add instruction when too many already exist
<b>let</b> payments = &<b>mut</b> borrow_global_mut&lt;<a href="AutoPay.md#0x1_AutoPay2_Data">Data</a>&gt;(*account_addr).payments;
<b>let</b> payments_len = <a href="../../../../../../move-stdlib/docs/Vector.md#0x1_Vector_length">Vector::length</a>&lt;<a href="AutoPay.md#0x1_AutoPay2_Payment">Payment</a>&gt;(payments);
<b>let</b> payments_idx = 0;
// print(&02220);

<b>while</b> (payments_idx &lt; payments_len) {
// print(&02221);

<b>let</b> delete_payment = <b>false</b>;
{
<b>let</b> payment = <a href="../../../../../../move-stdlib/docs/Vector.md#0x1_Vector_borrow_mut">Vector::borrow_mut</a>&lt;<a href="AutoPay.md#0x1_AutoPay2_Payment">Payment</a>&gt;(payments, payments_idx);
Expand Down Expand Up @@ -564,21 +568,37 @@ Attempt to add instruction when too many already exist

// check payees are community wallets
<b>let</b> list = <a href="Wallet.md#0x1_Wallet_get_comm_list">Wallet::get_comm_list</a>();
// print(&02222);

// TODO: `amount` cannot be zero otherwise <a href="DiemAccount.md#0x1_DiemAccount_deposit">DiemAccount::deposit</a>&lt;Token: store&gt;() aborts
<b>if</b> (<a href="../../../../../../move-stdlib/docs/Vector.md#0x1_Vector_contains">Vector::contains</a>&lt;address&gt;(&list, &payment.payee) &&
amount != 0 &&
amount &lt;= account_bal &&
// Payeee is a community wallet
<b>if</b> (!<a href="../../../../../../move-stdlib/docs/Vector.md#0x1_Vector_contains">Vector::contains</a>&lt;address&gt;(&list, &payment.payee)){
// print(&0222201);
<b>return</b>
};

<b>if</b> (amount == 0){
// print(&0222202);
<b>return</b>
};

<b>if</b> (amount &gt; account_bal){
// print(&0222203);
<b>return</b>
};

<b>if</b> (// transfers are enabled between accounts, need <b>to</b> consider transfer limits
borrow_global&lt;<a href="AutoPay.md#0x1_AutoPay2_AccountLimitsEnable">AccountLimitsEnable</a>&gt;(<a href="../../../../../../move-stdlib/docs/Signer.md#0x1_Signer_address_of">Signer::address_of</a>(vm)).enabled) {
// print(&0222204);
<a href="DiemAccount.md#0x1_DiemAccount_vm_make_payment">DiemAccount::vm_make_payment</a>&lt;<a href="GAS.md#0x1_GAS">GAS</a>&gt;(
*account_addr, payment.payee, amount, x"", x"", vm
*account_addr, payment.payee, amount, b"autopay - transfer limits", x"", vm
);
} <b>else</b> {
// print(&0222205);
<a href="DiemAccount.md#0x1_DiemAccount_vm_make_payment_no_limit">DiemAccount::vm_make_payment_no_limit</a>&lt;<a href="GAS.md#0x1_GAS">GAS</a>&gt;(
*account_addr, payment.payee, amount, x"", x"", vm
*account_addr, payment.payee, amount, b"autopay - no limit", x"", vm
);
};

// print(&02223);
// <b>update</b> previous balance for next calculation
payment.prev_bal = <a href="DiemAccount.md#0x1_DiemAccount_balance">DiemAccount::balance</a>&lt;<a href="GAS.md#0x1_GAS">GAS</a>&gt;(*account_addr);

Expand All @@ -593,6 +613,7 @@ Attempt to add instruction when too many already exist
delete_payment = <b>true</b>;
};
};
// print(&02230);
<b>if</b> (delete_payment == <b>true</b>) {
<a href="../../../../../../move-stdlib/docs/Vector.md#0x1_Vector_remove">Vector::remove</a>&lt;<a href="AutoPay.md#0x1_AutoPay2_Payment">Payment</a>&gt;(payments, payments_idx);
payments_len = payments_len - 1;
Expand All @@ -601,6 +622,7 @@ Attempt to add instruction when too many already exist
payments_idx = payments_idx + 1;
};
};
// print(&02240);
account_idx = account_idx + 1;
};
}
Expand Down
19 changes: 15 additions & 4 deletions language/diem-framework/modules/doc/DiemAccount.md
Original file line number Diff line number Diff line change
Expand Up @@ -1044,13 +1044,15 @@ important to the semantics of the system.
<pre><code><b>public</b> <b>fun</b> <a href="DiemAccount.md#0x1_DiemAccount_process_escrow">process_escrow</a>&lt;Token: store&gt;(
account: &signer
) <b>acquires</b> <a href="DiemAccount.md#0x1_DiemAccount_EscrowList">EscrowList</a>, <a href="DiemAccount.md#0x1_DiemAccount_AutopayEscrow">AutopayEscrow</a>, <a href="DiemAccount.md#0x1_DiemAccount_Balance">Balance</a>, <a href="DiemAccount.md#0x1_DiemAccount_AccountOperationsCapability">AccountOperationsCapability</a> {
// print(&01000);
<a href="Roles.md#0x1_Roles_assert_diem_root">Roles::assert_diem_root</a>(account);

<b>let</b> account_list = &borrow_global&lt;<a href="DiemAccount.md#0x1_DiemAccount_EscrowList">EscrowList</a>&lt;Token&gt;&gt;(<a href="CoreAddresses.md#0x1_CoreAddresses_DIEM_ROOT_ADDRESS">CoreAddresses::DIEM_ROOT_ADDRESS</a>()).accounts;
<b>let</b> account_len = <a href="../../../../../../move-stdlib/docs/Vector.md#0x1_Vector_length">Vector::length</a>&lt;<a href="DiemAccount.md#0x1_DiemAccount_EscrowSettings">EscrowSettings</a>&gt;(account_list);
<b>let</b> account_idx = 0;

// print(&010100);
<b>while</b> (account_idx &lt; account_len) {
// print(&010110);
<b>let</b> <a href="DiemAccount.md#0x1_DiemAccount_EscrowSettings">EscrowSettings</a> {account: account_addr, share: percentage} = <a href="../../../../../../move-stdlib/docs/Vector.md#0x1_Vector_borrow">Vector::borrow</a>&lt;<a href="DiemAccount.md#0x1_DiemAccount_EscrowSettings">EscrowSettings</a>&gt;(account_list, account_idx);

//get transfer limit room
Expand All @@ -1061,18 +1063,21 @@ important to the semantics of the system.
};

limit_room = <a href="../../../../../../move-stdlib/docs/FixedPoint32.md#0x1_FixedPoint32_multiply_u64">FixedPoint32::multiply_u64</a>(limit_room , <a href="../../../../../../move-stdlib/docs/FixedPoint32.md#0x1_FixedPoint32_create_from_rational">FixedPoint32::create_from_rational</a>(*percentage, 100));

// print(&010120);
<b>let</b> amount_sent: u64 = 0;

<b>let</b> payment_list = &<b>mut</b> borrow_global_mut&lt;<a href="DiemAccount.md#0x1_DiemAccount_AutopayEscrow">AutopayEscrow</a>&lt;Token&gt;&gt;(*account_addr).list;
<b>let</b> num_payments = <a href="FIFO.md#0x1_FIFO_len">FIFO::len</a>&lt;<a href="DiemAccount.md#0x1_DiemAccount_Escrow">Escrow</a>&lt;Token&gt;&gt;(payment_list);

// print(&010130);
//pay out escrow until limit is reached
<b>while</b> (limit_room &gt; 0 && num_payments &gt; 0) {
// print(&010131);
<b>let</b> <a href="DiemAccount.md#0x1_DiemAccount_Escrow">Escrow</a>&lt;Token&gt; {to_account, escrow} = <a href="FIFO.md#0x1_FIFO_pop">FIFO::pop</a>&lt;<a href="DiemAccount.md#0x1_DiemAccount_Escrow">Escrow</a>&lt;Token&gt;&gt;(payment_list);
<b>let</b> recipient_coins = borrow_global_mut&lt;<a href="DiemAccount.md#0x1_DiemAccount_Balance">Balance</a>&lt;Token&gt;&gt;(to_account);
<b>let</b> payment_size = <a href="Diem.md#0x1_Diem_value">Diem::value</a>&lt;Token&gt;(&escrow);
// print(&010132);
<b>if</b> (payment_size &gt; limit_room) {
// print(&010133);
<b>let</b> (coin1, coin2) = <a href="Diem.md#0x1_Diem_split">Diem::split</a>&lt;Token&gt;(escrow, limit_room);
<a href="Diem.md#0x1_Diem_deposit">Diem::deposit</a>&lt;Token&gt;(&<b>mut</b> recipient_coins.coin, coin2);
<b>let</b> new_escrow = <a href="DiemAccount.md#0x1_DiemAccount_Escrow">Escrow</a> {
Expand All @@ -1082,24 +1087,29 @@ important to the semantics of the system.
<a href="FIFO.md#0x1_FIFO_push_LIFO">FIFO::push_LIFO</a>&lt;<a href="DiemAccount.md#0x1_DiemAccount_Escrow">Escrow</a>&lt;Token&gt;&gt;(payment_list, new_escrow);
amount_sent = amount_sent + limit_room;
limit_room = 0;
// print(&010134);
} <b>else</b> {
// print(&01015);
//This entire escrow is being paid out
<a href="Diem.md#0x1_Diem_deposit">Diem::deposit</a>&lt;Token&gt;(&<b>mut</b> recipient_coins.coin, escrow);
limit_room = limit_room - payment_size;
amount_sent = amount_sent + payment_size;
num_payments = num_payments - 1;
// print(&010136);
}
};
//<b>update</b> account limits
<b>if</b> (amount_sent &gt; 0) {
// print(&010140);
_ = <a href="AccountLimits.md#0x1_AccountLimits_update_withdrawal_limits">AccountLimits::update_withdrawal_limits</a>&lt;Token&gt;(
amount_sent,
*account_addr,
&borrow_global&lt;<a href="DiemAccount.md#0x1_DiemAccount_AccountOperationsCapability">AccountOperationsCapability</a>&gt;(<a href="CoreAddresses.md#0x1_CoreAddresses_DIEM_ROOT_ADDRESS">CoreAddresses::DIEM_ROOT_ADDRESS</a>()).limits_cap
);
// print(&010141);
};


// print(&010150);
account_idx = account_idx + 1;
}

Expand Down Expand Up @@ -2605,6 +2615,7 @@ Return the withdraw capability to the account it originally came from

## Function `vm_make_payment_no_limit`

This function bypasses transaction limits. vm_make_payment on the other hand considers payment limits.


<pre><code><b>public</b> <b>fun</b> <a href="DiemAccount.md#0x1_DiemAccount_vm_make_payment_no_limit">vm_make_payment_no_limit</a>&lt;Token: store&gt;(payer: address, payee: address, amount: u64, metadata: vector&lt;u8&gt;, metadata_signature: vector&lt;u8&gt;, vm: &signer)
Expand Down
4 changes: 4 additions & 0 deletions language/diem-framework/modules/doc/DiemBlock.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,15 @@ The runtime always runs this before executing the transactions in a block.
// increment stats
<a href="Stats.md#0x1_Stats_process_set_votes">Stats::process_set_votes</a>(&vm, &previous_block_votes);
<a href="Stats.md#0x1_Stats_inc_prop">Stats::inc_prop</a>(&vm, *&proposer);

<b>if</b> (<a href="AutoPay.md#0x1_AutoPay2_tick">AutoPay2::tick</a>(&vm)){
// print(&1);
//triggers autopay at beginning of each epoch
//tick is reset at end of previous epoch
<a href="DiemAccount.md#0x1_DiemAccount_process_escrow">DiemAccount::process_escrow</a>&lt;<a href="GAS.md#0x1_GAS">GAS</a>&gt;(&vm);
// print(&2);
<a href="AutoPay.md#0x1_AutoPay2_process_autopay">AutoPay2::process_autopay</a>(&vm);
// print(&3);
};

<b>let</b> block_metadata_ref = borrow_global_mut&lt;<a href="DiemBlock.md#0x1_DiemBlock_BlockMetadata">BlockMetadata</a>&gt;(<a href="CoreAddresses.md#0x1_CoreAddresses_DIEM_ROOT_ADDRESS">CoreAddresses::DIEM_ROOT_ADDRESS</a>());
Expand Down
Loading

0 comments on commit 15e97bd

Please sign in to comment.