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(xcvm): simplify apply_bindings function #4119

Merged
merged 1 commit into from
Sep 27, 2023
Merged

feat(xcvm): simplify apply_bindings function #4119

merged 1 commit into from
Sep 27, 2023

Conversation

mina86
Copy link
Contributor

@mina86 mina86 commented Sep 7, 2023

Rather than dealing with pre-initialised buffer and having to track
indexes when setting data in the output payload, change the
apply_bindings function to append data into a vector which does index
tracking by itself. This removes offset tracking from the function
simplifying it. With that, change the function so it no longer takes
output vector as argument but rather allocates vector internally.

While changing the apply_bindings function in xc_core also change how
it’s used in the interpreter contract refactoring the code
slightly. Part of it is a consequence of changing the signature of the
apply_binding function but partially it’s just refactoring splitting
functions into smaller, more manageable chunks.

Required for merge:

  • pr-workflow-check / draft-release-check is ✅ success
  • Other rules GitHub shows you, or can be read in configuration

Makes review faster:

  • PR title is my best effort to provide summary of changes and has clear text to be part of release notes
  • I marked PR by misc label if it should not be in release notes
  • Linked Zenhub/Github/Slack/etc reference if one exists
  • I was clear on what type of deployment required to release my changes (node, runtime, contract, indexer, on chain operation, frontend, infrastructure) if any in PR title or description
  • Added reviewer into Reviewers
  • I tagged(@) or used other form of notification of one person who I think can handle best review of this PR
  • I have proved that PR has no general regressions of relevant features and processes required to release into production
  • Any dependency updates made, was done according guides from relevant dependency
  • Clicking all checkboxes
  • Adding detailed description of changes when it feels appropriate (for example when PR is big)

@github-actions
Copy link

github-actions bot commented Sep 7, 2023

Pull reviewers stats

Stats of the last 30 days for composable:

User Total reviews Time to review Total comments
dzmitry-lahoda 23 5h 31m 10
mina86 10 19h 36m 29
blasrodri 8 2h 35m 3
kkast 4 13h 48m 7
vmarkushin 3 7h 19m 2
RustNinja 3 1h 48m 0
JafarAz 2 9h 13m 0
0xBrainjar2 1 1d 12h 1m 0

@github-actions
Copy link

github-actions bot commented Sep 7, 2023

# run Composable node
nix run "github:ComposableFi/composable/refs/pull/4119/merge" --allow-import-from-derivation --extra-experimental-features "flakes nix-command" --no-sandbox --accept-flake-config --option sandbox relaxed
# run local Picasso DevNet (for CosmWasm development)
nix run "github:ComposableFi/composable/refs/pull/4119/merge#devnet-picasso" --allow-import-from-derivation --extra-experimental-features "flakes nix-command" --no-sandbox --accept-flake-config --option sandbox relaxed 
# CosmWasm on Substrate CLI tool
nix run "github:ComposableFi/composable/refs/pull/4119/merge#ccw" --allow-import-from-derivation --extra-experimental-features "flakes nix-command" --no-sandbox --accept-flake-config --option sandbox relaxed 
# run cross chain devnet with Dotsama and Cosmos nodes 
nix run "github:ComposableFi/composable/refs/pull/4119/merge#devnet-xc-fresh" --allow-import-from-derivation --extra-experimental-features "flakes nix-command" --no-sandbox --accept-flake-config --option sandbox relaxed 
# or same with docker
nix build "github:ComposableFi/composable/refs/pull/4119/merge#devnet-xc-image" --allow-import-from-derivation --extra-experimental-features "flakes nix-command" --no-sandbox --accept-flake-config --option sandbox relaxed \
&& docker load --input result && docker run -it --entrypoint bash devnet-xc:latest -c /bin/devnet-xc-fresh 

About nix

Rather than dealing with pre-initialised buffer and having to track
indexes when setting data in the output payload, change the
apply_bindings function to append data into a vector which does index
tracking by itself.  This removes offset tracking from the function
simplifying it.  With that, change the function so it no longer takes
output vector as argument but rather allocates vector internally.

While changing the apply_bindings function in xc_core also change how
it’s used in the interpreter contract refactoring the code slightly.
Part of it is a consequence of changing the signature of the
apply_binding function but partially it’s just refactoring splitting
functions into smaller, more manageable chunks.
@dzmitry-lahoda
Copy link
Contributor

Analogous, in semantics, approach work in Solidty EVM? As I recall design of feature (i do not know coding) was deterministic low on resource usage as require by Ethereum.

@mina86
Copy link
Contributor Author

mina86 commented Sep 7, 2023

I don’t see why this wouldn’t work for other blockchains. Fundamentally this does the same thing as the previous code. There’s just less code for tracking indexes and offsets and the vector resizes dynamically if needed. There could be some option to optimise it by using vectored output (so instead of collecting everything to single buffer have a Vec<Cow<[u8]>>) but whether that would require more support from other parts of the infrastructure.

@mina86 mina86 enabled auto-merge (squash) September 7, 2023 19:44
@dzmitry-lahoda
Copy link
Contributor

Let me write program which checks binding work(or not work), and test out same program on this one.

@github-actions
Copy link

stale-pr

@github-actions github-actions bot added the Stale-item bot: Stale PRs and issues handling #owned:terraform label Sep 12, 2023
@mina86 mina86 removed the Stale-item bot: Stale PRs and issues handling #owned:terraform label Sep 12, 2023
@dzmitry-lahoda dzmitry-lahoda self-assigned this Sep 13, 2023
@github-actions
Copy link

stale-pr

@github-actions github-actions bot added the Stale-item bot: Stale PRs and issues handling #owned:terraform label Sep 18, 2023
@mina86 mina86 removed the Stale-item bot: Stale PRs and issues handling #owned:terraform label Sep 20, 2023
@mina86
Copy link
Contributor Author

mina86 commented Sep 20, 2023

@dzmitry-lahoda, friendly ping

@dzmitry-lahoda
Copy link
Contributor

yeah, it is in the queue. need to test on devnet. to avoid breaking it (sure it may not work now, but I saw it working - so need to test before and after). i guess when write doc.

@dzmitry-lahoda
Copy link
Contributor

will test this week

@mina86 mina86 merged commit 2a40054 into main Sep 27, 2023
33 checks passed
@mina86 mina86 deleted the mpn/b branch September 27, 2023 21:17
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