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

Add multisig Python SDK tooling, tutorial #6356

Closed
wants to merge 57 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
b2d4662
Add partial multisig tutorial, Python SDK tooling
alnoki Jan 27, 2023
34bf867
Made direct edits to new first multisig tutorial, fix links along the…
clay-aptos Jan 27, 2023
3d54b05
Fix more links
clay-aptos Jan 27, 2023
ec62363
Fix links in index to work in GitHub
clay-aptos Jan 27, 2023
37b6047
Add transfer support to multisig Python tutorial
alnoki Jan 28, 2023
b50b870
Add key rotation tutorial up until failed proof
alnoki Jan 29, 2023
3c36b3f
Add RotationProofChallenge tooling, tutorial
alnoki Jan 31, 2023
a49b332
Add upgrade and govern package, publishing example
alnoki Jan 31, 2023
7e54762
Correct erroneous hyphenation in doc comment
alnoki Jan 31, 2023
5bc4a5b
Add package upgrade, Move script tutorial examples
alnoki Jan 31, 2023
393d528
Update Python SDK version minor
alnoki Jan 31, 2023
b06de58
Fix misspelling, make other tiny edits
clay-aptos Feb 1, 2023
070115a
Add link to move-examples/upgrade_and_govern directory
clay-aptos Feb 1, 2023
9be2f0c
Add missing markdown link brace
alnoki Feb 1, 2023
dc3da83
Add password-protected keystorage, begin CLI
alnoki Feb 2, 2023
94b9642
Implement private key encrypt/decrypt CLI tooling
alnoki Feb 3, 2023
1d676b7
Add keyfile operations, abstract, clean up
alnoki Feb 3, 2023
5b8a672
Add multisig metadata incorporation command
alnoki Feb 3, 2023
d171ec8
Run formatters, update tutorial var names/outputs
alnoki Feb 6, 2023
b3dcabc
Merge branch 'multisig-tutorial' into multisig-tool
alnoki Feb 6, 2023
e98b148
Apply Python auto-formatter
alnoki Feb 6, 2023
3329416
Add bytes to prefixed hex conversion helpers
alnoki Feb 6, 2023
868d660
Update assertion/exception feedback
alnoki Feb 6, 2023
333a75f
Abstract outfile writing logic
alnoki Feb 6, 2023
2ef4b6e
Add rotation proof challenge propose/sign logic
alnoki Feb 7, 2023
5652228
Add auth key rotation conversion logic
alnoki Feb 8, 2023
a2db767
Update command hierarchy, run scripted test
alnoki Feb 8, 2023
1265f3a
Add abstracted metafile mutation operations
alnoki Feb 9, 2023
64abd0b
Add metafile threshold subcommand logic
alnoki Feb 10, 2023
ba677c7
Add rotation transaction proposal logic
alnoki Feb 10, 2023
89ab5b6
Remove triple quotes for one-liner strings
alnoki Feb 10, 2023
66788f4
Add rotation transaction signing logic
alnoki Feb 10, 2023
d02a0f6
Abstract raw rotation transaction construction
alnoki Feb 10, 2023
ec6255f
Move expiry and chain ID to challenge proposal
alnoki Feb 10, 2023
6acd1b0
Add full rotation logic, demo scripts
alnoki Feb 11, 2023
97c5179
Standardize outfile syntax
alnoki Feb 11, 2023
1b84c28
Simplify single-signer determination
alnoki Feb 11, 2023
5a606f6
Add metafile funding, publication proposal
alnoki Feb 13, 2023
3aca9fd
Add publication building/signing
alnoki Feb 14, 2023
80e2901
Add publication execution logic
alnoki Feb 14, 2023
0e9a2cf
Abstract out metafile from multisig execution
alnoki Feb 14, 2023
12faf4a
Abstract extract/compile context manager
alnoki Feb 15, 2023
1c26076
Add script without non-signer arguments
alnoki Feb 15, 2023
241af06
Add script invocation support
alnoki Feb 15, 2023
f38d1d1
Sort functions
alnoki Feb 15, 2023
171d576
Update poetry dependencies
alnoki Feb 16, 2023
aebdb99
Modify password schema, add shell script tutorial
alnoki Feb 16, 2023
93a5703
Add metafile, authentication key rotation examples
alnoki Feb 17, 2023
4961912
Add collapsible output boxes, spellchecking
alnoki Feb 17, 2023
460be0f
Update doc comment, run formatter
alnoki Feb 17, 2023
bf1c18c
Add governance example
alnoki Feb 17, 2023
4ad05b4
Finalize demo scripting
alnoki Feb 17, 2023
dfba672
Merge branch 'main' into multisig-tool
alnoki Feb 17, 2023
6e29573
Fix discrepancies from compare vs main
alnoki Feb 17, 2023
20ac8f6
Update dictionary for formatting run
alnoki Feb 17, 2023
2e184de
Update argparse boilerplate to fix unittest
alnoki Feb 17, 2023
ed6e609
Remove artifacts in publication for size savings
alnoki Feb 21, 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
4 changes: 4 additions & 0 deletions aptos-move/framework/aptos-framework/doc/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ Second, this struct is signed by the new public key that the account owner wants
knowledge of this new public key's associated secret key. These two signatures cannot be replayed in another
context because they include the TXN's unique sequence number.

Note that the challenge message to sign includes the <code><a href="account.md#0x1_account_RotationProofChallenge">RotationProofChallenge</a></code> type info prepended to the
relevant bytes, such that serializing then signing only the below four struct fields will lead to rotation
failure. For the verification implementation, see <code>aptos_stdlib::ed25519::signature_verify_strict_t()</code>.


