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

TX fails due to PrevrandaoNotSet on non-mainnet forks #4232

Closed
2 tasks done
Craigson opened this issue Jan 31, 2023 · 11 comments · Fixed by #9489
Closed
2 tasks done

TX fails due to PrevrandaoNotSet on non-mainnet forks #4232

Craigson opened this issue Jan 31, 2023 · 11 comments · Fixed by #9489
Assignees
Labels
A-testing Area: testing T-bug Type: bug

Comments

@Craigson
Copy link

Craigson commented Jan 31, 2023

Component

Anvil

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (31f945c 2023-01-30T00:05:12.356073Z)

What command(s) is the bug in?

anvil --fork-url https://moonbeam.blastapi.io/<api_key>

Operating System

macOS (Apple Silicon)

Describe the bug

Attempting to deploy a contract to local fork of the Moonbeam network

Run the local node:

anvil --fork-url https://moonbeam.blastapi.io/<api_key>

Deploy the contract:

forge script scripts/foundry/DeployGarage.s.sol:DeployGarage --rpc-url http://localhost:8545 --broadcast --legacy

Fails with:

Fork
==================
Endpoint:       https://moonbeam.blastapi.io/<api_key>
Block number:   2844720
Block hash:     0x1ee3577268a3d1f1fcb2da74d0b1cd4f56a6ccc89abe80771486551d3e9bdc2b
Chain ID:       1284
...
eth_blockNumber
eth_chainId
eth_getBlockByNumber
eth_chainId
eth_chainId
eth_sendRawTransaction

    Transaction: 0xd76504b4c53e2f0051c26f106469a0d47d1807fb3cc865aab50f064e017991cc
    Gas used: 0
    Error: failed due to PrevrandaoNotSet

    Block Number: 2844721
    Block Hash: 0x98f3806dff433e5c3d38550262854e0763980f3fa32bb0287356ff228df44964
    Block Time: "Tue, 31 Jan 2023 00:30:23 +0000"

eth_getTransactionReceipt
@Craigson Craigson added the T-bug Type: bug label Jan 31, 2023
@mattsse
Copy link
Member

mattsse commented Jan 31, 2023

can you please post an eth_getBlockByHash response from that provider?

@Craigson
Copy link
Author

Craigson commented Jan 31, 2023

@mattsse :

Local Fork

curl --location --request POST 'localhost:8545/' \
--header 'Content-Type: application/json' \
--data-raw '{
        "jsonrpc":"2.0",
        "method":"eth_getBlockByHash",
        "params":[
                "0x84fa58a278a7fd1782796fb62f728c5cf687212a022c621ecc03532be4f64eb3",
                true
        ],
        "id":1
}'

with response:

