Skip to content

Borsh serde read solana #176

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

Open
wants to merge 7 commits into
base: dev-solana-v2-add-solana
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
| Error | Signature |
|-------|-----------|
| `InvalidSwitchboardTest(bytes32,bytes32)` | `0x702f36a1` |
| `InvalidGatewayTest(bytes32,bytes32,bytes32)` | `0xc6ad0fcf` |

## evmx/watcher/RequestHandler.sol

Expand Down
3 changes: 1 addition & 2 deletions FunctionSignatures.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@
| -------- | --------- |
| `addressResolver__` | `0x6a750469` |
| `asyncDeployer__` | `0x2a39e801` |
| `callSolana` | `0x8af147d3` |
| `callSolana` | `0x4ef7957b` |
| `chainSlug` | `0xb349ba65` |
| `deployForwarder__` | `0xd4e3b034` |
| `feesManager__` | `0x70568b58` |
Expand Down Expand Up @@ -553,7 +553,6 @@
| `completeOwnershipHandover` | `0xf04e283e` |
| `contractFactoryPlugs` | `0x35426631` |
| `digestHashes` | `0xd1a862bf` |
| `encodeU64Borsh` | `0xacc1b559` |
| `expiryTime` | `0x99bc0aea` |
| `getDigest` | `0x91b6288b` |
| `getPrecompileFees` | `0xb7a3d04c` |
Expand Down
30 changes: 5 additions & 25 deletions contracts/evmx/helpers/ForwarderSolana.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ contract ForwarderSolana is ForwarderStorage, Initializable, AddressResolverUtil
/// @param addressResolver_ address resolver contract
function initialize(
uint32 chainSlug_,
bytes32 onChainAddress_,
bytes32 onChainAddress_, // TODO:GW: after demo remove this param, we take target as param in callSolana()
address addressResolver_
) public initializer {
if (chainSlug_ == CHAIN_SLUG_SOLANA_MAINNET || chainSlug_ == CHAIN_SLUG_SOLANA_DEVNET) {
Expand Down Expand Up @@ -76,7 +76,7 @@ contract ForwarderSolana is ForwarderStorage, Initializable, AddressResolverUtil
/// @notice Fallback function to process the contract calls to onChainAddress
/// @dev It queues the calls in the middleware and deploys the promise contract
// function callSolana(SolanaInstruction memory solanaInstruction, bytes32 switchboardSolana) external {
function callSolana(SolanaInstruction memory solanaInstruction) external {
function callSolana(bytes memory solanaPayload, bytes32 target) external {
if (address(addressResolver__) == address(0)) {
revert AddressResolverNotSet();
}
Expand All @@ -97,37 +97,17 @@ contract ForwarderSolana is ForwarderStorage, Initializable, AddressResolverUtil
// get the switchboard address from the watcher precompile config
// address switchboard = watcherPrecompileConfig().switchboards(chainSlug, sbType);

bytes memory solanaPayload = abi.encode(solanaInstruction);

// Queue the call in the middleware.
QueueParams memory queueParams;
queueParams.overrideParams = overrideParams;
queueParams.transaction = Transaction({
chainSlug: chainSlug,
target: onChainAddress,
// target: onChainAddress, // for Solana reads it should be accountToRead
// TODO: Solana forwarder can be a singleton - does not need to store onChainAddress and can use target as param
target: target,
payload: solanaPayload
});
queueParams.switchboardType = sbType;
watcher__().queue(queueParams, msgSender);

// Queue the call in the middleware.
// deliveryHelper__().queue(
// QueuePayloadParams({
// chainSlug: chainSlug,
// callType: isReadCall == Read.ON ? CallType.READ : CallType.WRITE,
// isParallel: isParallelCall,
// isPlug: IsPlug.NO,
// writeFinality: writeFinality,
// asyncPromise: latestAsyncPromise,
// switchboard: switchboardSolana,
// target: onChainAddress,
// appGateway: msg.sender,
// gasLimit: gasLimit,
// value: value,
// readAt: readAt,
// payload: solanaPayload,
// initCallData: bytes("")
// })
// );
}
}
8 changes: 5 additions & 3 deletions contracts/evmx/watcher/Configurations.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ abstract contract ConfigurationsStorage is IConfigurations {
uint256[50] _gap_before;

error InvalidSwitchboardTest(bytes32 sb, bytes32 sbExpected);
error InvalidGatewayTest(bytes32 appGatewayId, bytes32 appGatewayIdExpected, bytes32 switchboard);

// slot 50
/// @notice Maps network and plug to their configuration
Expand Down Expand Up @@ -163,13 +164,14 @@ contract Configurations is ConfigurationsStorage, Initializable, Ownable, Watche
bytes32 target_,
address appGateway_,
bytes32 switchboardType_
// ) external {
) external view {
(bytes32 appGatewayId, bytes32 switchboard) = getPlugConfigs(chainSlug_, target_);
if (appGatewayId != toBytes32Format(appGateway_)) revert InvalidGateway();
// if (appGatewayId != toBytes32Format(appGateway_)) revert InvalidGateway();
if (appGatewayId != toBytes32Format(appGateway_)) revert InvalidGatewayTest(appGatewayId, toBytes32Format(appGateway_), switchboard);
// emit VerifyConnectionsSB(switchboard, switchboards[chainSlug_][switchboardType_]);
// if (switchboard != switchboards[chainSlug_][switchboardType_]) revert InvalidSwitchboard();
if (switchboard != switchboards[chainSlug_][switchboardType_]) revert InvalidSwitchboardTest(switchboard, switchboards[chainSlug_][switchboardType_]);
if (switchboard != switchboards[chainSlug_][switchboardType_])
revert InvalidSwitchboardTest(switchboard, switchboards[chainSlug_][switchboardType_]);
}

/**
Expand Down
Loading