Skip to content

Commit

Permalink
Add gas measurements for
Browse files Browse the repository at this point in the history
ServiceRegistry.deposit() and ServiceRegistry.setURL().

This is a part of #1122.
  • Loading branch information
pirapira committed Jul 12, 2019
1 parent e32ae57 commit 8182ef4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 deletions.
26 changes: 14 additions & 12 deletions raiden_contracts/data/gas.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@
"CustomToken.transfer": 36123,
"CustomToken.transferFrom": 29557,
"MonitoringService.claimReward": 41931,
"MonitoringService.monitor": 207422,
"OneToN.claim": 92705,
"MonitoringService.monitor": 207736,
"OneToN.claim": 92786,
"SecretRegistry.registerSecret": 46892,
"TokenNetwork DEPLOYMENT": 4277369,
"TokenNetwork.closeChannel": 111155,
"ServiceRegistry.deposit": 433192,
"ServiceRegistry.setURL": 44555,
"TokenNetwork DEPLOYMENT": 4283201,
"TokenNetwork.closeChannel": 111439,
"TokenNetwork.openChannel": 97745,
"TokenNetwork.setTotalDeposit": 44909,
"TokenNetwork.setTotalWithdraw": 103306,
"TokenNetwork.settleChannel": 108229,
"TokenNetwork.unlock 1 locks": 31549,
"TokenNetwork.unlock 6 locks": 58649,
"TokenNetwork.updateNonClosingBalanceProof": 93786,
"TokenNetworkRegistry DEPLOYMENT": 4947971,
"TokenNetworkRegistry createERC20TokenNetwork": 3300096,
"TokenNetwork.setTotalDeposit": 44845,
"TokenNetwork.setTotalWithdraw": 103178,
"TokenNetwork.settleChannel": 108197,
"TokenNetwork.unlock 1 locks": 31485,
"TokenNetwork.unlock 6 locks": 58457,
"TokenNetwork.updateNonClosingBalanceProof": 93972,
"TokenNetworkRegistry DEPLOYMENT": 4953811,
"TokenNetworkRegistry createERC20TokenNetwork": 3304504,
"UserDeposit.deposit": 92392,
"UserDeposit.deposit (increase balance)": 32392,
"UserDeposit.planWithdraw": 64021,
Expand Down
22 changes: 22 additions & 0 deletions raiden_contracts/tests/test_print_gas.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
CONTRACT_MONITORING_SERVICE,
CONTRACT_ONE_TO_N,
CONTRACT_SECRET_REGISTRY,
CONTRACT_SERVICE_REGISTRY,
CONTRACT_TOKEN_NETWORK,
CONTRACT_TOKEN_NETWORK_REGISTRY,
CONTRACT_USER_DEPOSIT,
Expand Down Expand Up @@ -37,6 +38,8 @@ def test_gas_json_has_enough_fields(version: Optional[str]) -> None:
"MonitoringService.monitor",
"OneToN.claim",
"SecretRegistry.registerSecret",
"ServiceRegistry.deposit",
"ServiceRegistry.setURL",
"TokenNetwork DEPLOYMENT",
"TokenNetwork.closeChannel",
"TokenNetwork.openChannel",
Expand Down Expand Up @@ -371,6 +374,24 @@ def print_gas_user_deposit(
print_gas(txn_hash, CONTRACT_USER_DEPOSIT + ".withdraw")


@pytest.fixture
def print_gas_service_registry(
get_accounts: Callable, custom_token: Contract, service_registry: Contract, print_gas: Callable
) -> None:
(A,) = get_accounts(1)
custom_token.functions.mint(SERVICE_DEPOSIT).call_and_transact({"from": A})
custom_token.functions.approve(service_registry.address, SERVICE_DEPOSIT).call_and_transact(
{"from": A}
)

# happy path
deposit_tx = service_registry.functions.deposit(SERVICE_DEPOSIT).call_and_transact({"from": A})
print_gas(deposit_tx, CONTRACT_SERVICE_REGISTRY + ".deposit")
url = "http://example.com"
set_url_tx = service_registry.functions.setURL(url).call_and_transact({"from": A})
print_gas(set_url_tx, CONTRACT_SERVICE_REGISTRY + ".setURL")


@pytest.fixture
def print_gas_token(get_accounts: Callable, custom_token: Contract, print_gas: Callable) -> None:
(A, B) = get_accounts(2)
Expand All @@ -395,6 +416,7 @@ def print_gas_token(get_accounts: Callable, custom_token: Contract, print_gas: C
"print_gas_channel_cycle",
"print_gas_monitoring_service",
"print_gas_one_to_n",
"print_gas_service_registry",
"print_gas_user_deposit",
"print_gas_token",
)
Expand Down

0 comments on commit 8182ef4

Please sign in to comment.