Skip to content

sapphire-foundry: Remove hardcode Subcall paths for invoking FFI #638

@matevz

Description

@matevz
SUMMARY

Hardcoded directories in BinaryContracts (https://github.com/oasisprotocol/sapphire-paratime/blob/main/integrations/foundry/lib/oasisprotocol-sapphire-foundry/BinaryContracts.sol#L16) cause this documentation steps to fail https://github.com/oasisprotocol/docs/blob/main/docs/build/tools/foundry.mdx#installing-sapphire-foundry-optional because soldeer installs the package to dependencies/@oasisprotocol-sapphire-foundry-0.1.2/ instead of lib/oasisprotocol-sapphire-foundry.

Find a way to obtain the working path on-the-fly. I would try to extract this info from remappings.txt. Probably there is already a call in foundry for this.

ISSUE TYPE
  • Bug Report
STEPS TO REPRODUCE

Follow https://github.com/oasisprotocol/docs/blob/main/docs/build/tools/foundry.mdx#installing-sapphire-foundry-optional

ACTUAL RESULTS

When running forge test it returns:

$ forge test -vvv
[⠊] Compiling...
No files changed, compilation skipped

Ran 3 tests for test/PriceFeedDirectory.t.sol:PriceFeedDirectoryTest
[FAIL: SubcallError()] test_addFeed_existing_agg() (gas: 26808)
Traces:
  [26808] PriceFeedDirectoryTest::test_addFeed_existing_agg()
    ├─ [18790] PriceFeedDirectory::addFeed("bitstamp.net/btc_usd", SimpleAggregator: [0x2e234DAe75C793f67A35089C9d99245E1C58470b], false)
    │   ├─ [13016] SUBCALL::00000000(000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000e726f666c2e4f726967696e4170700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001f600000000000000000000000000000000000000000000000000000000000000) [staticcall]
    │   │   ├─ [0] VM::getBlockNumber() [staticcall]
    │   │   │   └─ ← [Return] 1
    │   │   ├─ [0] VM::toString(0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c01234567890123456789012345678901234567890123456789012345678901234000000000000000000000000000000000000000000000000000000000000000e726f666c2e4f726967696e4170700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001f600000000000000000000000000000000000000000000000000000000000000) [staticcall]
    │   │   │   └─ ← [Return] "0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c01234567890123456789012345678901234567890123456789012345678901234000000000000000000000000000000000000000000000000000000000000000e726f666c2e4f726967696e4170700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001f600000000000000000000000000000000000000000000000000000000000000"
    │   │   ├─ [0] VM::ffi(["lib/oasisprotocol-sapphire-foundry/precompiles/target/release/subcall", "0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c01234567890123456789012345678901234567890123456789012345678901234000000000000000000000000000000000000000000000000000000000000000e726f666c2e4f726967696e4170700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001f600000000000000000000000000000000000000000000000000000000000000"])
    │   │   │   └─ ← [Revert] vm.ffi: failed to execute command cd "/home/oa/rofl-price-oracle/contracts" && "lib/oasisprotocol-sapphire-foundry/precompiles/target/release/subcall" "0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c01234567890123456789012345678901234567890123456789012345678901234000000000000000000000000000000000000000000000000000000000000000e726f666c2e4f726967696e4170700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001f600000000000000000000000000000000000000000000000000000000000000": No such file or directory (os error 2)
    │   │   └─ ← [Revert] vm.ffi: failed to execute command cd "/home/oa/rofl-price-oracle/contracts" && "lib/oasisprotocol-sapphire-foundry/precompiles/target/release/subcall" "0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c01234567890123456789012345678901234567890123456789012345678901234000000000000000000000000000000000000000000000000000000000000000e726f666c2e4f726967696e4170700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001f600000000000000000000000000000000000000000000000000000000000000": No such file or directory (os error 2)
    │   └─ ← [Revert] SubcallError()
    └─ ← [Revert] SubcallError()
EXPECTED RESULTS

Running forge test should work out of the box.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions