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

My take on dialects, which I think is now uniform in interface with the run_program from stage_0 #98

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

prozacchiwawa
Copy link
Contributor

May be controversial.

I made cuts needed to move some constants into a place where importing them would be possible from anywhere, improving dependency congestion.

Main visible differences:

  • There is now a dialect_factories collection the end user can use to get sane dialects.
  • Configuring a dialect to be a standard chia clvm runner is now a function that most python based dialects can use.
  • A configure method on dialects allows implementation specific communication

As used in clvm_tools, it's now possible to

        ````
        backend = args.backend if args.backend is not None else "python"
        dialect = dialect_factories[backend](
            KEYWORD_TO_ATOM["q"],
            KEYWORD_TO_ATOM["a"],
            args.strict,
            to_sexp_f
        )

        cost, result = dialect.run_program(
            run_script, input_sexp, max_cost=max_cost, pre_eval_f=pre_eval_f)
        ````

The dialect object is factored out of global paths, so it at least owns all its own information.

@richardkiss richardkiss changed the base branch from rework_py_api_2 to main August 13, 2021 20:26
try:
cost, result = prev(value)
except TypeError:
cost, result = prev(value,max_cost)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you run black on all the .py files to standardize formatting?

pip install black
black clvm tests

clvm/chia_dialect.py Outdated Show resolved Hide resolved
KEYWORD_FROM_ATOM = {int_to_bytes(k): v for k, v in enumerate(KEYWORDS)}
KEYWORD_TO_ATOM = {v: k for k, v in KEYWORD_FROM_ATOM.items()}

KEYWORD_TO_LONG_KEYWORD = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you build this table algorithmically from OP_REWRITE?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or vice-versa?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this constant is actually Chia dialect-specific.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I included it there mainly to avoid another layer when resolving dependencies, but it does make sense to put this on a layer in between.

@@ -7,6 +7,7 @@

dependencies = [
"blspy>=0.9",
"clvm_rs>=0.1.8"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's best to make clvm_rs an optional dependency. I expect that clvm_rs will eventually be completely standalone.

@richardkiss richardkiss changed the base branch from main to dialects August 13, 2021 21:50
CLVMAtom = Any
CLVMPair = Any

CLVMObjectType = Union["CLVMAtom", "CLVMPair"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I originally wrote this file, but I'm wondering if maybe we should remove CLVMObjectType since it's not actually used anywhere (and maybe other unused things in this file). It doesn't seem that mypy's typing system is advanced enough to do what we need to do.

@richardkiss richardkiss changed the base branch from dialects to main August 13, 2021 21:52
@@ -1,4 +1,4 @@
brun --backend=python -c -v '(x)'
brun -c -v '(x)'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops these should be replaced with a dialect choice. Will fix that.

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

Successfully merging this pull request may close these issues.

2 participants