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

fix(script/spawn): calucate the correct cycles_base #4123

Merged

Conversation

mohanson
Copy link
Contributor

What problem does this PR solve?

Problem Summary:

When current_cycles is called in spawn, only the sum of the cycles of the parent script and the current script is returned, and the grandpa script is not included.

What is changed and how it works?

What's Changed:

Add a cycles_base parameter to spawn. Make child script's cycles_base equal to parent script's cycles_base + parent script's machine.cycles()

Related changes

  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code ci-runs-only: [ quick_checks,linters ]

Release note

Note: Add a note under the PR title in the release note.

@mohanson mohanson requested a review from a team as a code owner August 29, 2023 02:58
@mohanson mohanson requested review from quake and removed request for a team August 29, 2023 02:58
@mohanson
Copy link
Contributor Author

TestCase:

https://github.com/libraries/ckb-spawn-current-cycles/blob/master/contracts/ckb-spawn-current-cycles/src/entry.rs

Output:

current cycle:11823, argv length:0 - 1
current cycle:159165, argv length:1 - 1
current cycle:166237, argv length:1 - 2 
current cycle:360299, argv length:2 - 1
current cycle:367371, argv length:2 - 2 
current cycle:562131, argv length:3 - 1
current cycle:569203, argv length:3 - 2 
current cycle:764625, argv length:4 - 1
current cycle:771697, argv length:4 - 2 
current cycle:973916, argv length:5 - 1
current cycle:980988, argv length:5 - 2 
current cycle:1183881, argv length:6 - 1
current cycle:1190993, argv length:6 - 2 
current cycle:1394589, argv length:7 - 1
current cycle:1401701, argv length:7 - 2 
current cycle:1607087, argv length:8 - 1
current cycle:1614199, argv length:8 - 2 
current cycle:1833376, argv length:9 - 1
current cycle:1840488, argv length:9 - 2 
current cycle:2060339, argv length:10 - 1
current cycle:2067501, argv length:10 - 2 
current cycle:2288059, argv length:11 - 1
current cycle:2295221, argv length:11 - 2 
current cycle:2516441, argv length:12 - 1
current cycle:2523603, argv length:12 - 2 
current cycle:2745485, argv length:13 - 1
current cycle:2752647, argv length:13 - 2 
current cycle:2975203, argv length:14 - 1
current cycle:2982365, argv length:14 - 2 
current cycle:3205583, argv length:15 - 1
current cycle:3212745, argv length:15 - 2 
current cycle:3435107, argv length:16 - 1
current cycle:3442269, argv length:16 - 2 
current cycle:3674453, argv length:17 - 1
current cycle:3681615, argv length:17 - 2 
current cycle:3914473, argv length:18 - 1
current cycle:3921635, argv length:18 - 2 
current cycle:4023702, argv length:18 - 3
current cycle:4040280, argv length:17 - 3
current cycle:4056858, argv length:16 - 3
current cycle:4073436, argv length:15 - 3
current cycle:4091201, argv length:14 - 3
current cycle:4108966, argv length:13 - 3
current cycle:4126731, argv length:12 - 3
current cycle:4144496, argv length:11 - 3
current cycle:4162261, argv length:10 - 3
current cycle:4180026, argv length:9 - 3
current cycle:4197741, argv length:8 - 3
current cycle:4214336, argv length:7 - 3
current cycle:4226594, argv length:6 - 3
current cycle:4238852, argv length:5 - 3
current cycle:4251110, argv length:4 - 3
current cycle:4263368, argv length:3 - 3
current cycle:4271809, argv length:2 - 3
current cycle:4280250, argv length:1 - 3
current cycle:4288691, argv length:0 - 3

@zhangsoledad zhangsoledad added this pull request to the merge queue Aug 29, 2023
Merged via the queue into nervosnetwork:develop with commit 7db3976 Aug 29, 2023
34 checks passed
@zhangsoledad zhangsoledad mentioned this pull request Aug 29, 2023
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