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

CLI: Generate Reactor Stub #14

Closed
ivan-gavran opened this issue Jul 13, 2022 · 3 comments
Closed

CLI: Generate Reactor Stub #14

ivan-gavran opened this issue Jul 13, 2022 · 3 comments
Assignees

Comments

@ivan-gavran
Copy link
Collaborator

ivan-gavran commented Jul 13, 2022

Context: Reactor

Once the user has a TLA+ model, they need to write a reactor:
a set of Python functions connecting the actions of the model to executions of the code.

The task is to generate a stub for the reactor.

Task

The command that needs to be implemented is
atomkraft reactor <action-list> <model> [<reactor-stub-file>]
where

  • action-list is a list of actions for which to generate stubs
  • model is the TLA model for which we are implementing a reactor
  • reactor-stub-file is a path at which the reactor file should be created. If omitted, a default path is used.

The stub should include:

  • a stub for the testnet initialization function
@pytest.fixture(scope="session")
def testnet():
  chain_id = "test-cw"
  binary = <binary> # as setup in the init command
  denom = "stake"
  prefix = "juno" #TODO: clarify
  coin_type = 118 # TODO: clarify

  genesis_config = {
      "app_state.gov.voting_params.voting_period": "600s",
      "app_state.mint.minter.inflation": "0.300000000000000000",
  }

  node_config = {
      "config/app.toml": {
          "api.enable": True,
          "api.swagger": True,
          "api.enabled-unsafe-cors": True,
          "minimum-gas-prices": f"0.10{denom}",
          "rosetta.enable": False,
      },
      "config/config.toml": {
          "instrumentation.prometheus": False,
          "p2p.addr_book_strict": False,
          "p2p.allow_duplicate_ip": True,
      },
  }

  testnet = Testnet(
      chain_id,
      n_validator=3,
      n_account=3,
      binary=binary,
      denom=denom,
      prefix=prefix,
      coin_type=coin_type,
      genesis_config=genesis_config,
      node_config=node_config,
      account_balance=10**26,
      validator_balance=10**16,
  )

  testnet.oneshot()
  time.sleep(10)
  yield testnet
  time.sleep(2)
  • a stub for the state function
  @pytest.fixture
  def state():
      pass
  • for each action act from action-list, a stub for the step function connecting the abstract action to the code execution.
  @step("act")
  def act_step(testnet, state, var1, var2,..., vark):
      pass

where var1, var2,...,vark are all the variables of the model, state is the state provided by the function state, and testnet is the blockchain client provided by the function testnet

Finally, the stub should contain comments with guidance on how to use the stub.

@andrey-kuprianov
Copy link
Contributor

As all actions are supposed to be mapped into transactions on the blockchain, the stub could probably have a few additional components:

  • the (import of) the Pytest fixture that sets up the blockchain (this should be provided by the init command)
  • each action should have a parameter client that provides a client connected to the chain instance provided by the above fixture.

Not exactly part of the user interface, but downstream, to the run trace command, this component should provide the functionality to validate wether the reactor has been filled by the user correctly, contains all necessary actions, etc.

@ivan-gavran
Copy link
Collaborator Author

As all actions are supposed to be mapped into transactions on the blockchain, the stub could probably have a few additional components:

  • the (import of) the Pytest fixture that sets up the blockchain (this should be provided by the init command)
  • each action should have a parameter client that provides a client connected to the chain instance provided by the above fixture.

You are very right, I edited the description now

@ivan-gavran
Copy link
Collaborator Author

Duplicate of #16

@ivan-gavran ivan-gavran marked this as a duplicate of #16 Jul 13, 2022
@andrey-kuprianov andrey-kuprianov added this to the Atomkraft prototype milestone Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants