Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Drop support for deploy tx #394

Merged
merged 44 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
9ef8f03
Deprecate deploy tx
FabijanC Dec 15, 2022
9d41b46
Add declare_and_deploy [skip ci]
FabijanC Dec 15, 2022
8356e6c
Fix address calculation; Fix nonce [WIP] [skip ci]
FabijanC Dec 19, 2022
3b73d81
Almost adapt accout tests [skip ci] [WIP]
FabijanC Dec 20, 2022
178f77b
TODO: use the always present funded acc [skip ci]
FabijanC Jan 12, 2023
25a1494
Improve imports [WIP] [skip ci]
FabijanC Jan 17, 2023
cad2275
Use chargeable account in test_account [skip ci]
FabijanC Jan 18, 2023
3e63015
Ignore marshmallow warnings [skip ci]
FabijanC Jan 18, 2023
77c692f
Adapt test_account.py [skip ci]
FabijanC Jan 18, 2023
f1761a1
Adapt and refactor general workflow test [skip ci]
FabijanC Feb 8, 2023
6079608
Merge branch 'master' into drop-deploy-tx
FabijanC Feb 22, 2023
bfe8cb8
Replace deploy with declare_and_deploy_with_chargeable [skip ci]
FabijanC Feb 22, 2023
380fefd
Merge branch 'master' into drop-deploy-tx
FabijanC Feb 22, 2023
e811e22
Add test-execution.log [skip ci]
FabijanC Feb 22, 2023
79d42e1
Merge branch 'master' into drop-deploy-tx
FabijanC Mar 30, 2023
35389ed
Fix some tests [skip ci]
FabijanC Mar 30, 2023
766418b
Fix some more [skip ci]
FabijanC Mar 30, 2023
2784eb5
Adapt more tests [skip ci]
FabijanC Mar 31, 2023
5ff15bd
Just RPC tests failing [skip ci] [WIP]
FabijanC Apr 3, 2023
67d4a0a
Refactor [skip ci] [WIP]
FabijanC Apr 3, 2023
5f23ccf
Merge branch 'master' into drop-deploy-tx
FabijanC Apr 4, 2023
6d09a90
Remove deploy support in rpc [skip ci]
FabijanC Apr 4, 2023
c55f3be
Merge branch 'master' into drop-deploy-tx
FabijanC Apr 5, 2023
7ac98c4
Remove test log file [skip ci]
FabijanC Apr 5, 2023
5e99be0
Fix general workflow and state update tests [skip ci]
FabijanC Apr 5, 2023
efb1074
Merge branch 'master' into drop-deploy-tx
FabijanC Apr 7, 2023
7fcbd81
Refactor deploy_info fixture
FabijanC Apr 7, 2023
6b01c2a
Merge branch 'master' into drop-deploy-tx
FabijanC Apr 13, 2023
41629c3
Merge branch 'master' into drop-deploy-tx
FabijanC Apr 13, 2023
5415fff
Update state update test (rpc) [skip ci]
FabijanC Apr 13, 2023
868265d
Merge branch 'master' into drop-deploy-tx
FabijanC Apr 14, 2023
f62a965
Merge branch 'master' into drop-deploy-tx
FabijanC Apr 14, 2023
3aad1f4
Remaining RPC tests: misc and transactions [skip ci]
FabijanC Apr 17, 2023
61884d8
Merge branch 'master' into drop-deploy-tx
FabijanC Apr 17, 2023
e6f3092
Fix test/rpc/test_rpc_transactions.py [skip ci]
FabijanC Apr 18, 2023
e0cafd2
Merge branch 'master' into drop-deploy-tx [skip ci]
FabijanC Apr 18, 2023
d125e69
Fix get_events [skip ci]
FabijanC Apr 18, 2023
1b5ca03
Refactor salty test [skip ci]
FabijanC Apr 18, 2023
479f8fd
Fix rpc declare
FabijanC Apr 19, 2023
b8c3d5f
Minify UDC json [skip ci]
FabijanC Apr 19, 2023
d8b10cb
Minor docstring and formatting changes [skip ci]
FabijanC Apr 20, 2023
a8b2d32
Add comment in test/account.py [skip ci]
FabijanC Apr 21, 2023
1c4bc40
Update tests
FabijanC Apr 21, 2023
5e0e430
Merge branch 'master' into drop-deploy-tx
FabijanC Apr 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
7 changes: 4 additions & 3 deletions starknet_devnet/blueprints/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

from flask import Blueprint, jsonify, request
from starkware.starknet.definitions.error_codes import StarknetErrorCode
from starkware.starknet.definitions.transaction_type import TransactionType
from starkware.starkware_utils.error_handling import StarkErrorCode

Expand Down Expand Up @@ -40,10 +41,10 @@ async def add_transaction():
response_dict["address"] = fixed_length_hex(contract_address)

elif tx_type == TransactionType.DEPLOY:
contract_address, transaction_hash = await state.starknet_wrapper.deploy(
transaction
raise StarknetDevnetException(
code=StarknetErrorCode.DEPRECATED_TRANSACTION,
message="Deploy transaction is no longer supported.",
)
response_dict["address"] = fixed_length_hex(contract_address)

elif tx_type == TransactionType.INVOKE_FUNCTION:
(contract_address, transaction_hash) = await state.starknet_wrapper.invoke(
Expand Down
2 changes: 0 additions & 2 deletions starknet_devnet/blueprints/rpc/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
from starknet_devnet.blueprints.rpc.transactions import (
add_declare_transaction,
add_deploy_account_transaction,
add_deploy_transaction,
add_invoke_transaction,
estimate_fee,
get_transaction_by_block_id_and_index,
Expand Down Expand Up @@ -73,7 +72,6 @@
"getNonce": get_nonce,
"addInvokeTransaction": add_invoke_transaction,
"addDeclareTransaction": add_declare_transaction,
"addDeployTransaction": add_deploy_transaction,
"addDeployAccountTransaction": add_deploy_account_transaction,
}

Expand Down
26 changes: 0 additions & 26 deletions starknet_devnet/blueprints/rpc/structures/payloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
TransactionType,
)
from starkware.starknet.services.api.gateway.transaction import (
Deploy,
DeployAccount,
DeprecatedDeclare,
InvokeFunction,
Expand Down Expand Up @@ -457,31 +456,6 @@ def make_declare(declare_transaction: RpcBroadcastedDeclareTxn) -> DeprecatedDec
return declare_tx


def make_deploy(deploy_transaction: RpcBroadcastedDeployTxn) -> Deploy:
"""
Convert RpcBroadcastedDeployTxn to Deploy
"""
contract_class = deploy_transaction["contract_class"]
if "abi" not in contract_class:
contract_class["abi"] = []

try:
contract_class["program"] = decompress_program(contract_class["program"])
contract_class = DeprecatedCompiledClass.load(contract_class)
except (StarkException, TypeError, MarshmallowError) as ex:
raise RpcError(code=50, message="Invalid contract class") from ex

deploy_tx = Deploy(
contract_address_salt=int(deploy_transaction["contract_address_salt"], 16),
constructor_calldata=[
int(data, 16) for data in deploy_transaction["constructor_calldata"]
],
contract_definition=contract_class,
version=int(deploy_transaction["version"], 16),
)
return deploy_tx


def make_deploy_account(
deploy_account_transaction: RpcBroadcastedDeployAccountTxn,
) -> DeployAccount:
Expand Down
21 changes: 1 addition & 20 deletions starknet_devnet/blueprints/rpc/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
from starknet_devnet.blueprints.rpc.structures.payloads import (
RpcBroadcastedDeclareTxn,
RpcBroadcastedDeployAccountTxn,
RpcBroadcastedDeployTxn,
RpcBroadcastedInvokeTxn,
RpcBroadcastedTxn,
RpcTransaction,
make_declare,
make_deploy,
make_deploy_account,
make_invoke_function,
rpc_fee_estimate,
Expand All @@ -28,7 +26,6 @@
from starknet_devnet.blueprints.rpc.structures.responses import (
RpcDeclareTransactionResult,
RpcDeployAccountTransactionResult,
RpcDeployTransactionResult,
RpcInvokeTransactionResult,
rpc_transaction_receipt,
)
Expand Down Expand Up @@ -135,22 +132,6 @@ async def add_declare_transaction(
)


@validate_schema("addDeployTransaction")
async def add_deploy_transaction(deploy_transaction: RpcBroadcastedDeployTxn) -> dict:
"""
Submit a new deploy contract transaction
"""
deploy_transaction = make_deploy(deploy_transaction)

contract_address, transaction_hash = await state.starknet_wrapper.deploy(
deploy_transaction=deploy_transaction
)
return RpcDeployTransactionResult(
transaction_hash=rpc_felt(transaction_hash),
contract_address=rpc_felt(contract_address),
)


@validate_schema("addDeployAccountTransaction")
async def add_deploy_account_transaction(
deploy_account_transaction: RpcBroadcastedDeployAccountTxn,
Expand Down Expand Up @@ -189,7 +170,7 @@ def make_transaction(txn: RpcBroadcastedTxn) -> AccountTransaction:
if txn_type == "DECLARE":
return make_declare(txn)
if txn_type == "DEPLOY":
return make_deploy(txn)
raise RpcError(code=-1, message="DEPLOY transactions are deprecated")
if txn_type == "DEPLOY_ACCOUNT":
return make_deploy_account(txn)
raise NotImplementedError(f"Unexpected type {txn_type}.")
Expand Down
53 changes: 2 additions & 51 deletions starknet_devnet/starknet_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
from starkware.starknet.core.os.contract_class.compiled_class_hash import (
compute_compiled_class_hash,
)
from starkware.starknet.core.os.transaction_hash.transaction_hash import (
calculate_deploy_transaction_hash,
)
from starkware.starknet.definitions.error_codes import StarknetErrorCode
from starkware.starknet.definitions.transaction_type import TransactionType
from starkware.starknet.services.api.contract_class.contract_class import (
Expand All @@ -54,7 +51,6 @@
)
from starkware.starknet.services.api.gateway.transaction import (
Declare,
Deploy,
DeployAccount,
DeprecatedDeclare,
InvokeFunction,
Expand Down Expand Up @@ -114,6 +110,7 @@

DEFAULT_BLOCK_ID = LATEST_BLOCK_ID


# pylint: disable=too-many-instance-attributes
# pylint: disable=too-many-public-methods
# pylint: disable=too-many-locals
Expand Down Expand Up @@ -215,6 +212,7 @@ async def __create_genesis_block(self):
deploy_data.append((account.class_hash, account.address))

for class_hash, contract_address in deploy_data:
# this might be the only place where DEPLOY tx is used
internal_deploy = create_empty_internal_deploy(
mikiw marked this conversation as resolved.
Show resolved Hide resolved
transaction_hash, class_hash, contract_address
)
Expand Down Expand Up @@ -543,53 +541,6 @@ async def deploy_account(self, external_tx: DeployAccount):
tx_handler.internal_tx.hash_value,
)

async def deploy(self, deploy_transaction: Deploy) -> Tuple[int, int]:
"""
Deploys the contract specified with `deploy_transaction`.
Returns (contract_address, transaction_hash).
"""

contract_class = deploy_transaction.contract_definition

internal_tx: InternalDeploy = InternalDeploy.from_external(
deploy_transaction, self.get_state().general_config
)

contract_address = internal_tx.contract_address

if await self.is_deployed(contract_address):
tx_hash = calculate_deploy_transaction_hash(
version=deploy_transaction.version,
contract_address=contract_address,
constructor_calldata=deploy_transaction.constructor_calldata,
chain_id=self.get_state().general_config.chain_id.value,
)
return contract_address, tx_hash

tx_hash = internal_tx.hash_value

async with self.__get_transaction_handler(
external_tx=deploy_transaction
) as tx_handler:
tx_handler.internal_tx = internal_tx
state = self.get_state().state
state.contract_classes[internal_tx.class_hash] = contract_class
self._contract_classes[internal_tx.class_hash] = contract_class

tx_handler.execution_info = await self.__deploy(internal_tx)
tx_handler.internal_calls = (
tx_handler.execution_info.call_info.internal_calls
)

tx_handler.deployed_contracts.append(
ContractAddressHashPair(
address=contract_address,
class_hash=internal_tx.class_hash,
)
)

return contract_address, tx_hash

async def invoke(self, external_tx: InvokeFunction):
"""Perform invoke according to specifications in `transaction`."""
state = self.get_state()
Expand Down
Loading