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

feat: new PublishTemplate instruction #1208

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions applications/tari_dan_app_utilities/src/transaction_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use std::sync::Arc;

use log::*;
use tari_common::configuration::Network;
use tari_common_types::types::PublicKey;
use tari_crypto::tari_utilities::ByteArray;
use tari_dan_common_types::{
Expand All @@ -18,7 +17,7 @@ use tari_dan_engine::{
runtime::{AuthParams, RuntimeModule},
state_store::{memory::ReadOnlyMemoryStateStore, StateStoreError},
template::LoadedTemplate,
transaction::{TransactionError, TransactionProcessor},
transaction::{TransactionError, TransactionProcessor, TransactionProcessorConfig},
};
use tari_dan_storage::consensus_models::VersionedSubstateIdLockIntent;
use tari_engine_types::{commit_result::ExecuteResult, substate::Substate, virtual_substate::VirtualSubstates};
Expand Down Expand Up @@ -89,15 +88,15 @@ impl ExecutionOutput {
pub struct TariDanTransactionProcessor<TTemplateProvider> {
template_provider: Arc<TTemplateProvider>,
fee_table: FeeTable,
network: Network,
config: TransactionProcessorConfig,
}

impl<TTemplateProvider> TariDanTransactionProcessor<TTemplateProvider> {
pub fn new(network: Network, template_provider: TTemplateProvider, fee_table: FeeTable) -> Self {
pub fn new(config: TransactionProcessorConfig, template_provider: TTemplateProvider, fee_table: FeeTable) -> Self {
Self {
template_provider: Arc::new(template_provider),
fee_table,
network,
config,
}
}
}
Expand Down Expand Up @@ -128,12 +127,12 @@ where TTemplateProvider: TemplateProvider<Template = LoadedTemplate>
let modules: Vec<Arc<dyn RuntimeModule>> = vec![Arc::new(FeeModule::new(initial_cost, self.fee_table.clone()))];

let processor = TransactionProcessor::new(
self.config.clone(),
self.template_provider.clone(),
state_store,
auth_params,
virtual_substates,
modules,
self.network,
);
let result = processor.execute(transaction.clone())?;

Expand Down
11 changes: 5 additions & 6 deletions applications/tari_indexer/src/dry_run/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@
use std::{collections::HashMap, sync::Arc};

use log::info;
use tari_common::configuration::Network;
use tari_dan_app_utilities::{
template_manager::implementation::TemplateManager,
transaction_executor::{TariDanTransactionProcessor, TransactionExecutor as _},
};
use tari_dan_common_types::{Epoch, PeerAddress, SubstateAddress, SubstateRequirement};
use tari_dan_engine::{fees::FeeTable, state_store::new_memory_store};
use tari_dan_engine::{fees::FeeTable, state_store::new_memory_store, transaction::TransactionProcessorConfig};
use tari_engine_types::{
commit_result::ExecuteResult,
instruction::Instruction,
Expand All @@ -56,37 +55,37 @@ use crate::dry_run::error::DryRunTransactionProcessorError;
const LOG_TARGET: &str = "tari::indexer::dry_run_transaction_processor";

pub struct DryRunTransactionProcessor<TSubstateCache> {
config: TransactionProcessorConfig,
epoch_manager: EpochManagerHandle<PeerAddress>,
client_provider: TariValidatorNodeRpcClientFactory,
transaction_autofiller:
TransactionAutofiller<EpochManagerHandle<PeerAddress>, TariValidatorNodeRpcClientFactory, TSubstateCache>,
template_manager: TemplateManager<PeerAddress>,
substate_scanner:
Arc<SubstateScanner<EpochManagerHandle<PeerAddress>, TariValidatorNodeRpcClientFactory, TSubstateCache>>,
network: Network,
}

impl<TSubstateCache> DryRunTransactionProcessor<TSubstateCache>
where TSubstateCache: SubstateCache + 'static
{
pub fn new(
config: TransactionProcessorConfig,
epoch_manager: EpochManagerHandle<PeerAddress>,
client_provider: TariValidatorNodeRpcClientFactory,
substate_scanner: Arc<
SubstateScanner<EpochManagerHandle<PeerAddress>, TariValidatorNodeRpcClientFactory, TSubstateCache>,
>,
template_manager: TemplateManager<PeerAddress>,
network: Network,
) -> Self {
let transaction_autofiller = TransactionAutofiller::new(substate_scanner.clone());

Self {
config,
epoch_manager,
client_provider,
transaction_autofiller,
template_manager,
substate_scanner,
network,
}
}

Expand Down Expand Up @@ -139,7 +138,7 @@ where TSubstateCache: SubstateCache + 'static
FeeTable::zero_rated()
};

TariDanTransactionProcessor::new(self.network, self.template_manager.clone(), fee_table)
TariDanTransactionProcessor::new(self.config.clone(), self.template_manager.clone(), fee_table)
}

fn transaction_includes_fees(transaction: &Transaction) -> bool {
Expand Down
9 changes: 7 additions & 2 deletions applications/tari_indexer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ use tari_common::{
};
use tari_consensus::consensus_constants::ConsensusConstants;
use tari_dan_app_utilities::{keypair::setup_keypair_prompt, substate_file_cache::SubstateFileCache};
use tari_dan_engine::transaction::TransactionProcessorConfig;
use tari_dan_storage::global::DbFactory;
use tari_dan_storage_sqlite::SqliteDbFactory;
use tari_epoch_manager::{EpochManagerEvent, EpochManagerReader};
Expand Down Expand Up @@ -86,13 +87,14 @@ pub async fn run_indexer(config: ApplicationConfig, mut shutdown_signal: Shutdow
.get_or_create_global_db()
.map_err(|e| ExitError::new(ExitCode::DatabaseError, e))?;

let consensus_constants = ConsensusConstants::from(config.network);
let base_node_client = create_base_layer_clients(&config).await?;
let services: Services = spawn_services(
&config,
shutdown_signal.clone(),
keypair.clone(),
global_db,
ConsensusConstants::devnet(), // TODO: change this eventually
consensus_constants.clone(),
)
.await?;

Expand Down Expand Up @@ -120,11 +122,14 @@ pub async fn run_indexer(config: ApplicationConfig, mut shutdown_signal: Shutdow

// dry run
let dry_run_transaction_processor = DryRunTransactionProcessor::new(
TransactionProcessorConfig::builder()
.with_network(config.network)
.with_template_binary_max_size_bytes(consensus_constants.template_binary_max_size_bytes)
.build(),
services.epoch_manager.clone(),
services.validator_node_client_factory.clone(),
dan_layer_scanner.clone(),
services.template_manager.clone(),
config.network,
);

// Run the JSON-RPC API
Expand Down
11 changes: 9 additions & 2 deletions applications/tari_validator_node/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ use tari_dan_common_types::{
ShardGroup,
VersionedSubstateId,
};
use tari_dan_engine::fees::FeeTable;
use tari_dan_engine::{fees::FeeTable, transaction::TransactionProcessorConfig};
use tari_dan_p2p::TariMessagingSpec;
use tari_dan_storage::{
consensus_models::{Block, BlockId, SubstateRecord},
Expand Down Expand Up @@ -289,7 +289,14 @@ pub async fn spawn_services(
);

// Consensus
let payload_processor = TariDanTransactionProcessor::new(config.network, template_manager.clone(), fee_table);
let payload_processor = TariDanTransactionProcessor::new(
TransactionProcessorConfig::builder()
.with_network(config.network)
.with_template_binary_max_size_bytes(consensus_constants.template_binary_max_size_bytes)
.build(),
template_manager.clone(),
fee_table,
);
let transaction_executor = TariDanBlockTransactionExecutor::new(
payload_processor.clone(),
consensus::create_transaction_validator(template_manager.clone()).boxed(),
Expand Down
42 changes: 21 additions & 21 deletions bindings/dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ export * from "./types/AbortReason";
export * from "./types/AccessRule";
export * from "./types/Account";
export * from "./types/Amount";
export * from "./types/ArgDef";
export * from "./types/Arg";
export * from "./types/ArgDef";
export * from "./types/AuthHook";
export * from "./types/BlockHeader";
export * from "./types/Block";
export * from "./types/BlockHeader";
export * from "./types/BucketId";
export * from "./types/Claims";
export * from "./types/Command";
export * from "./types/Committee";
export * from "./types/CommitteeInfo";
export * from "./types/CommitteeShardInfo";
export * from "./types/Committee";
export * from "./types/ComponentAccessRules";
export * from "./types/ComponentAddress";
export * from "./types/ComponentBody";
export * from "./types/ComponentHeader";
export * from "./types/ComponentKey";
export * from "./types/ConfidentialClaim";
export * from "./types/ConfidentialOutputStatement";
export * from "./types/ConfidentialOutput";
export * from "./types/ConfidentialOutputStatement";
export * from "./types/ConfidentialStatement";
export * from "./types/ConfidentialTransferInputSelection";
export * from "./types/ConfidentialWithdrawProof";
Expand All @@ -32,12 +32,12 @@ export * from "./types/Era";
export * from "./types/Event";
export * from "./types/EvictNodeAtom";
export * from "./types/Evidence";
export * from "./types/ExecutedTransaction";
export * from "./types/ExecuteResult";
export * from "./types/ExecutedTransaction";
export * from "./types/ExtraData";
export * from "./types/FeeBreakdown";
export * from "./types/FeeClaimAddress";
export * from "./types/FeeClaim";
export * from "./types/FeeClaimAddress";
export * from "./types/FeeCostBreakdown";
export * from "./types/FeeReceipt";
export * from "./types/FeeSource";
Expand All @@ -46,10 +46,10 @@ export * from "./types/ForeignProposalAtom";
export * from "./types/FunctionDef";
export * from "./types/IndexedValue";
export * from "./types/IndexedWellKnownTypes";
export * from "./types/InstructionResult";
export * from "./types/Instruction";
export * from "./types/JrpcPermissions";
export * from "./types/InstructionResult";
export * from "./types/JrpcPermission";
export * from "./types/JrpcPermissions";
export * from "./types/LeaderFee";
export * from "./types/LockFlag";
export * from "./types/LogEntry";
Expand All @@ -58,14 +58,14 @@ export * from "./types/Metadata";
export * from "./types/MintConfidentialOutputAtom";
export * from "./types/NetworkCommitteeInfo";
export * from "./types/NodeHeight";
export * from "./types/NonFungibleAddressContents";
export * from "./types/NonFungible";
export * from "./types/NonFungibleAddress";
export * from "./types/NonFungibleAddressContents";
export * from "./types/NonFungibleContainer";
export * from "./types/NonFungibleId";
export * from "./types/NonFungibleIndexAddress";
export * from "./types/NonFungibleIndex";
export * from "./types/NonFungibleIndexAddress";
export * from "./types/NonFungibleToken";
export * from "./types/NonFungible";
export * from "./types/NumPreshards";
export * from "./types/Ordering";
export * from "./types/OwnerRule";
Expand All @@ -75,50 +75,50 @@ export * from "./types/QuorumCertificate";
export * from "./types/QuorumDecision";
export * from "./types/RejectReason";
export * from "./types/RequireRule";
export * from "./types/Resource";
export * from "./types/ResourceAccessRules";
export * from "./types/ResourceAddress";
export * from "./types/ResourceContainer";
export * from "./types/Resource";
export * from "./types/ResourceType";
export * from "./types/RestrictedAccessRule";
export * from "./types/ResumeNodeAtom";
export * from "./types/RuleRequirement";
export * from "./types/Shard";
export * from "./types/ShardEvidence";
export * from "./types/ShardGroupEvidence";
export * from "./types/ShardGroup";
export * from "./types/Shard";
export * from "./types/ShardGroupEvidence";
export * from "./types/Substate";
export * from "./types/SubstateAddress";
export * from "./types/SubstateDestroyed";
export * from "./types/SubstateDiff";
export * from "./types/SubstateId";
export * from "./types/SubstateLockType";
export * from "./types/SubstateRecord";
export * from "./types/SubstateRequirementLockIntent";
export * from "./types/SubstateRequirement";
export * from "./types/Substate";
export * from "./types/SubstateRequirementLockIntent";
export * from "./types/SubstateType";
export * from "./types/SubstateValue";
export * from "./types/SuspendNodeAtom";
export * from "./types/TemplateDef";
export * from "./types/TemplateDefV1";
export * from "./types/Transaction";
export * from "./types/TransactionAtom";
export * from "./types/TransactionPoolRecord";
export * from "./types/TransactionPoolStage";
export * from "./types/TransactionReceiptAddress";
export * from "./types/TransactionReceipt";
export * from "./types/TransactionReceiptAddress";
export * from "./types/TransactionResult";
export * from "./types/TransactionSignature";
export * from "./types/TransactionStatus";
export * from "./types/Transaction";
export * from "./types/Type";
export * from "./types/UnclaimedConfidentialOutputAddress";
export * from "./types/UnclaimedConfidentialOutput";
export * from "./types/UnclaimedConfidentialOutputAddress";
export * from "./types/UnsignedTransaction";
export * from "./types/ValidatorSignature";
export * from "./types/VaultId";
export * from "./types/Vault";
export * from "./types/VersionedSubstateIdLockIntent";
export * from "./types/VaultId";
export * from "./types/VersionedSubstateId";
export * from "./types/VersionedSubstateIdLockIntent";
export * from "./types/ViewableBalanceProof";
export * from "./base-node-client";
export * from "./tari-indexer-client";
Expand Down
Loading
Loading