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

Feature/support move calls from client #157

Merged
merged 26 commits into from
Jan 15, 2022

Conversation

oxade
Copy link
Contributor

@oxade oxade commented Jan 12, 2022

Changes:

  1. Return object with ObjectInfoResponse
  2. Cleanup of Client CLI
  3. Can call Move functions from CLI where args are specified in cfg file.
    Example sh:
# cleanup prev runs
cargo build --release
cd target/release
rm -f *.json *.toml
rm -rf db*
killall server

# Create DB dirs and configuration files for 4 authorities.
# * Private server states are stored in `server*.json`.
# * `committee.json` is the public description of the FastPay committee.
for I in 1 2 3 4
do
    mkdir ./db"$I"
    ./server --server server"$I".json generate --host 127.0.0.1 --port 9"$I"00 --database-path ./db"$I" >> committee.json
done

# Create configuration files for 100 user accounts, with 10 gas objects per account and 2000000 value each.
# * Private account states are stored in one local wallet `accounts.json`.
# * `initial_accounts.toml` is used to mint the corresponding initially randomly generated (for now) objects at startup on the server side.
./client --committee committee.json --accounts accounts.json create-accounts --num 100 \
--gas-objs-per-account 10 --value-per-per-obj 2000000 initial_accounts.toml

# Start servers
for I in 1 2 3 4
do
    ./server --server server"$I".json run --initial-accounts initial_accounts.toml --committee committee.json &
done

# Query (locally cached) object info for first and last user account
ACCOUNT1=`./client --committee committee.json --accounts accounts.json query-accounts-addrs | head -n 1`
ACCOUNT2=`./client --committee committee.json --accounts accounts.json query-accounts-addrs | tail -n -1`

echo "ACCOUNT1"
echo $ACCOUNT1
./client --committee committee.json --accounts accounts.json query-objects --address "$ACCOUNT1"

echo "ACCOUNT2"
echo $ACCOUNT2
./client --committee committee.json --accounts accounts.json query-objects --address "$ACCOUNT2"



# Execute Move call with args in json file based on the values from ACCOUNT1, ACCOUNT2
./client --committee committee.json --accounts accounts.json call transfer_args.json


Where example transfer_args.json:

{
    "package_obj_id": "6D3FFC5213ED4DF6802CD4535D3C18F6",
    "module": "ObjectBasics",
    "function": "create",
    "type_args": [],
    "object_args_ids": [],
    "gas_object_id": "2C0EC2E20BCD27686CCFAA2C96E2A2E2",
    "pure_args": "200u64,   x\"01FE4E6F9F57935C5150A486B5B78AC2B94E2C5CD9352C132691D99B3E8E095C\"",
    "gas_budget": 10000
}

The package_obj_id is from framework package https://github.com/MystenLabs/fastnft/blob/main/fastx_types/src/lib.rs#L42

TODO:

  1. Cert sync still not perfected: [fastx client] Update Certificates For Multi Object Orders #173
  2. More tests: [fastx client] More Robust Tests For Move Calls #181
  3. Better error handling: [fastx client] Better Error Handling & Messaging #187

Copy link
Contributor

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fastpay/src/client.rs is getting really long! How about creating a split modulefor it?

Is every expect|unwrap a justifiably program-stopping irrecoverable error?

fastpay_core/src/client.rs Outdated Show resolved Hide resolved
fastpay_core/src/client.rs Outdated Show resolved Hide resolved
fastpay_core/src/client.rs Outdated Show resolved Hide resolved
fastpay/src/client.rs Outdated Show resolved Hide resolved
fastpay/src/client.rs Outdated Show resolved Hide resolved
fastpay/src/client.rs Outdated Show resolved Hide resolved
fastpay/src/client.rs Show resolved Hide resolved
fastpay_core/src/client.rs Outdated Show resolved Hide resolved
fastpay_core/src/client.rs Outdated Show resolved Hide resolved
fastpay_core/src/client.rs Outdated Show resolved Hide resolved
@@ -283,6 +284,44 @@ fn deserialize_response(response: &[u8]) -> Option<ObjectInfoResponse> {
}
}
}
fn find_owner_by_object_cache(
account_config: &mut AccountsConfig,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

fastpay/Cargo.toml Show resolved Hide resolved
fastpay/src/client.rs Outdated Show resolved Hide resolved
fastpay/src/config.rs Outdated Show resolved Hide resolved
fastpay/src/config.rs Outdated Show resolved Hide resolved
fastpay_core/src/client.rs Show resolved Hide resolved
fastpay_core/src/client.rs Outdated Show resolved Hide resolved
fastpay_core/src/client.rs Outdated Show resolved Hide resolved
fastpay_core/src/client.rs Outdated Show resolved Hide resolved
fastpay_core/src/client.rs Show resolved Hide resolved
@oxade
Copy link
Contributor Author

oxade commented Jan 14, 2022

The fastpay/src/client.rs is getting really long! How about creating a split modulefor it?

Is every expect|unwrap a justifiably program-stopping irrecoverable error?

Created issue for this #178

fastpay_core/src/authority.rs Show resolved Hide resolved
fastpay/src/client.rs Outdated Show resolved Hide resolved
fastpay/src/client.rs Outdated Show resolved Hide resolved
fastpay/src/client.rs Outdated Show resolved Hide resolved
fastpay/src/client.rs Outdated Show resolved Hide resolved
fastpay/src/client.rs Outdated Show resolved Hide resolved
fastpay/src/client.rs Outdated Show resolved Hide resolved
fastpay_core/src/client.rs Outdated Show resolved Hide resolved
fastpay_core/src/client.rs Outdated Show resolved Hide resolved
fastpay_core/src/client.rs Outdated Show resolved Hide resolved
fastpay_core/src/client.rs Outdated Show resolved Hide resolved
fastpay/src/client.rs Show resolved Hide resolved
fastpay/src/config.rs Outdated Show resolved Hide resolved
fastpay/src/config.rs Show resolved Hide resolved
fastpay_core/src/client.rs Outdated Show resolved Hide resolved
fastpay_core/src/client.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding tested code suggestions

fastpay_core/src/client.rs Outdated Show resolved Hide resolved
fastpay_core/src/client.rs Outdated Show resolved Hide resolved
fastpay_core/src/client.rs Outdated Show resolved Hide resolved
fastpay_core/src/client.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a couple of simplifications, but overall this no longer introduces panics where they can be avoided.

fastpay_core/src/client.rs Outdated Show resolved Hide resolved
fastpay_core/src/client.rs Outdated Show resolved Hide resolved
fastx_types/src/base_types.rs Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants