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

Ndev 3380 compasability for iterative trx #456

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d7b8a00
added iterative tests for compasibility
kristinaNikolaevaa Nov 21, 2024
2b4b2d4
added proxy tests
kristinaNikolaevaa Nov 21, 2024
09f7fac
Merge branch 'develop' into NDEV-3380
kristinaNikolaevaa Nov 25, 2024
aeeb02a
added one more test for evm
kristinaNikolaevaa Nov 27, 2024
99ffd1e
Merge branch 'develop' into NDEV-3380
kristinaNikolaevaa Dec 11, 2024
76ecb68
fix test_step_from_instruction_for_counter: use holder account with f…
romanova-natasha Dec 12, 2024
817e0d9
fix iterative transaction tests: reduce iteration lenght
romanova-natasha Dec 12, 2024
327b649
Merge branch 'develop' into NDEV-3380
kristinaNikolaevaa Dec 12, 2024
1b4e143
fix: new holder account for all interoperability tests
romanova-natasha Dec 12, 2024
d19510e
add composability test cases: iterative actions + solana call/calls, …
romanova-natasha Dec 13, 2024
834d901
fix deploy contract and solana call test
romanova-natasha Dec 13, 2024
104b7a0
rm tests with no iterative txs check
romanova-natasha Dec 13, 2024
01e2828
check holder account state after tx execution
romanova-natasha Dec 13, 2024
53c473c
rename test test_solana_call_before_iterative_actions
romanova-natasha Dec 13, 2024
8b95fbb
add case: eip 1559 iterative tx check with program_id = transfer_toke…
romanova-natasha Dec 17, 2024
05d9542
add case: failed solana call
romanova-natasha Dec 17, 2024
1604cab
add case: iterative tx with solana call in sol network
romanova-natasha Dec 17, 2024
0392e6a
rm dbg info
romanova-natasha Dec 18, 2024
92ddd80
add case: iterative tx with send tokens
romanova-natasha Dec 19, 2024
0ad085e
add case of solana call with 2 programs, minor refactoring
romanova-natasha Dec 19, 2024
ab96edc
fix review
romanova-natasha Dec 19, 2024
4e9f1ab
NDEV-3380 change tests order for tests test_iterative_actions_and_mul…
artem-yazkov Dec 23, 2024
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
2 changes: 1 addition & 1 deletion contracts/common/StorageSoliditySource.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ contract Storage {
return msg.sender.balance;
}

