Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
cr fix - file reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
stana-miric committed May 16, 2023
1 parent 4c1475f commit 726fbea
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 72 deletions.
17 changes: 0 additions & 17 deletions benchmark/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion benchmark/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import (

func Benchmark_RunTests(b *testing.B) {
// benchmark tests
RootChildSendTx(b)
rootChildSendTx(b)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//nolint:lll
package common
package benchmark

// pragma solidity ^0.5.16;

Expand All @@ -22,7 +22,7 @@ package common
// return result;
// }
// }
const SingleContByteCode = `608060405234801561001057600080fd5b50610210806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806320965255146100465780635b9af12b146100a55780637a85644b146100d3575b600080fd5b61004e61011f565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015610091578082015181840152602081019050610076565b505050509050019250505060405180910390f35b6100d1600480360360208110156100bb57600080fd5b8101908080359060200190929190505050610177565b005b610109600480360360408110156100e957600080fd5b8101908080359060200190929190803590602001909291905050506101a6565b6040518082815260200191505060405180910390f35b6060600080548060200260200160405190810160405280929190818152602001828054801561016d57602002820191906000526020600020905b815481526020019060010190808311610159575b5050505050905090565b600081908060018154018082558091505090600182039060005260206000200160009091929091909150555050565b600080828401905060008090505b600a8110156101d05760028202915080806001019150506101b4565b50809150509291505056fea265627a7a72315820ec23cf989c20e0d41d7819001da6dfe6cc129988f15cd8a7b79595a2e61a93d264736f6c63430005100032`
const singleContByteCode = `608060405234801561001057600080fd5b50610210806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806320965255146100465780635b9af12b146100a55780637a85644b146100d3575b600080fd5b61004e61011f565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015610091578082015181840152602081019050610076565b505050509050019250505060405180910390f35b6100d1600480360360208110156100bb57600080fd5b8101908080359060200190929190505050610177565b005b610109600480360360408110156100e957600080fd5b8101908080359060200190929190803590602001909291905050506101a6565b6040518082815260200191505060405180910390f35b6060600080548060200260200160405190810160405280929190818152602001828054801561016d57602002820191906000526020600020905b815481526020019060010190808311610159575b5050505050905090565b600081908060018154018082558091505090600182039060005260206000200160009091929091909150555050565b600080828401905060008090505b600a8110156101d05760028202915080806001019150506101b4565b50809150509291505056fea265627a7a72315820ec23cf989c20e0d41d7819001da6dfe6cc129988f15cd8a7b79595a2e61a93d264736f6c63430005100032`

//MULTI CONTRACTS CALL: A->B->C

Expand All @@ -42,7 +42,7 @@ const SingleContByteCode = `608060405234801561001057600080fd5b506102108061002060
// return valB;
// }
// }
const MultiContAByteCode = `608060405234801561001057600080fd5b506101c5806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063286d2e3a1461003b57806368685ad31461007f575b600080fd5b61007d6004803603602081101561005157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061009d565b005b6100876100e0565b6040518082815260200191505060405180910390f35b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000806000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636cde00cd6040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561014c57600080fd5b505af1158015610160573d6000803e3d6000fd5b505050506040513d602081101561017657600080fd5b81019080805190602001909291905050509050809150509056fea265627a7a7231582082d7a079b4ea6bcf371ef0665da89a56bd53bdc82ae90daa9dd21b61fc6c115864736f6c63430005100032`
const multiContAByteCode = `608060405234801561001057600080fd5b506101c5806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063286d2e3a1461003b57806368685ad31461007f575b600080fd5b61007d6004803603602081101561005157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061009d565b005b6100876100e0565b6040518082815260200191505060405180910390f35b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000806000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636cde00cd6040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561014c57600080fd5b505af1158015610160573d6000803e3d6000fd5b505050506040513d602081101561017657600080fd5b81019080805190602001909291905050509050809150509056fea265627a7a7231582082d7a079b4ea6bcf371ef0665da89a56bd53bdc82ae90daa9dd21b61fc6c115864736f6c63430005100032`

// pragma solidity ^0.5.16;
// interface IContractC {
Expand All @@ -63,7 +63,7 @@ const MultiContAByteCode = `608060405234801561001057600080fd5b506101c58061002060
// }

// }
const MultiContBByteCode = `608060405234801561001057600080fd5b50610205806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063286d2e3a146100465780636cde00cd1461008a578063735b7e6f146100a8575b600080fd5b6100886004803603602081101561005c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506100c6565b005b61009261010a565b6040518082815260200191505060405180910390f35b6100b06101ca565b6040518082815260200191505060405180910390f35b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166349ec07186040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561017757600080fd5b505af115801561018b573d6000803e3d6000fd5b505050506040513d60208110156101a157600080fd5b810190808051906020019092919050505090508060008082825401925050819055508091505090565b6000548156fea265627a7a7231582082a5dbbf184a5c59907837a73f0ea2083719218b0bd60ef31a3ef2b209aad00764736f6c63430005100032`
const multiContBByteCode = `608060405234801561001057600080fd5b50610205806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063286d2e3a146100465780636cde00cd1461008a578063735b7e6f146100a8575b600080fd5b6100886004803603602081101561005c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506100c6565b005b61009261010a565b6040518082815260200191505060405180910390f35b6100b06101ca565b6040518082815260200191505060405180910390f35b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166349ec07186040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561017757600080fd5b505af115801561018b573d6000803e3d6000fd5b505050506040513d60208110156101a157600080fd5b810190808051906020019092919050505090508060008082825401925050819055508091505090565b6000548156fea265627a7a7231582082a5dbbf184a5c59907837a73f0ea2083719218b0bd60ef31a3ef2b209aad00764736f6c63430005100032`

// pragma solidity ^0.5.16;
// contract ContractC {
Expand All @@ -78,4 +78,4 @@ const MultiContBByteCode = `608060405234801561001057600080fd5b506102058061002060
// return uint256(keccak256(abi.encode(block.timestamp, block.difficulty))) % 100;
// }
// }
const MultiContCByteCode = `608060405234801561001057600080fd5b50610143806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80631990ceb9146100465780633b3cf4e31461006457806349ec071814610082575b600080fd5b61004e6100a0565b6040518082815260200191505060405180910390f35b61006c6100e3565b6040518082815260200191505060405180910390f35b61008a6100e9565b6040518082815260200191505060405180910390f35b60006064424460405160200180838152602001828152602001925050506040516020818303038152906040528051906020012060001c816100dd57fe5b06905090565b60005481565b6000806100f46100a0565b90506000808154809291906001019190505550809150509056fea265627a7a72315820834484e13fa60ebe10a9d7102df12bafa8db4d9cdad5a38d2af6d360adc7ff4064736f6c63430005100032`
const multiContCByteCode = `608060405234801561001057600080fd5b50610143806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80631990ceb9146100465780633b3cf4e31461006457806349ec071814610082575b600080fd5b61004e6100a0565b6040518082815260200191505060405180910390f35b61006c6100e3565b6040518082815260200191505060405180910390f35b61008a6100e9565b6040518082815260200191505060405180910390f35b60006064424460405160200180838152602001828152602001925050506040516020818303038152906040528051906020012060001c816100dd57fe5b06905090565b60005481565b6000806100f46100a0565b90506000808154809291906001019190505550809150509056fea265627a7a72315820834484e13fa60ebe10a9d7102df12bafa8db4d9cdad5a38d2af6d360adc7ff4064736f6c63430005100032`
2 changes: 1 addition & 1 deletion benchmark/common/executors.go → benchmark/executors.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package common
package benchmark

import (
"sync"
Expand Down
35 changes: 18 additions & 17 deletions benchmark/common/helper.go → benchmark/helper.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package common
package benchmark

import (
"encoding/hex"
Expand All @@ -12,8 +12,8 @@ import (
"github.com/umbracle/ethgo/wallet"
)

// DeployContractOnRootAndChild deploys contract code on both root and child chain
func DeployContractOnRootAndChild(
// deployContractOnRootAndChild deploys contract code on both root and child chain
func deployContractOnRootAndChild(
b *testing.B,
childTxRelayer txrelayer.TxRelayer,
rootTxRelayer txrelayer.TxRelayer,
Expand All @@ -26,16 +26,16 @@ func DeployContractOnRootAndChild(
require.NoError(b, err)

// deploy contract on the child chain
contractChildAddr := DeployContract(b, childTxRelayer, sender, byteCode)
contractChildAddr := deployContract(b, childTxRelayer, sender, byteCode)

// deploy contract on the root chain
contractRootAddr := DeployContract(b, rootTxRelayer, sender, byteCode)
contractRootAddr := deployContract(b, rootTxRelayer, sender, byteCode)

return contractChildAddr, contractRootAddr
}

// DeployContract deploys contract code for the given relayer
func DeployContract(b *testing.B, txRelayer txrelayer.TxRelayer, sender ethgo.Key, byteCode []byte) ethgo.Address {
// deployContract deploys contract code for the given relayer
func deployContract(b *testing.B, txRelayer txrelayer.TxRelayer, sender ethgo.Key, byteCode []byte) ethgo.Address {
b.Helper()

txn := &ethgo.Transaction{
Expand All @@ -51,13 +51,14 @@ func DeployContract(b *testing.B, txRelayer txrelayer.TxRelayer, sender ethgo.Ke
return receipt.ContractAddress
}

// GetTxInput returns input for sending tx, given the abi encoded method and call parameters
func GetTxInput(b *testing.B, method *abi.Method, args interface{}) []byte {
// getTxInput returns input for sending tx, given the abi encoded method and call parameters
func getTxInput(b *testing.B, method *abi.Method, args interface{}) []byte {
b.Helper()

var input []byte

var err error
var (
input []byte
err error
)

if args != nil {
input, err = method.Encode(args)
Expand All @@ -70,12 +71,12 @@ func GetTxInput(b *testing.B, method *abi.Method, args interface{}) []byte {
return input
}

// SetContractDependencyAddress calls setContract function on caller contract, to set address of the callee contract
func SetContractDependencyAddress(b *testing.B, txRelayer txrelayer.TxRelayer, callerContractAddr ethgo.Address,
// setContractDependencyAddress calls setContract function on caller contract, to set address of the callee contract
func setContractDependencyAddress(b *testing.B, txRelayer txrelayer.TxRelayer, callerContractAddr ethgo.Address,
calleeContractAddr ethgo.Address, setContractAbiMethod *abi.Method, sender ethgo.Key) {
b.Helper()

input := GetTxInput(b, setContractAbiMethod, []interface{}{calleeContractAddr})
input := getTxInput(b, setContractAbiMethod, []interface{}{calleeContractAddr})
receipt, err := txRelayer.SendTransaction(
&ethgo.Transaction{
To: &callerContractAddr,
Expand All @@ -85,8 +86,8 @@ func SetContractDependencyAddress(b *testing.B, txRelayer txrelayer.TxRelayer, c
require.Equal(b, uint64(types.ReceiptSuccess), receipt.Status)
}

// GetPrivateKey initializes a private key from provided raw private key
func GetPrivateKey(b *testing.B, privateKeyRaw string) ethgo.Key {
// getPrivateKey initializes a private key from provided raw private key
func getPrivateKey(b *testing.B, privateKeyRaw string) ethgo.Key {
b.Helper()

dec, err := hex.DecodeString(privateKeyRaw)
Expand Down
Loading

0 comments on commit 726fbea

Please sign in to comment.