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

Open
0xc22b opened this issue Nov 25, 2024 · 1 comment
Assignees

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🏗 In Progress
Development

No branches or pull requests

3 participants