Skip to content

Conversation

advaita-saha
Copy link
Contributor

@advaita-saha advaita-saha commented Aug 26, 2025

Goal is to first integrate constantine and check performance metrics for all precompiles

  • Integrate only parts which give us a performance boost
  • Solve unbounded stack issue

Stats:-

  • ECREC ( not working )
  • SHA256
  • RIPEMD160
  • ID
  • MODEXP
  • BN254_ADD
  • BN254_MUL
  • BN254_PAIRING ( errors in EEST )
  • BLAKE2F ( not available )
  • KZG_POINT_EVALUATION
  • BLS12_G1ADD
  • BLS12_G1MSM
  • BLS12_G2ADD
  • BLS12_G2MSM
  • BLS12_PAIRING_CHECK
  • BLS12_MAP_FP_TO_G1
  • BLS12_MAP_FP2_TO_G2
  • P256_VERIFY ( not available )

Note

Need to create a error handler for constantine type errors

@advaita-saha advaita-saha marked this pull request as draft August 26, 2025 11:01
@advaita-saha
Copy link
Contributor Author

advaita-saha commented Aug 26, 2025

Current issue

eest_blockchain_test  →  processBlock  →  processTransactions
→ processTransaction → call_evm.txCallEvm → runComputation
→ interpreter_dispatch.executeOpcodes → precompiles.execPrecompile (line 842)
→ ecRecover
→ constantine/ethereum_evm_precompiles.nim(1360) ctt_eth_evm_ecrecover
→ …/signatures/ecdsa.nim recoverPubkeyImpl…
→ …/math/elliptic/ec_scalar_mul.nim(426) scalarMulGLV_m2w2  ⟵ hot loop
→ …/elliptic/ec_shortweierstrass_jacobian.nim(618) pluseq …

So the test runner was executing a transaction that hit the ECRECOVER precompile; it was “stuck” (busy) inside Constantine’s secp256k1 scalar multiplication (GLV path), i.e., the inner loop that accumulates points for the pubkey recovery.

NOTE: It is stuck for hours
https://github.com/status-im/nimbus-eth1/actions/runs/17236072804/job/48901163025?pr=3587

Exact input causing issue
18c547e4f7b0f325ad1e56f57e26c745b09a3e503d86e00e5255ff7f715d3d1c000000000000000000000000000000000000000000000000000000000000001c00b1693892219d736caba55bdb67216e485557ea6b6af75f37096c9aa6a5a75feeb940b1d03b21e36b0e47e79769f095fe2ab855bd91e3a38756b7d75a9c4549

@advaita-saha
Copy link
Contributor Author

advaita-saha commented Aug 27, 2025

Issues found with eth_evm_bn254_ecpairingcheck in constantine implementation.
Failing the following EEST tests

TestName: tests/static/state_tests/stZeroKnowledge/ecpairing_inputsFiller.yml::ecpairing_inputs[fork_Cancun-blockchain_test_from_state_test-d1-g0-v0] RunTest error: A bug? good block rejected: gasUsed mismatch
TestName: tests/static/state_tests/stZeroKnowledge/ecpairing_inputsFiller.yml::ecpairing_inputs[fork_Cancun-blockchain_test_from_state_test-d3-g0-v0] RunTest error: A bug? good block rejected: gasUsed mismatch
TestName: tests/static/state_tests/stZeroKnowledge/ecpairing_inputsFiller.yml::ecpairing_inputs[fork_Prague-blockchain_test_from_state_test-d1-g0-v0] RunTest error: A bug? good block rejected: gasUsed mismatch
TestName: tests/static/state_tests/stZeroKnowledge/ecpairing_inputsFiller.yml::ecpairing_inputs[fork_Prague-blockchain_test_from_state_test-d3-g0-v0] RunTest error: A bug? good block rejected: gasUsed mismatch
TestName: tests/static/state_tests/stZeroKnowledge/ecpairing_two_points_with_one_g2_zeroFiller.json::ecpairing_two_points_with_one_g2_zero[fork_Cancun-blockchain_test_from_state_test-d0-g0-v0] RunTest error: A bug? good block rejected: gasUsed mismatch
TestName: tests/static/state_tests/stZeroKnowledge/ecpairing_two_points_with_one_g2_zeroFiller.json::ecpairing_two_points_with_one_g2_zero[fork_Cancun-blockchain_test_from_state_test-d0-g3-v0] RunTest error: A bug? good block rejected: gasUsed mismatch
TestName: tests/static/state_tests/stZeroKnowledge/ecpairing_two_points_with_one_g2_zeroFiller.json::ecpairing_two_points_with_one_g2_zero[fork_Prague-blockchain_test_from_state_test-d0-g0-v0] RunTest error: A bug? good block rejected: gasUsed mismatch
TestName: tests/static/state_tests/stZeroKnowledge/ecpairing_two_points_with_one_g2_zeroFiller.json::ecpairing_two_points_with_one_g2_zero[fork_Prague-blockchain_test_from_state_test-d0-g3-v0] RunTest error: A bug? good block rejected: gasUsed mismatch

Exact implementation issue still not investigated

UPDATE : Fixed 8th Sept

@arnetheduck
Copy link
Member

Regarding constantine, my recommendation is that the initial branch integrates sha256 only as a start - once that is working (ie sha256 is confirmed to be fast, constantine subrepo is present and so on), separate branches can be used for each precompile - in particular, this allows measuring (in benchmarks) and rolling back precompiles on an individual basis.

@advaita-saha
Copy link
Contributor Author

Linux arm and windows arm issues
mratsim/constantine#582

Comment on lines 59 to +62
if defined(windows):
# Constantine
switch("passC", "-fomit-frame-pointer")
switch("passL", "-fomit-frame-pointer")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constantine windows issue

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