{"jsonrpc":"2.0","id":1,"result":{"hash":"0x84fa58a278a7fd1782796fb62f728c5cf687212a022c621ecc03532be4f64eb3","parentHash":"0x4b3d5f405d87b9ce1bf7f3bf43a148fa74489f9216c5cc49a1b332af01510b93","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0xbb470b51ea61958a789f9e2c8ae17577dcad600ee55731cd9197c1fd776dff53","receiptsRoot":"0x703c035562d8e37c66f2f9461219b45c710e59c8d0d234f6b062107de627758c","number":"0x2b78f1","gasUsed":"0x0","gasLimit":"0xe4e1c0","extraData":"0x","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","timestamp":"0x63d92d74","difficulty":"0x0","totalDifficulty":"0x0","sealFields":["0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000"],"uncles":[],"transactions":[{"hash":"0x1e59a2767f2960bc4ceaded667cd8493a2815925735916f0ffbe0cac0619d892","nonce":"0x4","blockHash":"0x84fa58a278a7fd1782796fb62f728c5cf687212a022c621ecc03532be4f64eb3","blockNumber":"0x2b78f1","transactionIndex":"0x0","from":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","to":null,"value":"0x0","gasPrice":"0x14f42e429d","gas":"0x2090f","input":"0x6080604052348015600f57600080fd5b506063600055607d806100236000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80634e70b1dc14602d575b600080fd5b603560005481565b60405190815260200160405180910390f3fea2646970667358221220bf8077bb444b3110164dd2d4b292160bc8c702eab717c0c61fa80178183a557c64736f6c634300080f0033","v":"0xa2c","r":"0x2a328141daded32b3c27496ff65eab47f643af176ebbeb522d222dced8f48d62","s":"0x7fc65be499cfcbc148459f118bf9e96c59e8649de9bb07b056dd0e6b9260cb43","type":"0x0","maxPriorityFeePerGas":"0x14f42e429d","maxFeePerGas":"0x14f42e429d","chainId":"0x504"}],"size":"0x2fc","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x14b893789d"}}

Node provider

https://gist.github.com/Craigson/3c97f492199f30f634dea44d4516ac2d

@mattsse
Copy link
Member

mattsse commented Jan 31, 2023

hmm
mixHash is definitely present in the response so no idea why prevrandao is not set.

@Craigson
Copy link
Author

Craigson commented Feb 1, 2023

@mattsse looks like this was fixed in #4238 , thank you!

@dung5ire
Copy link

dung5ire commented Oct 1, 2024

Hi. I am still getting issue in 5ireChain testnet

My command for testing:

forge script script/deploy.s.sol --private-key <my private key>  --broadcast --legacy --rpc-url https://rpc.testnet.5ire.network/

My issue:

- Error #0: header validation error: `prevrandao` not set
- Error #1: `prevrandao` not set

My forge version is : forge 0.2.0 (3ff3d0562 2024-10-01T08:39:18.585271000Z)

I am able to cast run

cast run --rpc-url https://rpc.testnet.5ire.network 0x83c9e9c16d2f86d4692b65be62ff70d7f9bd2cfec469fd3ef6b32fcad1581ab5
Executing previous transactions from the block.
Traces:
  [66306] 0x1c04a522FDd4B3c115057C4f4c255Cd9586A9801::setPricesWithBits(176664478902489129649911 [1.766e23], 1729743721 [1.729e9])
    ├─ [4108] 0x2c588b061059dC61B551F381818f78AeF57aDF94::emitPriceEvent(0x0b3BC705ff5335D31f66057C626915b637aa3685, 67077879000000000000000000000000000 [6.707e34])
    │   ├─ emit PriceUpdate(: 0x0b3BC705ff5335D31f66057C626915b637aa3685, : 67077879000000000000000000000000000 [6.707e34], : 0x1c04a522FDd4B3c115057C4f4c255Cd9586A9801)
    │   └─ ← [Stop] 
    ├─ [2108] 0x2c588b061059dC61B551F381818f78AeF57aDF94::emitPriceEvent(0xf27D49dc283Df73af8436f0Ea7FFa63293956fad, 2539850000000000000000000000000000 [2.539e33])
    │   ├─ emit PriceUpdate(: 0xf27D49dc283Df73af8436f0Ea7FFa63293956fad, : 2539850000000000000000000000000000 [2.539e33], : 0x1c04a522FDd4B3c115057C4f4c255Cd9586A9801)
    │   └─ ← [Stop] 
    ├─ [2108] 0x2c588b061059dC61B551F381818f78AeF57aDF94::emitPriceEvent(0x4C504E825eeFe951A5d94e6f87Ff34fC559A3307, 9577000000000000000000000000 [9.577e27])
    │   ├─ emit PriceUpdate(: 0x4C504E825eeFe951A5d94e6f87Ff34fC559A3307, : 9577000000000000000000000000 [9.577e27], : 0x1c04a522FDd4B3c115057C4f4c255Cd9586A9801)
    │   └─ ← [Stop] 
    └─ ← [Stop] 


Transaction successfully executed.
Gas used: 87782

@dung5ire
Copy link

May I open this issue again ? @mattsse

@Lohann
Copy link

Lohann commented Oct 26, 2024

Same case here

@anajuliabit
Copy link

@mattsse could you reopen please? This is happening after I upgrade foundry version on ci moonwell-fi/moonwell-contracts-v2#437

@zerosnacks zerosnacks reopened this Dec 4, 2024
@zerosnacks zerosnacks added the T-to-investigate Type: to investigate label Dec 4, 2024
@zerosnacks
Copy link
Member

Hi @anajuliabit

This likely relates to the recent upgrade to default the evm_version to cancun rather than paris. Perhaps are trying to deploy to a chain that does not support shanghai (push0)?

https://github.com/moonwell-fi/moonwell-contracts-v2/blob/a3559fe4d379ff0874fd4a3202d4a019bc6267aa/foundry.toml#L9

To resolve this you could manually pass --evm-version paris in forge script

@anajuliabit
Copy link

that doesn't seams to work @zerosnacks

46.470 total
(1) 46s anajulia ~/code/moonwell-contracts-v2
%  time forge test --match-contract MoonbeamTest --fork-url moonbeam -vvv --evm-version paris   
[⠊] Compiling...
[⠒] Compiling 225 files with Solc 0.8.19
[⠢] Compiling 12 files with Solc 0.8.10
[⠒] Solc 0.8.10 finished in 1.09s
[⠔] Solc 0.8.19 finished in 38.01s
Compiler run successful!

Ran 1 test for test/integration/xWELL/DeployxWellMoonbeamIntegration.t.sol:DeployxWellMoonbeamTest
[FAIL: backend: failed while inspecting; header validation error: `prevrandao` not set; `prevrandao` not set; ] setUp() (gas: 0)
```

@mattsse
Copy link
Member

mattsse commented Dec 4, 2024

@zerosnacks I believe this happens because moonbeam doesn't return a mixHash

@zerosnacks zerosnacks self-assigned this Dec 5, 2024
@zerosnacks zerosnacks added A-testing Area: testing and removed T-to-investigate Type: to investigate labels Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testing Area: testing T-bug Type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants