From 99efd02febfbca7286cd7e470e43ef3777880722 Mon Sep 17 00:00:00 2001 From: stana-ethernal Date: Wed, 17 May 2023 11:01:27 +0200 Subject: [PATCH] cr fix - move contract codes to contractsapi --- benchmark/contract_codes.go | 81 ------------------- benchmark/helper.go | 6 +- benchmark/root_child_send_tx.go | 9 ++- consensus/polybft/contractsapi/init.go | 24 ++++++ .../test-contracts/ITestBenchmarkB.json | 24 ++++++ .../test-contracts/ITestBenchmarkC.json | 24 ++++++ .../test-contracts/TestBenchmarkA.json | 37 +++++++++ .../test-contracts/TestBenchmarkA.sol | 18 +++++ .../test-contracts/TestBenchmarkB.json | 50 ++++++++++++ .../test-contracts/TestBenchmarkB.sol | 20 +++++ .../test-contracts/TestBenchmarkC.json | 50 ++++++++++++ .../test-contracts/TestBenchmarkC.sol | 15 ++++ .../test-contracts/TestBenchmarkSingle.json | 61 ++++++++++++++ .../test-contracts/TestBenchmarkSingle.sol | 22 +++++ 14 files changed, 351 insertions(+), 90 deletions(-) delete mode 100644 benchmark/contract_codes.go create mode 100644 consensus/polybft/contractsapi/test-contracts/ITestBenchmarkB.json create mode 100644 consensus/polybft/contractsapi/test-contracts/ITestBenchmarkC.json create mode 100644 consensus/polybft/contractsapi/test-contracts/TestBenchmarkA.json create mode 100644 consensus/polybft/contractsapi/test-contracts/TestBenchmarkA.sol create mode 100644 consensus/polybft/contractsapi/test-contracts/TestBenchmarkB.json create mode 100644 consensus/polybft/contractsapi/test-contracts/TestBenchmarkB.sol create mode 100644 consensus/polybft/contractsapi/test-contracts/TestBenchmarkC.json create mode 100644 consensus/polybft/contractsapi/test-contracts/TestBenchmarkC.sol create mode 100644 consensus/polybft/contractsapi/test-contracts/TestBenchmarkSingle.json create mode 100644 consensus/polybft/contractsapi/test-contracts/TestBenchmarkSingle.sol diff --git a/benchmark/contract_codes.go b/benchmark/contract_codes.go deleted file mode 100644 index 8a567032a6..0000000000 --- a/benchmark/contract_codes.go +++ /dev/null @@ -1,81 +0,0 @@ -//nolint:lll -package benchmark - -// pragma solidity ^0.5.16; - -// contract SingleCallContract { -// uint256[] private val; - -// function addValue(uint256 value) public { -// val.push(value); -// } - -// function getValue() public view returns (uint256[] memory) { -// return val; -// } - -// function compute(uint256 x, uint256 y) public pure returns (uint256) { -// uint256 result = x + y; -// for (uint256 i = 0; i < 10; i++) { -// result = result * 2; -// } -// return result; -// } -// } -const singleContByteCode = `608060405234801561001057600080fd5b50610210806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806320965255146100465780635b9af12b146100a55780637a85644b146100d3575b600080fd5b61004e61011f565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015610091578082015181840152602081019050610076565b505050509050019250505060405180910390f35b6100d1600480360360208110156100bb57600080fd5b8101908080359060200190929190505050610177565b005b610109600480360360408110156100e957600080fd5b8101908080359060200190929190803590602001909291905050506101a6565b6040518082815260200191505060405180910390f35b6060600080548060200260200160405190810160405280929190818152602001828054801561016d57602002820191906000526020600020905b815481526020019060010190808311610159575b5050505050905090565b600081908060018154018082558091505090600182039060005260206000200160009091929091909150555050565b600080828401905060008090505b600a8110156101d05760028202915080806001019150506101b4565b50809150509291505056fea265627a7a72315820ec23cf989c20e0d41d7819001da6dfe6cc129988f15cd8a7b79595a2e61a93d264736f6c63430005100032` - -//MULTI CONTRACTS CALL: A->B->C - -// pragma solidity ^0.5.16; -// interface IContractB { -// function fnB() external returns (uint256); -// } -// contract ContractA { -// address contractAddr; -// -// function setContractAddr(address _contract) public { -// contractAddr = _contract; -// } - -// function fnA() public returns (uint256) { -// uint256 valB = IContractB(contractAddr).fnB(); -// return valB; -// } -// } -const multiContAByteCode = `608060405234801561001057600080fd5b506101c5806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063286d2e3a1461003b57806368685ad31461007f575b600080fd5b61007d6004803603602081101561005157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061009d565b005b6100876100e0565b6040518082815260200191505060405180910390f35b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000806000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636cde00cd6040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561014c57600080fd5b505af1158015610160573d6000803e3d6000fd5b505050506040513d602081101561017657600080fd5b81019080805190602001909291905050509050809150509056fea265627a7a7231582082d7a079b4ea6bcf371ef0665da89a56bd53bdc82ae90daa9dd21b61fc6c115864736f6c63430005100032` - -// pragma solidity ^0.5.16; -// interface IContractC { -// function fnC1() external returns (uint256); -// } -// contract ContractB { -// uint256 public valB; -// address contractAddr; - -// function setContractAddr(address _contract) public { -// contractAddr = _contract; -// } - -// function fnB() external returns (uint256) { -// uint256 valC = IContractC(contractAddr).fnC1(); -// valB += valC; -// return valC; -// } - -// } -const multiContBByteCode = `608060405234801561001057600080fd5b50610205806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063286d2e3a146100465780636cde00cd1461008a578063735b7e6f146100a8575b600080fd5b6100886004803603602081101561005c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506100c6565b005b61009261010a565b6040518082815260200191505060405180910390f35b6100b06101ca565b6040518082815260200191505060405180910390f35b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166349ec07186040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561017757600080fd5b505af115801561018b573d6000803e3d6000fd5b505050506040513d60208110156101a157600080fd5b810190808051906020019092919050505090508060008082825401925050819055508091505090565b6000548156fea265627a7a7231582082a5dbbf184a5c59907837a73f0ea2083719218b0bd60ef31a3ef2b209aad00764736f6c63430005100032` - -// pragma solidity ^0.5.16; -// contract ContractC { -// uint256 public valC; -// function fnC1() external returns (uint256) { -// uint256 valC2 = fnC2(); -// valC++; -// return valC2; -// } - -// function fnC2() public view returns (uint256) { -// return uint256(keccak256(abi.encode(block.timestamp, block.difficulty))) % 100; -// } -// } -const multiContCByteCode = `608060405234801561001057600080fd5b50610143806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80631990ceb9146100465780633b3cf4e31461006457806349ec071814610082575b600080fd5b61004e6100a0565b6040518082815260200191505060405180910390f35b61006c6100e3565b6040518082815260200191505060405180910390f35b61008a6100e9565b6040518082815260200191505060405180910390f35b60006064424460405160200180838152602001828152602001925050506040516020818303038152906040528051906020012060001c816100dd57fe5b06905090565b60005481565b6000806100f46100a0565b90506000808154809291906001019190505550809150509056fea265627a7a72315820834484e13fa60ebe10a9d7102df12bafa8db4d9cdad5a38d2af6d360adc7ff4064736f6c63430005100032` diff --git a/benchmark/helper.go b/benchmark/helper.go index 8fb8948895..00ed724a64 100644 --- a/benchmark/helper.go +++ b/benchmark/helper.go @@ -18,13 +18,9 @@ func deployContractOnRootAndChild( childTxRelayer txrelayer.TxRelayer, rootTxRelayer txrelayer.TxRelayer, sender ethgo.Key, - byteCodeString string) (ethgo.Address, ethgo.Address) { + byteCode []byte) (ethgo.Address, ethgo.Address) { b.Helper() - // bytecode from string - byteCode, err := hex.DecodeString(byteCodeString) - require.NoError(b, err) - // deploy contract on the child chain contractChildAddr := deployContract(b, childTxRelayer, sender, byteCode) diff --git a/benchmark/root_child_send_tx.go b/benchmark/root_child_send_tx.go index d9de979972..adbc4fcfc8 100644 --- a/benchmark/root_child_send_tx.go +++ b/benchmark/root_child_send_tx.go @@ -5,6 +5,7 @@ import ( "math/big" "testing" + "github.com/0xPolygon/polygon-edge/consensus/polybft/contractsapi" "github.com/0xPolygon/polygon-edge/e2e-polybft/framework" "github.com/0xPolygon/polygon-edge/txrelayer" "github.com/0xPolygon/polygon-edge/types" @@ -107,13 +108,13 @@ func RootChildSendTxSetUp(b *testing.B) ([]TxTestCase, func()) { // deploy contracts singleContChildAddr, singleContRootAddr := deployContractOnRootAndChild(b, childTxRelayer, rootTxRelayer, - sender, singleContByteCode) + sender, contractsapi.TestBenchmarkSingle.Bytecode) multiAContChildAddr, multiAContRootAddr := deployContractOnRootAndChild(b, childTxRelayer, rootTxRelayer, - sender, multiContAByteCode) + sender, contractsapi.TestBenchmarkA.Bytecode) multiBContChildAddr, multiBContRootAddr := deployContractOnRootAndChild(b, childTxRelayer, rootTxRelayer, - sender, multiContBByteCode) + sender, contractsapi.TestBenchmarkB.Bytecode) multiCContChildAddr, multiCContRootAddr := deployContractOnRootAndChild(b, childTxRelayer, rootTxRelayer, - sender, multiContCByteCode) + sender, contractsapi.TestBenchmarkC.Bytecode) // set callee contract addresses for multi call contracts (A->B->C) // set B contract address in A contract diff --git a/consensus/polybft/contractsapi/init.go b/consensus/polybft/contractsapi/init.go index 7ec7a977bb..fb2e967076 100644 --- a/consensus/polybft/contractsapi/init.go +++ b/consensus/polybft/contractsapi/init.go @@ -52,6 +52,10 @@ var ( RootERC20 *artifact.Artifact TestSimple *artifact.Artifact TestRewardToken *artifact.Artifact + TestBenchmarkA *artifact.Artifact + TestBenchmarkB *artifact.Artifact + TestBenchmarkC *artifact.Artifact + TestBenchmarkSingle *artifact.Artifact ) func init() { @@ -202,6 +206,26 @@ func init() { log.Fatal(err) } + TestBenchmarkA, err = artifact.DecodeArtifact(readTestContractContent("TestBenchmarkA.json")) + if err != nil { + log.Fatal(err) + } + + TestBenchmarkB, err = artifact.DecodeArtifact(readTestContractContent("TestBenchmarkB.json")) + if err != nil { + log.Fatal(err) + } + + TestBenchmarkC, err = artifact.DecodeArtifact(readTestContractContent("TestBenchmarkC.json")) + if err != nil { + log.Fatal(err) + } + + TestBenchmarkSingle, err = artifact.DecodeArtifact(readTestContractContent("TestBenchmarkSingle.json")) + if err != nil { + log.Fatal(err) + } + CustomSupernetManager, err = artifact.DecodeArtifact([]byte(CustomSupernetManagerArtifact)) if err != nil { log.Fatal(err) diff --git a/consensus/polybft/contractsapi/test-contracts/ITestBenchmarkB.json b/consensus/polybft/contractsapi/test-contracts/ITestBenchmarkB.json new file mode 100644 index 0000000000..1c8f393171 --- /dev/null +++ b/consensus/polybft/contractsapi/test-contracts/ITestBenchmarkB.json @@ -0,0 +1,24 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "ITestBenchmarkB", + "sourceName": "contracts/test/TestBenchmarkA.sol", + "abi": [ + { + "inputs": [], + "name": "fnB", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x", + "deployedBytecode": "0x", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/consensus/polybft/contractsapi/test-contracts/ITestBenchmarkC.json b/consensus/polybft/contractsapi/test-contracts/ITestBenchmarkC.json new file mode 100644 index 0000000000..9ec29ff956 --- /dev/null +++ b/consensus/polybft/contractsapi/test-contracts/ITestBenchmarkC.json @@ -0,0 +1,24 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "ITestBenchmarkC", + "sourceName": "contracts/test/TestBenchmarkB.sol", + "abi": [ + { + "inputs": [], + "name": "fnC1", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x", + "deployedBytecode": "0x", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/consensus/polybft/contractsapi/test-contracts/TestBenchmarkA.json b/consensus/polybft/contractsapi/test-contracts/TestBenchmarkA.json new file mode 100644 index 0000000000..3207437512 --- /dev/null +++ b/consensus/polybft/contractsapi/test-contracts/TestBenchmarkA.json @@ -0,0 +1,37 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "TestBenchmarkA", + "sourceName": "contracts/test/TestBenchmarkA.sol", + "abi": [ + { + "inputs": [], + "name": "fnA", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_contract", + "type": "address" + } + ], + "name": "setContractAddr", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b5061017b806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063286d2e3a1461003b57806368685ad31461006d575b600080fd5b61006b6100493660046100fc565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b005b610075610087565b60405190815260200160405180910390f35b6000805460408051636cde00cd60e01b8152905183926001600160a01b031691636cde00cd916004808301926020929190829003018187875af11580156100d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100f6919061012c565b92915050565b60006020828403121561010e57600080fd5b81356001600160a01b038116811461012557600080fd5b9392505050565b60006020828403121561013e57600080fd5b505191905056fea2646970667358221220a8ce85649b9a1ab453ecb852ac36c64f7be380547a5cf2faf83ffdbb59b6424464736f6c63430008130033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100365760003560e01c8063286d2e3a1461003b57806368685ad31461006d575b600080fd5b61006b6100493660046100fc565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b005b610075610087565b60405190815260200160405180910390f35b6000805460408051636cde00cd60e01b8152905183926001600160a01b031691636cde00cd916004808301926020929190829003018187875af11580156100d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100f6919061012c565b92915050565b60006020828403121561010e57600080fd5b81356001600160a01b038116811461012557600080fd5b9392505050565b60006020828403121561013e57600080fd5b505191905056fea2646970667358221220a8ce85649b9a1ab453ecb852ac36c64f7be380547a5cf2faf83ffdbb59b6424464736f6c63430008130033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/consensus/polybft/contractsapi/test-contracts/TestBenchmarkA.sol b/consensus/polybft/contractsapi/test-contracts/TestBenchmarkA.sol new file mode 100644 index 0000000000..aade227025 --- /dev/null +++ b/consensus/polybft/contractsapi/test-contracts/TestBenchmarkA.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.19; + +interface ITestBenchmarkB { + function fnB() external returns (uint256); +} +contract TestBenchmarkA { + address contractAddr; + + function setContractAddr(address _contract) public { + contractAddr = _contract; + } + + function fnA() public returns (uint256) { + uint256 valB = ITestBenchmarkB(contractAddr).fnB(); + return valB; + } + } \ No newline at end of file diff --git a/consensus/polybft/contractsapi/test-contracts/TestBenchmarkB.json b/consensus/polybft/contractsapi/test-contracts/TestBenchmarkB.json new file mode 100644 index 0000000000..a5c9e28157 --- /dev/null +++ b/consensus/polybft/contractsapi/test-contracts/TestBenchmarkB.json @@ -0,0 +1,50 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "TestBenchmarkB", + "sourceName": "contracts/test/TestBenchmarkB.sol", + "abi": [ + { + "inputs": [], + "name": "fnB", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_contract", + "type": "address" + } + ], + "name": "setContractAddr", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "valB", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b506101db806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063286d2e3a146100465780636cde00cd14610078578063735b7e6f14610092575b600080fd5b610076610054366004610135565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b005b61008061009b565b60405190815260200160405180910390f35b61008060005481565b600080600160009054906101000a90046001600160a01b03166001600160a01b03166349ec07186040518163ffffffff1660e01b81526004016020604051808303816000875af11580156100f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101179190610165565b90508060008082825461012a919061017e565b909155509092915050565b60006020828403121561014757600080fd5b81356001600160a01b038116811461015e57600080fd5b9392505050565b60006020828403121561017757600080fd5b5051919050565b8082018082111561019f57634e487b7160e01b600052601160045260246000fd5b9291505056fea26469706673582212209f01d2971a8238a2a1c208a8dde49ecc84579475e54782314375cb36d1bf60ea64736f6c63430008130033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c8063286d2e3a146100465780636cde00cd14610078578063735b7e6f14610092575b600080fd5b610076610054366004610135565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b005b61008061009b565b60405190815260200160405180910390f35b61008060005481565b600080600160009054906101000a90046001600160a01b03166001600160a01b03166349ec07186040518163ffffffff1660e01b81526004016020604051808303816000875af11580156100f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101179190610165565b90508060008082825461012a919061017e565b909155509092915050565b60006020828403121561014757600080fd5b81356001600160a01b038116811461015e57600080fd5b9392505050565b60006020828403121561017757600080fd5b5051919050565b8082018082111561019f57634e487b7160e01b600052601160045260246000fd5b9291505056fea26469706673582212209f01d2971a8238a2a1c208a8dde49ecc84579475e54782314375cb36d1bf60ea64736f6c63430008130033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/consensus/polybft/contractsapi/test-contracts/TestBenchmarkB.sol b/consensus/polybft/contractsapi/test-contracts/TestBenchmarkB.sol new file mode 100644 index 0000000000..d4b033f43c --- /dev/null +++ b/consensus/polybft/contractsapi/test-contracts/TestBenchmarkB.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.19; + +interface ITestBenchmarkC { + function fnC1() external returns (uint256); +} +contract TestBenchmarkB { + uint256 public valB; + address contractAddr; + + function setContractAddr(address _contract) public { + contractAddr = _contract; + } + + function fnB() external returns (uint256) { + uint256 valC = ITestBenchmarkC(contractAddr).fnC1(); + valB += valC; + return valC; + } +} \ No newline at end of file diff --git a/consensus/polybft/contractsapi/test-contracts/TestBenchmarkC.json b/consensus/polybft/contractsapi/test-contracts/TestBenchmarkC.json new file mode 100644 index 0000000000..8830848643 --- /dev/null +++ b/consensus/polybft/contractsapi/test-contracts/TestBenchmarkC.json @@ -0,0 +1,50 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "TestBenchmarkC", + "sourceName": "contracts/test/TestBenchmarkC.sol", + "abi": [ + { + "inputs": [], + "name": "fnC1", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "fnC2", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "valC", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b5061015f806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80631990ceb9146100465780633b3cf4e31461006057806349ec071814610069575b600080fd5b61004e610071565b60405190815260200160405180910390f35b61004e60005481565b61004e6100b9565b600060644244604051602001610091929190918252602082015260400190565b6040516020818303038152906040528051906020012060001c6100b491906100e0565b905090565b6000806100c4610071565b60008054919250806100d583610102565b909155509092915050565b6000826100fd57634e487b7160e01b600052601260045260246000fd5b500690565b60006001820161012257634e487b7160e01b600052601160045260246000fd5b506001019056fea264697066735822122092ffbbf005793faaa839fdfd4e894697301342a305e3e8734927815308198d7964736f6c63430008130033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c80631990ceb9146100465780633b3cf4e31461006057806349ec071814610069575b600080fd5b61004e610071565b60405190815260200160405180910390f35b61004e60005481565b61004e6100b9565b600060644244604051602001610091929190918252602082015260400190565b6040516020818303038152906040528051906020012060001c6100b491906100e0565b905090565b6000806100c4610071565b60008054919250806100d583610102565b909155509092915050565b6000826100fd57634e487b7160e01b600052601260045260246000fd5b500690565b60006001820161012257634e487b7160e01b600052601160045260246000fd5b506001019056fea264697066735822122092ffbbf005793faaa839fdfd4e894697301342a305e3e8734927815308198d7964736f6c63430008130033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/consensus/polybft/contractsapi/test-contracts/TestBenchmarkC.sol b/consensus/polybft/contractsapi/test-contracts/TestBenchmarkC.sol new file mode 100644 index 0000000000..0203ed2de9 --- /dev/null +++ b/consensus/polybft/contractsapi/test-contracts/TestBenchmarkC.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.19; + +contract TestBenchmarkC { + uint256 public valC; + function fnC1() external returns (uint256) { + uint256 valC2 = fnC2(); + valC++; + return valC2; + } + + function fnC2() public view returns (uint256) { + return uint256(keccak256(abi.encode(block.timestamp, block.difficulty))) % 100; + } +} \ No newline at end of file diff --git a/consensus/polybft/contractsapi/test-contracts/TestBenchmarkSingle.json b/consensus/polybft/contractsapi/test-contracts/TestBenchmarkSingle.json new file mode 100644 index 0000000000..ba764ff24f --- /dev/null +++ b/consensus/polybft/contractsapi/test-contracts/TestBenchmarkSingle.json @@ -0,0 +1,61 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "TestBenchmarkSingle", + "sourceName": "contracts/test/TestBenchmarkSingle.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "addValue", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "x", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "y", + "type": "uint256" + } + ], + "name": "compute", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getValue", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b50610271806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806320965255146100465780635b9af12b146100645780637a85644b146100a6575b600080fd5b61004e6100c7565b60405161005b9190610163565b60405180910390f35b6100a46100723660046101a7565b600080546001810182559080527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5630155565b005b6100b96100b43660046101c0565b61011f565b60405190815260200161005b565b6060600080548060200260200160405190810160405280929190818152602001828054801561011557602002820191906000526020600020905b815481526020019060010190808311610101575b5050505050905090565b60008061012c83856101f8565b905060005b600a8110156101595761014582600261020b565b91508061015181610222565b915050610131565b5090505b92915050565b6020808252825182820181905260009190848201906040850190845b8181101561019b5783518352928401929184019160010161017f565b50909695505050505050565b6000602082840312156101b957600080fd5b5035919050565b600080604083850312156101d357600080fd5b50508035926020909101359150565b634e487b7160e01b600052601160045260246000fd5b8082018082111561015d5761015d6101e2565b808202811582820484141761015d5761015d6101e2565b600060018201610234576102346101e2565b506001019056fea2646970667358221220c572f74159ad307792361021be5daa28297e481a4cac587b5b311e5679e9d9da64736f6c63430008130033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c806320965255146100465780635b9af12b146100645780637a85644b146100a6575b600080fd5b61004e6100c7565b60405161005b9190610163565b60405180910390f35b6100a46100723660046101a7565b600080546001810182559080527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5630155565b005b6100b96100b43660046101c0565b61011f565b60405190815260200161005b565b6060600080548060200260200160405190810160405280929190818152602001828054801561011557602002820191906000526020600020905b815481526020019060010190808311610101575b5050505050905090565b60008061012c83856101f8565b905060005b600a8110156101595761014582600261020b565b91508061015181610222565b915050610131565b5090505b92915050565b6020808252825182820181905260009190848201906040850190845b8181101561019b5783518352928401929184019160010161017f565b50909695505050505050565b6000602082840312156101b957600080fd5b5035919050565b600080604083850312156101d357600080fd5b50508035926020909101359150565b634e487b7160e01b600052601160045260246000fd5b8082018082111561015d5761015d6101e2565b808202811582820484141761015d5761015d6101e2565b600060018201610234576102346101e2565b506001019056fea2646970667358221220c572f74159ad307792361021be5daa28297e481a4cac587b5b311e5679e9d9da64736f6c63430008130033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/consensus/polybft/contractsapi/test-contracts/TestBenchmarkSingle.sol b/consensus/polybft/contractsapi/test-contracts/TestBenchmarkSingle.sol new file mode 100644 index 0000000000..432f7990e6 --- /dev/null +++ b/consensus/polybft/contractsapi/test-contracts/TestBenchmarkSingle.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.19; + +contract TestBenchmarkSingle { + uint256[] private val; + + function addValue(uint256 value) public { + val.push(value); + } + + function getValue() public view returns (uint256[] memory) { + return val; + } + + function compute(uint256 x, uint256 y) public pure returns (uint256) { + uint256 result = x + y; + for (uint256 i = 0; i < 10; i++) { + result = result * 2; + } + return result; + } + } \ No newline at end of file