Skip to content

Commit

Permalink
remove last piece of gateway code (MystenLabs#6666)
Browse files Browse the repository at this point in the history
  • Loading branch information
longbowlu authored Dec 8, 2022
1 parent 643c877 commit 637cce5
Show file tree
Hide file tree
Showing 30 changed files with 52 additions and 2,367 deletions.
2 changes: 1 addition & 1 deletion crates/sui-benchmark/src/bin/stress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ pub async fn follow(authority_client: NetworkAuthorityClient, download_txes: boo
/// --num-server-threads 10 \
/// --num-transfer-accounts 2 \
/// --primary-gas-id 0x59931dcac57ba20d75321acaf55e8eb5a2c47e9f \
/// --gateway-config-path /tmp/gateway.yaml \
/// --genesis-blob-path /tmp/genesis.blob \
/// --keystore-path /tmp/sui.keystore bench \
/// --target-qps 100 \
/// --in-flight-ratio 2 \
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-cluster-test/src/faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl RemoteFaucetClient {
#[async_trait]
impl FaucetClient for RemoteFaucetClient {
/// Request test SUI coins from faucet.
/// It also verifies the effects are observed by gateway/fullnode.
/// It also verifies the effects are observed by fullnode.
async fn request_sui_coins(&self, request_address: SuiAddress) -> FaucetResponse {
let gas_url = format!("{}/gas", self.remote_url);
debug!("Getting coin from remote faucet {}", gas_url);
Expand Down
3 changes: 1 addition & 2 deletions crates/sui-cluster-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ pub mod wallet_client;
pub struct TestContext {
/// Cluster handle that allows access to various components in a cluster
cluster: Box<dyn Cluster + Sync + Send>,
/// Client that provides wallet context and gateway access
/// Once we sunset gateway, we will spin off fullnode client,
/// Client that provides wallet context and fullnode access
client: WalletClient,
/// Facuet client that provides faucet access to a test
faucet: Arc<dyn FaucetClient + Sync + Send>,
Expand Down
34 changes: 0 additions & 34 deletions crates/sui-config/src/gateway.rs

This file was deleted.

2 changes: 0 additions & 2 deletions crates/sui-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use sui_types::committee::StakeUnit;
use tracing::trace;

pub mod builder;
pub mod gateway;
pub mod genesis;
pub mod genesis_config;
pub mod node;
Expand All @@ -29,7 +28,6 @@ pub const SUI_NETWORK_CONFIG: &str = "network.yaml";
pub const SUI_FULLNODE_CONFIG: &str = "fullnode.yaml";
pub const SUI_CLIENT_CONFIG: &str = "client.yaml";
pub const SUI_KEYSTORE_FILENAME: &str = "sui.keystore";
pub const SUI_GATEWAY_CONFIG: &str = "gateway.yaml";
pub const SUI_GENESIS_FILENAME: &str = "genesis.blob";
pub const SUI_DEV_NET_URL: &str = "https://fullnode.devnet.sui.io:443";

Expand Down
4 changes: 1 addition & 3 deletions crates/sui-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ use tracing::{debug, error, instrument, warn};
use typed_store::Map;

pub use authority_notify_read::EffectsNotifyRead;
pub use authority_store::{
AuthorityStore, GatewayStore, ResolverWrapper, SuiDataStore, UpdateType,
};
pub use authority_store::{AuthorityStore, ResolverWrapper, SuiDataStore, UpdateType};
use narwhal_config::{
Committee as ConsensusCommittee, WorkerCache as ConsensusWorkerCache,
WorkerId as ConsensusWorkerId,
Expand Down
104 changes: 4 additions & 100 deletions crates/sui-core/src/authority/authority_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use once_cell::sync::OnceCell;
use rocksdb::Options;
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
use std::collections::{BTreeMap, BTreeSet};
use std::collections::BTreeSet;
use std::iter;
use std::path::Path;
use std::sync::Arc;
Expand All @@ -20,10 +20,10 @@ use sui_storage::{
mutex_table::{LockGuard, MutexTable},
LockService,
};
use sui_types::crypto::{AuthoritySignInfo, EmptySignInfo};
use sui_types::crypto::AuthoritySignInfo;
use sui_types::message_envelope::VerifiedEnvelope;
use sui_types::object::Owner;
use sui_types::storage::{ChildObjectResolver, SingleTxContext, WriteKind};
use sui_types::storage::ChildObjectResolver;
use sui_types::{base_types::SequenceNumber, storage::ParentSync};
use sui_types::{batch::TxSequenceNumber, object::PACKAGE_VERSION};
use tokio_retry::strategy::{jitter, ExponentialBackoff};
Expand All @@ -32,7 +32,6 @@ use typed_store::rocks::DBBatch;
use typed_store::traits::Map;

pub type AuthorityStore = SuiDataStore<AuthoritySignInfo>;
pub type GatewayStore = SuiDataStore<EmptySignInfo>;

const NUM_SHARDS: usize = 4096;
const SHARD_SIZE: usize = 128;
Expand Down Expand Up @@ -543,8 +542,7 @@ impl<S: Eq + Debug + Serialize + for<'de> Deserialize<'de>> SuiDataStore<S> {

/// Insert an object directly into the store, and also update relevant tables
/// NOTE: does not handle transaction lock.
/// This is used by the gateway to insert object directly.
/// TODO: We need this today because we don't have another way to sync an account.
/// This is used to insert genesis objects
pub async fn insert_object_direct(&self, object_ref: ObjectRef, object: &Object) -> SuiResult {
// Insert object
self.perpetual_tables
Expand Down Expand Up @@ -641,19 +639,6 @@ impl<S: Eq + Debug + Serialize + for<'de> Deserialize<'de>> SuiDataStore<S> {
Ok(())
}

/// This function should only be used by the gateway.
/// It's called when we could not get a transaction to successfully execute,
/// and have to roll back.
pub async fn reset_transaction_lock(&self, owned_input_objects: &[ObjectRef]) -> SuiResult {
// this object should not be a child object, since child objects can no longer be
// inputs, but
// TODO double check these are not child objects
self.lock_service
.initialize_locks(owned_input_objects, true /* is_force_reset */)
.await?;
Ok(())
}

/// Updates the state resulting from the execution of a certificate.
///
/// Internally it checks that all locks for active inputs are at the correct
Expand Down Expand Up @@ -730,87 +715,6 @@ impl<S: Eq + Debug + Serialize + for<'de> Deserialize<'de>> SuiDataStore<S> {
Ok(())
}

/// This is used by the Gateway to update its local store after a transaction succeeded
/// on the authorities. Since we don't yet have local execution on the gateway, we will
/// need to recreate the temporary store based on the inputs and effects to update it properly.
pub async fn update_gateway_state(
&self,
input_objects: InputObjects,
mutated_objects: BTreeMap<ObjectRef, (Object, WriteKind)>,
certificate: VerifiedCertificate,
proposed_seq: TxSequenceNumber,
effects: TransactionEffectsEnvelope<S>,
effects_digest: &TransactionEffectsDigest,
) -> SuiResult {
let ctx = SingleTxContext::gateway(certificate.sender_address());
let transaction_digest = certificate.digest();
let mut temporary_store =
TemporaryStore::new(Arc::new(&self), input_objects, *transaction_digest);

// TemporaryStore::into_inner will increment object versions, and requires that this
// operation is a true increment. Roll back modified objects' versions so that this remains
// the case.
let prev_versions: HashMap<ObjectID, SequenceNumber> = effects
.data()
.modified_at_versions
.iter()
.copied()
.collect();

for (_, (mut object, kind)) in mutated_objects {
let prev_version = match kind {
WriteKind::Create => SequenceNumber::new(),
WriteKind::Mutate | WriteKind::Unwrap => prev_versions[&object.id()],
};

if let Owner::Shared {
initial_shared_version,
} = &mut object.owner
{
if WriteKind::Create == kind {
*initial_shared_version = SequenceNumber::new();
}
}

if let Some(object) = object.data.try_as_move_mut() {
object.decrement_version_to(prev_version);
}

temporary_store.write_object(&ctx, object, kind);
}

for obj_ref in &effects.data().deleted {
let mut v = obj_ref.1;
v.decrement_to(prev_versions[&obj_ref.0]);
temporary_store.delete_object(&ctx, &obj_ref.0, v, DeleteKind::Normal);
}

for obj_ref in &effects.data().wrapped {
let mut v = obj_ref.1;
v.decrement_to(prev_versions[&obj_ref.0]);
temporary_store.delete_object(&ctx, &obj_ref.0, v, DeleteKind::Wrap);
}

let (inner_temporary_store, _events) = temporary_store.into_inner();

let mut write_batch = self.perpetual_tables.certificates.batch();
// Store the certificate indexed by transaction digest
write_batch = write_batch.insert_batch(
&self.perpetual_tables.certificates,
iter::once((transaction_digest, certificate.serializable_ref())),
)?;
self.sequence_tx(
write_batch,
inner_temporary_store,
transaction_digest,
proposed_seq,
&effects,
effects_digest,
)
.await?;
Ok(())
}

async fn sequence_tx(
&self,
write_batch: DBBatch,
Expand Down
Loading

0 comments on commit 637cce5

Please sign in to comment.