function storeSumOfNumbers(uint256 num1, uint256 num2) public view returns (uint256) {
function storeSumOfNumbers(uint256 num1, uint256 num2) public view returns (uint256) {
if (number == 101) {
num1 = 0;
}
Expand Down
148 changes: 127 additions & 21 deletions contracts/precompiled/CallSolanaCaller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ pragma solidity >=0.7.0 <0.9.0;
pragma abicoder v2;

import "../external/neon-evm/call_solana.sol";

import "../common/StorageSoliditySource.sol";

contract CallSolanaCaller {
CallSolana constant _callSolana =
CallSolana(0xFF00000000000000000000000000000000000006);
struct Data {
uint256 value1;
uint256 value2;
}
mapping(uint256 => Data) public dataMap;

CallSolana constant _callSolana = CallSolana(0xFF00000000000000000000000000000000000006);
struct ExecuteArgs {
uint64 lamports;
bytes instruction;
Expand All @@ -17,73 +23,173 @@ contract CallSolanaCaller {
bytes instruction;
}


event LogBytes(bytes32 value);
event LogStr(string value);
event LogAddress(address value);
event LogData(bytes32 program, bytes value);

function getNeonAddress(address addr) public returns (bytes32){
function getNeonAddress(address addr) public returns (bytes32) {
bytes32 solanaAddr = _callSolana.getNeonAddress(addr);
return solanaAddr;
}

function execute(uint64 lamports, bytes calldata instruction) public {
bytes32 returnData = bytes32(_callSolana.execute(lamports, instruction));
bytes32 returnData = bytes32(
_callSolana.execute(lamports, instruction)
);
emit LogBytes(returnData);
}

function executeInIterativeMode(
uint256 actionsNumber,
uint64 lamports,
bytes calldata instruction
) public {
doIterativeActions(actionsNumber);
execute(lamports, instruction);
}

function executeAndDoSomeIterativeActions(
uint256 actionsNumber,
uint64 lamports,
bytes calldata instruction
) public {
execute(lamports, instruction);
doIterativeActions(actionsNumber);
}

function executeMultipleInIterativeMode(
uint256 calls,
uint256 actionsNumber,
uint64 lamports,
bytes calldata instruction
) public {
doIterativeActions(actionsNumber);
for (uint256 i = 0; i < calls; i++) {
execute(lamports, instruction);
}
}

function batchExecuteInIterativeMode(
uint256 actionsNumber,
ExecuteArgs[] memory _args
) public {
doIterativeActions(actionsNumber);
batchExecute(_args);
}

function sendTokensAndExecuteInIterativeMode(
uint256 actionsNumber,
uint64 lamports,
bytes calldata instruction
) public payable {
executeInIterativeMode(actionsNumber, lamports, instruction);
}

function doSomeIterativeActions(uint256 actionsNumber) public {
doIterativeActions(actionsNumber);
emit LogStr("iterative actions status: done");
}

function doIterativeActions(uint actionsNumber) public {
// some actions to make the call iterative
for (uint256 i = 0; i < actionsNumber; i++) {
Data memory newData = Data({value1: 1, value2: 2});
dataMap[i] = newData;
}
}

function deployStorageAndCallSolana(
string memory message,
uint64 lamports,
bytes calldata instruction
) public {
Storage storageContract = new Storage();
storageContract.store(10);
require(storageContract.retrieve() == 10);
execute(lamports, instruction);
emit LogAddress(address(storageContract));
}

function execute_with_get_return_data(uint64 lamports, bytes calldata instruction) public {
function execute_with_get_return_data(
uint64 lamports,
bytes calldata instruction
) public {
_callSolana.execute(lamports, instruction);
(bytes32 program, bytes memory returnData) = _callSolana.getReturnData();
(bytes32 program, bytes memory returnData) = _callSolana
.getReturnData();
emit LogData(program, returnData);
}

function batchExecute(ExecuteArgs[] memory _args) public {
for(uint i = 0; i < _args.length; i++) {
for (uint i = 0; i < _args.length; i++) {
_callSolana.execute(_args[i].lamports, _args[i].instruction);
}
(bytes32 program, bytes memory returnData) = _callSolana.getReturnData();
(bytes32 program, bytes memory returnData) = _callSolana
.getReturnData();
emit LogData(program, returnData);
}

function getPayer() public returns (bytes32){
function getPayer() public returns (bytes32) {
bytes32 payer = _callSolana.getPayer();
return payer;
}

function createResource(bytes32 salt, uint64 space, uint64 lamports, bytes32 owner) external returns (bytes32){
bytes32 resource = _callSolana.createResource(salt, space, lamports, owner);
function createResource(
bytes32 salt,
uint64 space,
uint64 lamports,
bytes32 owner
) external returns (bytes32) {
bytes32 resource = _callSolana.createResource(
salt,
space,
lamports,
owner
);
return resource;
}

function getResourceAddress(bytes32 salt) external returns (bytes32){
function getResourceAddress(bytes32 salt) external returns (bytes32) {
bytes32 resource = _callSolana.getResourceAddress(salt);
return resource;
}

function getSolanaPDA(bytes32 program_id, bytes memory seeds) external returns (bytes32){
function getSolanaPDA(
bytes32 program_id,
bytes memory seeds
) external returns (bytes32) {
bytes32 pda = _callSolana.getSolanaPDA(program_id, seeds);
return pda;
}

function getExtAuthority(bytes32 salt) external returns (bytes32){
function getExtAuthority(bytes32 salt) external returns (bytes32) {
bytes32 authority = _callSolana.getExtAuthority(salt);
return authority;
}

function executeWithSeed(uint64 lamports, bytes32 salt, bytes calldata instruction) public {
bytes32 returnData = bytes32(_callSolana.executeWithSeed(lamports, salt, instruction));
function executeWithSeed(
uint64 lamports,
bytes32 salt,
bytes calldata instruction
) public {
bytes32 returnData = bytes32(
_callSolana.executeWithSeed(lamports, salt, instruction)
);
emit LogBytes(returnData);
}

function getReturnData() public returns (bytes32, bytes memory){
function getReturnData() public returns (bytes32, bytes memory) {
return _callSolana.getReturnData();
}

function batchExecuteWithSeed(ExecuteWithSeedArgs[] memory _args) public {
for(uint i = 0; i < _args.length; i++) {
_callSolana.executeWithSeed(_args[i].lamports, _args[i].salt, _args[i].instruction);
for (uint i = 0; i < _args.length; i++) {
_callSolana.executeWithSeed(
_args[i].lamports,
_args[i].salt,
_args[i].instruction
);
}
}
}
}
Loading
Loading