Skip to content

Commit

Permalink
Cleanups (#390)
Browse files Browse the repository at this point in the history
  • Loading branch information
oxade committed Feb 8, 2022
1 parent 0f25d79 commit 94b792c
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 67 deletions.
4 changes: 2 additions & 2 deletions fastpay_core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ pub struct AuthorityState {

/// The authority state encapsulates all state, drives execution, and ensures safety.
///
/// Note the authority operations can be accesessed through a read reaf (&) and do not
/// Note the authority operations can be accesessed through a read ref (&) and do not
/// require &mut. Internally a database is syncronized through a mutex lock.
///
/// Repeating commands should produce no changes and return no error.
/// Repeating valid commands should produce no changes and return no error.
impl AuthorityState {
/// The logic to check one object against a reference, and return the object if all is well
/// or an error if not.
Expand Down
2 changes: 1 addition & 1 deletion fastx_types/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ pub enum FastPayError {
ModuleDeserializationFailure { error: String },
#[error("Failed to publish the Move module(s), reason: {error:?}.")]
ModulePublishFailure { error: String },
#[error("Failed to build Move modules")]
#[error("Failed to build Move modules: {error:?}.")]
ModuleBuildFailure { error: String },
#[error("Dependent package not found on-chain: {package_id:?}")]
DependentPackageNotFound { package_id: ObjectID },
Expand Down
16 changes: 0 additions & 16 deletions fastx_types/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,22 +387,6 @@ impl Order {
self.signature.check(&self.kind, *self.sender())
}

// TODO: support orders with multiple objects, each with their own sequence number (https://github.com/MystenLabs/fastnft/issues/8)
pub fn sequence_number(&self) -> SequenceNumber {
use OrderKind::*;
match &self.kind {
Transfer(t) => t.object_ref.1,
Publish(_) => SequenceNumber::new(), // modules are immutable, seq # is always 0
Call(c) => {
assert!(
c.object_arguments.is_empty(),
"Unimplemented: non-gas object arguments"
);
c.gas_payment.1
}
}
}

/// Return the metadata of each of the input objects for the order.
/// For a Move object, we attach the object reference;
/// for a Move package, we provide the object id only since they never change on chain.
Expand Down
48 changes: 0 additions & 48 deletions fastx_types/src/object.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Mysten Labs
// SPDX-License-Identifier: Apache-2.0

use move_core_types::ident_str;
use serde::{Deserialize, Serialize};
use serde_bytes::ByteBuf;
use serde_with::{serde_as, Bytes};
Expand All @@ -11,8 +10,6 @@ use std::convert::{TryFrom, TryInto};
use move_binary_format::CompiledModule;
use move_core_types::{account_address::AccountAddress, language_storage::StructTag};

use crate::id::ID;
use crate::FASTX_FRAMEWORK_ADDRESS;
use crate::{
base_types::{
sha3_hash, Authenticator, BcsSignable, FastPayAddress, ObjectDigest, ObjectID, ObjectRef,
Expand All @@ -21,10 +18,6 @@ use crate::{
gas_coin::GasCoin,
};

pub const OBJECT_BASICS_MODULE_NAME: &move_core_types::identifier::IdentStr =
ident_str!("ObjectBasics");
pub const OBJECT_BASICS_OBJECT_TYPE_NAME: &move_core_types::identifier::IdentStr =
ident_str!("Object");
pub const GAS_VALUE_FOR_TESTING: u64 = 100000_u64;
pub const OBJECT_START_VERSION: SequenceNumber = SequenceNumber::from_u64(1);

Expand All @@ -37,13 +30,6 @@ pub struct MoveObject {
read_only: bool,
}

/// ObjectBasics in the Framework uses an object of the following format
#[derive(Debug, Deserialize, Serialize)]
pub struct ObjectBasicsObject {
pub id: ID,
pub value: u64,
}

/// Byte encoding of a 64 byte unsigned integer in BCS
type BcsU64 = [u8; 8];
/// Index marking the end of the object's ID + the beginning of its version
Expand Down Expand Up @@ -313,40 +299,6 @@ impl Object {
Self::with_id_owner_gas_for_testing(id, SequenceNumber::new(), owner, GAS_VALUE_FOR_TESTING)
}

/// Create ObjectBasics object for use in Move object operation
pub fn with_id_owner_object_basics_object_for_testing(
id: ObjectID,
version: SequenceNumber,
owner: FastPayAddress,
value: u64,
) -> Self {
// Check ObjectBasics.move in Framework for details
// Create struct tag for ObjectBasics object
let struct_tag = StructTag {
address: FASTX_FRAMEWORK_ADDRESS,
name: OBJECT_BASICS_OBJECT_TYPE_NAME.to_owned(),
module: OBJECT_BASICS_MODULE_NAME.to_owned(),
type_params: Vec::new(),
};

// An object in ObjectBasics is a struct of an ID and a u64 value
let obj = ObjectBasicsObject {
id: ID::new(id, version),
value,
};

let data = Data::Move(MoveObject {
type_: struct_tag,
contents: bcs::to_bytes(&obj).unwrap(),
read_only: false,
});
Self {
owner: Authenticator::Address(owner),
data,
previous_transaction: TransactionDigest::genesis(),
}
}

/// Create Coin object for use in Move object operation
pub fn with_id_owner_gas_coin_object_for_testing(
id: ObjectID,
Expand Down

1 comment on commit 94b792c

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Bench results

�[0m�[0m�[1m�[32m Finished�[0m release [optimized + debuginfo] target(s) in 1.68s
�[0m�[0m�[1m�[32m Running�[0m target/release/bench
�[2m2022-02-08T17:53:47.821484Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Starting benchmark: OrdersAndCerts
�[2m2022-02-08T17:53:47.821505Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Preparing accounts.
�[2m2022-02-08T17:53:47.822656Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Open database on path: "/tmp/DB_8C2556CE7F876799D99141878F1B63A9FA377498"
�[2m2022-02-08T17:53:52.604768Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Preparing transactions.
�[2m2022-02-08T17:54:01.787230Z�[0m �[32m INFO�[0m �[2mfastpay_core::authority_server�[0m�[2m:�[0m Listening to TCP traffic on 127.0.0.1:9555
�[2m2022-02-08T17:54:02.789064Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Number of TCP connections: 2
�[2m2022-02-08T17:54:02.789091Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Set max_in_flight to 500
�[2m2022-02-08T17:54:02.789094Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Sending requests.
�[2m2022-02-08T17:54:02.793078Z�[0m �[32m INFO�[0m �[2mfastx_network::network�[0m�[2m:�[0m Sending TCP requests to 127.0.0.1:9555
�[2m2022-02-08T17:54:02.798083Z�[0m �[32m INFO�[0m �[2mfastx_network::network�[0m�[2m:�[0m Sending TCP requests to 127.0.0.1:9555
�[2m2022-02-08T17:54:03.601693Z�[0m �[32m INFO�[0m �[2mfastpay_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 5000 packets
�[2m2022-02-08T17:54:04.314474Z�[0m �[32m INFO�[0m �[2mfastx_network::network�[0m�[2m:�[0m In flight 500 Remaining 35000
�[2m2022-02-08T17:54:04.320510Z�[0m �[32m INFO�[0m �[2mfastx_network::network�[0m�[2m:�[0m In flight 500 Remaining 35000
�[2m2022-02-08T17:54:04.405889Z�[0m �[32m INFO�[0m �[2mfastpay_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 10000 packets
�[2m2022-02-08T17:54:05.209443Z�[0m �[32m INFO�[0m �[2mfastpay_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 15000 packets
�[2m2022-02-08T17:54:05.956097Z�[0m �[32m INFO�[0m �[2mfastx_network::network�[0m�[2m:�[0m In flight 500 Remaining 30000
�[2m2022-02-08T17:54:05.974875Z�[0m �[32m INFO�[0m �[2mfastx_network::network�[0m�[2m:�[0m In flight 500 Remaining 30000
�[2m2022-02-08T17:54:06.036783Z�[0m �[32m INFO�[0m �[2mfastpay_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 20000 packets
�[2m2022-02-08T17:54:06.850322Z�[0m �[32m INFO�[0m �[2mfastpay_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 25000 packets
�[2m2022-02-08T17:54:07.540801Z�[0m �[32m INFO�[0m �[2mfastx_network::network�[0m�[2m:�[0m In flight 500 Remaining 25000
�[2m2022-02-08T17:54:07.578495Z�[0m �[32m INFO�[0m �[2mfastx_network::network�[0m�[2m:�[0m In flight 500 Remaining 25000
�[2m2022-02-08T17:54:07.654900Z�[0m �[32m INFO�[0m �[2mfastpay_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 30000 packets
�[2m2022-02-08T17:54:08.461243Z�[0m �[32m INFO�[0m �[2mfastpay_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 35000 packets
�[2m2022-02-08T17:54:09.146577Z�[0m �[32m INFO�[0m �[2mfastx_network::network�[0m�[2m:�[0m In flight 500 Remaining 20000
�[2m2022-02-08T17:54:09.242330Z�[0m �[32m INFO�[0m �[2mfastx_network::network�[0m�[2m:�[0m In flight 500 Remaining 20000
�[2m2022-02-08T17:54:09.268513Z�[0m �[32m INFO�[0m �[2mfastpay_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 40000 packets
�[2m2022-02-08T17:54:10.074947Z�[0m �[32m INFO�[0m �[2mfastpay_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 45000 packets
�[2m2022-02-08T17:54:10.771583Z�[0m �[32m INFO�[0m �[2mfastx_network::network�[0m�[2m:�[0m In flight 500 Remaining 15000
�[2m2022-02-08T17:54:10.882384Z�[0m �[32m INFO�[0m �[2mfastx_network::network�[0m�[2m:�[0m In flight 500 Remaining 15000
�[2m2022-02-08T17:54:10.883074Z�[0m �[32m INFO�[0m �[2mfastpay_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 50000 packets
�[2m2022-02-08T17:54:11.689533Z�[0m �[32m INFO�[0m �[2mfastpay_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 55000 packets
�[2m2022-02-08T17:54:12.341694Z�[0m �[32m INFO�[0m �[2mfastx_network::network�[0m�[2m:�[0m In flight 500 Remaining 10000
�[2m2022-02-08T17:54:12.496654Z�[0m �[32m INFO�[0m �[2mfastx_network::network�[0m�[2m:�[0m In flight 500 Remaining 10000
�[2m2022-02-08T17:54:12.499942Z�[0m �[32m INFO�[0m �[2mfastpay_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 60000 packets
�[2m2022-02-08T17:54:13.308153Z�[0m �[32m INFO�[0m �[2mfastpay_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 65000 packets
�[2m2022-02-08T17:54:13.968990Z�[0m �[32m INFO�[0m �[2mfastx_network::network�[0m�[2m:�[0m In flight 500 Remaining 5000
�[2m2022-02-08T17:54:14.116617Z�[0m �[32m INFO�[0m �[2mfastpay_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 70000 packets
�[2m2022-02-08T17:54:14.141922Z�[0m �[32m INFO�[0m �[2mfastx_network::network�[0m�[2m:�[0m In flight 500 Remaining 5000
�[2m2022-02-08T17:54:14.926172Z�[0m �[32m INFO�[0m �[2mfastpay_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 75000 packets
�[2m2022-02-08T17:54:15.705391Z�[0m �[32m INFO�[0m �[2mfastx_network::network�[0m�[2m:�[0m Done sending TCP requests to 127.0.0.1:9555
�[2m2022-02-08T17:54:15.814197Z�[0m �[32m INFO�[0m �[2mfastpay_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 80000 packets
�[2m2022-02-08T17:54:15.853543Z�[0m �[32m INFO�[0m �[2mfastx_network::network�[0m�[2m:�[0m Done sending TCP requests to 127.0.0.1:9555
�[2m2022-02-08T17:54:15.855086Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Received 80000 responses.
�[2m2022-02-08T17:54:16.053036Z�[0m �[33m WARN�[0m �[2mbench�[0m�[2m:�[0m Completed benchmark for OrdersAndCerts
Total time: 13065982us, items: 40000, tx/sec: 3061.38490011696

Please sign in to comment.