<pre><code><b>struct</b> <a href="account.md#0x1_account_RotationProofChallenge">RotationProofChallenge</a> <b>has</b> <b>copy</b>, drop
</code></pre>
Expand Down
4 changes: 4 additions & 0 deletions aptos-move/framework/aptos-framework/sources/account.move
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ module aptos_framework::account {
/// Second, this struct is signed by the new public key that the account owner wants to rotate to, which proves
/// knowledge of this new public key's associated secret key. These two signatures cannot be replayed in another
/// context because they include the TXN's unique sequence number.
///
/// Note that the challenge message to sign includes the `RotationProofChallenge` type info prepended to the
/// relevant bytes, such that serializing then signing only the below four struct fields will lead to rotation
/// failure. For the verification implementation, see `aptos_stdlib::ed25519::signature_verify_strict_t()`.
struct RotationProofChallenge has copy, drop {
sequence_number: u64, // the sequence number of the account whose key is being rotated
originator: address, // the address of the account whose key is being rotated
Expand Down
4 changes: 4 additions & 0 deletions aptos-move/move-examples/upgrade_and_govern/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# `UpgradeAndGovern`

This directory contains two subsequent versions of the same package, as well as mock governance scripts.
See the "Your First Multisig" tutorial for more.
10 changes: 10 additions & 0 deletions aptos-move/move-examples/upgrade_and_govern/v1_0_0/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# :!:>manifest
[package]
name = 'UpgradeAndGovern'
version = '1.0.0'

[addresses]
upgrade_and_govern = '_'

[dependencies.AptosFramework]
local = '../../../framework/aptos-framework' # <:!:manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// :!:>module
/// Mock on-chain governance parameters.
module upgrade_and_govern::parameters {

struct GovernanceParameters has key {
parameter_1: u64,
parameter_2: u64
}

const GENESIS_PARAMETER_1: u64 = 123;
const GENESIS_PARAMETER_2: u64 = 456;

fun init_module(
upgrade_and_govern: &signer
) {
let governance_parameters = GovernanceParameters{
parameter_1: GENESIS_PARAMETER_1,
parameter_2: GENESIS_PARAMETER_2};
move_to<GovernanceParameters>(
upgrade_and_govern, governance_parameters);
}

public fun get_parameters():
(u64, u64)
acquires GovernanceParameters {
let governance_parameters_ref =
borrow_global<GovernanceParameters>(@upgrade_and_govern);
(governance_parameters_ref.parameter_1,
governance_parameters_ref.parameter_2)
}

} // <:!:module
10 changes: 10 additions & 0 deletions aptos-move/move-examples/upgrade_and_govern/v1_1_0/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# :!:>manifest
[package]
name = 'UpgradeAndGovern'
version = '1.1.0'

[addresses]
upgrade_and_govern = '_'

[dependencies.AptosFramework]
local = '../../../framework/aptos-framework' # <:!:manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// :!:>script
script {
use upgrade_and_govern::parameters;
use upgrade_and_govern::transfer;

const PARAMETER_1: u64 = 300;
const PARAMETER_2: u64 = 200;

fun main(
upgrade_and_govern: &signer,
to_1: address,
to_2: address
) {
parameters::set_parameters(
upgrade_and_govern, PARAMETER_1, PARAMETER_2);
transfer::transfer_octas(upgrade_and_govern, to_1, to_2);
}
} // <:!:script
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// :!:>script
script {
use upgrade_and_govern::parameters;

const PARAMETER_1: u64 = 500;
const PARAMETER_2: u64 = 700;

fun set_only(
upgrade_and_govern: &signer,
) {
parameters::set_parameters(
upgrade_and_govern, PARAMETER_1, PARAMETER_2);
}
} // <:!:script
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/// Mock on-chain governance parameters.
module upgrade_and_govern::parameters {

struct GovernanceParameters has key {
parameter_1: u64,
parameter_2: u64
}

const GENESIS_PARAMETER_1: u64 = 123;
const GENESIS_PARAMETER_2: u64 = 456;

fun init_module(
upgrade_and_govern: &signer
) {
let governance_parameters = GovernanceParameters{
parameter_1: GENESIS_PARAMETER_1,
parameter_2: GENESIS_PARAMETER_2};
move_to<GovernanceParameters>(
upgrade_and_govern, governance_parameters);
}

public fun get_parameters():
(u64, u64)
acquires GovernanceParameters {
let governance_parameters_ref =
borrow_global<GovernanceParameters>(@upgrade_and_govern);
(governance_parameters_ref.parameter_1,
governance_parameters_ref.parameter_2)
}

// :!:>appended
use std::signer::address_of;

const E_INVALID_AUTHORITY: u64 = 0;

public entry fun set_parameters(
upgrade_and_govern: &signer,
parameter_1: u64,
parameter_2: u64
) acquires GovernanceParameters {
assert!(address_of(upgrade_and_govern) == @upgrade_and_govern,
E_INVALID_AUTHORITY);
let governance_parameters_ref_mut =
borrow_global_mut<GovernanceParameters>(@upgrade_and_govern);
governance_parameters_ref_mut.parameter_1 = parameter_1;
governance_parameters_ref_mut.parameter_2 = parameter_2;
}

} // <:!:appended
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// :!:>module
/// Mock coin transfer module that invokes governance parameters.
module upgrade_and_govern::transfer {

use aptos_framework::aptos_coin::AptosCoin;
use aptos_framework::coin;
use upgrade_and_govern::parameters;

public entry fun transfer_octas(
from: &signer,
to_1: address,
to_2: address
) {
let (amount_1, amount_2) = parameters::get_parameters();
coin::transfer<AptosCoin>(from, to_1, amount_1);
coin::transfer<AptosCoin>(from, to_2, amount_2);
}

} // <:!:module
Loading