From 728649516f551bfb317506f9662d42c4e8abb142 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Thu, 12 Mar 2026 14:35:29 -0700 Subject: [PATCH 1/2] Update Flow CLI Install to use Latest Version --- .github/workflows/cadence_tests.yml | 2 +- .github/workflows/e2e_tests.yml | 2 +- .github/workflows/incrementfi_tests.yml | 2 +- .github/workflows/punchswap.yml | 2 +- .github/workflows/scheduled_rebalance_tests.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cadence_tests.yml b/.github/workflows/cadence_tests.yml index f3e23728..0a8693a7 100644 --- a/.github/workflows/cadence_tests.yml +++ b/.github/workflows/cadence_tests.yml @@ -37,7 +37,7 @@ jobs: restore-keys: | ${{ runner.os }}-flow-emulator-fork- - name: Install Flow CLI - run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v2.14.2-evm-manipulation-poc.1 + run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" - name: Flow CLI Version run: flow version - name: Update PATH diff --git a/.github/workflows/e2e_tests.yml b/.github/workflows/e2e_tests.yml index f349df89..1801af75 100644 --- a/.github/workflows/e2e_tests.yml +++ b/.github/workflows/e2e_tests.yml @@ -30,7 +30,7 @@ jobs: restore-keys: | ${{ runner.os }}-go- - name: Install Flow CLI - run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v2.14.2-evm-manipulation-poc.1 + run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" - name: Flow CLI Version run: flow version - name: Update PATH diff --git a/.github/workflows/incrementfi_tests.yml b/.github/workflows/incrementfi_tests.yml index 98d3191e..b2a269b8 100644 --- a/.github/workflows/incrementfi_tests.yml +++ b/.github/workflows/incrementfi_tests.yml @@ -20,7 +20,7 @@ jobs: token: ${{ secrets.GH_PAT }} submodules: recursive - name: Install Flow CLI - run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v2.14.2-evm-manipulation-poc.1 + run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" - name: Flow CLI Version run: flow version - name: Update PATH diff --git a/.github/workflows/punchswap.yml b/.github/workflows/punchswap.yml index 47f38a7c..af61fca4 100644 --- a/.github/workflows/punchswap.yml +++ b/.github/workflows/punchswap.yml @@ -26,7 +26,7 @@ jobs: cache-dependency-path: | **/go.sum - name: Install Flow CLI - run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v2.14.2-evm-manipulation-poc.1 + run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" - name: Flow CLI Version run: flow version - name: Update PATH diff --git a/.github/workflows/scheduled_rebalance_tests.yml b/.github/workflows/scheduled_rebalance_tests.yml index 6c226f16..97ad33a2 100644 --- a/.github/workflows/scheduled_rebalance_tests.yml +++ b/.github/workflows/scheduled_rebalance_tests.yml @@ -30,7 +30,7 @@ jobs: restore-keys: | ${{ runner.os }}-go- - name: Install Flow CLI - run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v2.14.2-evm-manipulation-poc.1 + run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" - name: Flow CLI Version run: flow version - name: Update PATH From 02efefbe86f7ad69d64fb7a95121fa7bd0c2af41 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Thu, 12 Mar 2026 14:49:09 -0700 Subject: [PATCH 2/2] Fix tests --- .../transactions/set_erc4626_vault_price.cdc | 19 +++++++++++--- .../set_uniswap_v3_pool_price.cdc | 26 +++++++++++-------- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/cadence/tests/transactions/set_erc4626_vault_price.cdc b/cadence/tests/transactions/set_erc4626_vault_price.cdc index 3d870b2e..5896ed26 100644 --- a/cadence/tests/transactions/set_erc4626_vault_price.cdc +++ b/cadence/tests/transactions/set_erc4626_vault_price.cdc @@ -6,7 +6,20 @@ import "FlowEVMBridgeUtils" access(all) fun computeMappingSlot(_ values: [AnyStruct]): String { let encoded = EVM.encodeABI(values) let hashBytes = HashAlgorithm.KECCAK_256.hash(encoded) - return String.encodeHex(hashBytes) + return "0x\(String.encodeHex(hashBytes))" +} + +// Helper: Convert UInt256 to zero-padded 64-char hex string (32 bytes) with 0x prefix +access(all) fun slotHex(_ value: UInt256): String { + let raw = value.toBigEndianBytes() + var padded: [UInt8] = [] + var padCount = 32 - raw.length + while padCount > 0 { + padded.append(0) + padCount = padCount - 1 + } + padded = padded.concat(raw) + return "0x\(String.encodeHex(padded))" } // Helper: Compute ERC20 balanceOf storage slot @@ -84,7 +97,7 @@ transaction( let finalTargetSupply = targetAssets * supplyMultiplier let supplyValue = String.encodeHex(finalTargetSupply.toBigEndianBytes()) - EVM.store(target: vault, slot: String.encodeHex(totalSupplySlot.toBigEndianBytes()), value: supplyValue) + EVM.store(target: vault, slot: slotHex(totalSupplySlot), value: supplyValue) // Update asset.balanceOf(vault) to finalTargetAssets let vaultBalanceSlot = computeBalanceOfSlot(holderAddress: vaultAddress, balanceSlot: assetBalanceSlot) @@ -120,6 +133,6 @@ transaction( assert(newSlotBytes.length == 32, message: "Vault storage slot must be exactly 32 bytes, got \(newSlotBytes.length) (lastUpdate: \(lastUpdateBytes.length), maxRate: \(maxRateBytes.length), assets: \(paddedAssets.length))") let newSlotValue = String.encodeHex(newSlotBytes) - EVM.store(target: vault, slot: String.encodeHex(vaultTotalAssetsSlot.toBigEndianBytes()), value: newSlotValue) + EVM.store(target: vault, slot: slotHex(vaultTotalAssetsSlot), value: newSlotValue) } } diff --git a/cadence/tests/transactions/set_uniswap_v3_pool_price.cdc b/cadence/tests/transactions/set_uniswap_v3_pool_price.cdc index 6b4b1b0a..e96a5093 100644 --- a/cadence/tests/transactions/set_uniswap_v3_pool_price.cdc +++ b/cadence/tests/transactions/set_uniswap_v3_pool_price.cdc @@ -4,7 +4,7 @@ import EVM from "MockEVM" access(all) fun computeMappingSlot(_ values: [AnyStruct]): String { let encoded = EVM.encodeABI(values) let hashBytes = HashAlgorithm.KECCAK_256.hash(encoded) - return String.encodeHex(hashBytes) + return "0x\(String.encodeHex(hashBytes))" } // Helper: Compute ERC20 balanceOf storage slot @@ -33,12 +33,16 @@ access(all) fun toHex32(_ value: UInt256): String { // Helper: Convert a slot number (UInt256) to its padded hex string for EVM.store/load access(all) fun slotHex(_ slotNum: UInt256): String { - return toHex32(slotNum) + return "0x\(toHex32(slotNum))" } // Helper: Parse a hex slot string back to UInt256 -access(all) fun slotToNum(_ slotHex: String): UInt256 { - let bytes = slotHex.decodeHex() +access(all) fun slotToNum(_ slot: String): UInt256 { + var hex = slot + if hex.length > 2 && hex.slice(from: 0, upTo: 2) == "0x" { + hex = hex.slice(from: 2, upTo: hex.length) + } + let bytes = hex.decodeHex() var num = 0 as UInt256 for byte in bytes { num = num * 256 + UInt256(byte) @@ -201,22 +205,22 @@ transaction( assert(slot0Value.length == 64, message: "slot0 must be 64 hex chars") // --- Slot 0: slot0 (packed) --- - EVM.store(target: poolAddr, slot: "0", value: slot0Value) + EVM.store(target: poolAddr, slot: slotHex(0), value: slot0Value) // Verify round-trip - let readBack = EVM.load(target: poolAddr, slot: "0") + let readBack = EVM.load(target: poolAddr, slot: slotHex(0)) let readBackHex = String.encodeHex(readBack) assert(readBackHex == slot0Value, message: "slot0 read-back mismatch - storage corruption!") // --- Slots 1-3: feeGrowthGlobal0X128, feeGrowthGlobal1X128, protocolFees = 0 --- let zero32 = "0000000000000000000000000000000000000000000000000000000000000000" - EVM.store(target: poolAddr, slot: "1", value: zero32) - EVM.store(target: poolAddr, slot: "2", value: zero32) - EVM.store(target: poolAddr, slot: "3", value: zero32) + EVM.store(target: poolAddr, slot: slotHex(1), value: zero32) + EVM.store(target: poolAddr, slot: slotHex(2), value: zero32) + EVM.store(target: poolAddr, slot: slotHex(3), value: zero32) // --- Slot 4: liquidity = uint128 max --- let liquidityAmount: UInt256 = 340282366920938463463374607431768211455 // 2^128 - 1 - EVM.store(target: poolAddr, slot: "4", value: toHex32(liquidityAmount)) + EVM.store(target: poolAddr, slot: slotHex(4), value: toHex32(liquidityAmount)) // --- Initialize boundary ticks --- // Tick storage layout per tick (4 consecutive slots): @@ -293,7 +297,7 @@ transaction( assert(obs0Bytes.length == 32, message: "observations[0] must be exactly 32 bytes") - EVM.store(target: poolAddr, slot: "8", value: String.encodeHex(obs0Bytes)) + EVM.store(target: poolAddr, slot: slotHex(8), value: String.encodeHex(obs0Bytes)) // --- Fund pool with token balances --- // Calculate 1 billion tokens in each token's decimal format