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

On Simnet, in at-block, burn-block-height returns the highest latest value, not the value on that block #1615

Closed
Tracked by #1672
0xc22b opened this issue Nov 25, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@0xc22b
Copy link

0xc22b commented Nov 25, 2024

Describe the bug
On Simnet, in at-block, burn-block-height returns the highest latest value, not the value on that block

To Reproduce
Steps to reproduce the behavior:

  1. Run clarinet console with a smart contract below.
(define-read-only (get-burn (height uint))
    (let
        (
            (id (unwrap! (get-stacks-block-info? id-header-hash height) err-invalid-args))
        )
        (at-block id
            (ok { burn-block-height: burn-block-height, stacks-block-height: stacks-block-height })
        )
    )
)
  1. Run ::advance_burn_chain_tip 1 repeatedly
  2. Call the smart contract with different heights
(contract-call? .contract get-burn u3)

Expected behavior
burn-block-height should return the height for that at-block

Screenshots
Image

Environment (please complete the following information):

  • OS (version): macOS (14.7)
  • Clarinet version 2.11.2
@github-project-automation github-project-automation bot moved this to 🆕 New in DevTools Nov 25, 2024
@hugocaillard hugocaillard self-assigned this Nov 25, 2024
@hugocaillard hugocaillard moved this from 🆕 New to 🏗 In Progress in DevTools Nov 25, 2024
@jbencin
Copy link
Member

jbencin commented Nov 27, 2024

I tried reproducing this today. It does not happen in the default Epoch (2.05) and only happens in Epoch 3.0, so the full steps to reproduce are:

  1. ::set_epoch 3.0
    
  2. (define-read-only (get-burn (height uint))
        (let
            (
                (id (unwrap! (get-stacks-block-info? id-header-hash height) (err 1)))
            )
            (at-block id
                (ok { burn-block-height: burn-block-height, stacks-block-height: stacks-block-height })
            )
        )
    )
  3. ::advance_burn_chain_tip 100
    
  4. (contract-call? .contract-0 get-burn u3)

Which returns:

(ok { burn-block-height: u101, stacks-block-height: u3 })

The problem is that burn-block-height is calculated differently in Epoch 3.0, in a way that doesn't take into account the context set by at-block

@hugocaillard
Copy link
Collaborator

@0xc22b thanks for noticing and reporting this.
I'm closing this issue since this is an issue in stacks-core and not clarinet itself, feel free to follow it there.

Once stacks core releases a new epoch with the fix, clarinet will soon after support this new epoch as well

@github-project-automation github-project-automation bot moved this from 🏗 In Progress to ✅ Done in DevTools Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

3 participants