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

[master] v1 metamask connect to isolated server + testnet #2820

Merged
merged 75 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
00e5606
v1 metamask connect - try testnet, too
n-hutton Jun 24, 2022
26f2440
fixup
n-hutton Jun 24, 2022
676d6a9
bump travis/jenkins
n-hutton Jun 28, 2022
ef23f54
tidying
n-hutton Jun 28, 2022
31cf230
add debug for testnet
n-hutton Jun 29, 2022
86ec18e
add killer rpc call for debug purpose
n-hutton Jun 29, 2022
cd3b4af
hacks
n-hutton Jun 29, 2022
b8639f8
Merge branch 'master' into feature/evm_rpc
n-hutton Jun 29, 2022
2d2faf0
fix unfortunate error
n-hutton Jun 29, 2022
3052f3b
WIP
n-hutton Jun 30, 2022
afa4c22
testnet
n-hutton Jul 4, 2022
878768d
fixme
n-hutton Jul 4, 2022
f6dc7d3
about to switch TX way
n-hutton Jul 5, 2022
3d23a94
fix versioning
n-hutton Jul 5, 2022
05c9349
fixes
n-hutton Jul 5, 2022
7f19390
fixes
n-hutton Jul 5, 2022
b4bc76c
bump and turn off travis
n-hutton Jul 5, 2022
56b53af
try more stuff
n-hutton Jul 5, 2022
f75267b
fix balance
n-hutton Jul 6, 2022
abbf7bd
fix balance querying
n-hutton Jul 6, 2022
e7af88a
WIP
n-hutton Jul 7, 2022
989125c
thing thing
n-hutton Jul 7, 2022
46af9a6
WORKING FIRST VERSION!
n-hutton Jul 9, 2022
7ca3ecb
seems to be working... try for another testnet deployment
n-hutton Jul 12, 2022
18ca008
another testnet deployment
n-hutton Jul 12, 2022
f78ebec
bump
n-hutton Jul 12, 2022
f09aaa8
add missing cmake file
n-hutton Jul 12, 2022
ecac377
add other file
n-hutton Jul 12, 2022
d2360c9
fix bad build
n-hutton Jul 12, 2022
cbf1da4
do not strip symbols
n-hutton Jul 13, 2022
544964b
Add debugging
n-hutton Jul 13, 2022
0f0e8f0
add more debug
n-hutton Jul 13, 2022
4a1a0d1
fixes
n-hutton Jul 13, 2022
b0b32cb
more fixes
n-hutton Jul 13, 2022
d97645c
add new eth library
n-hutton Jul 13, 2022
2e71a66
add additional debug
n-hutton Jul 13, 2022
a145230
bump it
n-hutton Jul 13, 2022
30caf65
add libEth
n-hutton Jul 13, 2022
6d3110a
ignore more files
n-hutton Jul 13, 2022
cb0ba1a
update schnorr...
n-hutton Jul 13, 2022
37ae6df
does this change the build materially?
n-hutton Jul 13, 2022
0538893
revert schnorr???
n-hutton Jul 13, 2022
c222b3c
fix hopefullyQ
n-hutton Jul 13, 2022
4607714
bump gitignore further
n-hutton Jul 13, 2022
4646afa
cleanup
n-hutton Jul 14, 2022
a89b2ae
fix build errors
n-hutton Jul 14, 2022
e90857b
tidy
n-hutton Jul 18, 2022
042ccd2
fix errors...
n-hutton Jul 18, 2022
21e3c06
attempt at recovery from corrupted git file
n-hutton Jul 18, 2022
6914897
fixes...
n-hutton Jul 18, 2022
0d9c546
transfer demo still works...
n-hutton Jul 18, 2022
780df7c
cleanup
n-hutton Jul 19, 2022
b5164a9
initial commit add python test file
Jul 19, 2022
059349b
Merge branch 'feature/evm_rpc' of github.com:Zilliqa/Zilliqa into fea…
n-hutton Jul 19, 2022
0f17863
v1 test
Jul 19, 2022
f0d9538
cleanup
n-hutton Jul 19, 2022
33ac463
Merge branch 'feature/evm_rpc' of github.com:Zilliqa/Zilliqa into fea…
n-hutton Jul 19, 2022
8b0253b
fixed balance issues
n-hutton Jul 19, 2022
35ce4fe
tests seemingly added
n-hutton Jul 19, 2022
e2d02df
fix build...
n-hutton Jul 19, 2022
6d062d7
sigh
n-hutton Jul 20, 2022
a080c5c
format fix
n-hutton Jul 20, 2022
9b25bac
include linting
n-hutton Jul 20, 2022
cb97c00
fix build error...
n-hutton Jul 20, 2022
525bddd
clang tidy fix
n-hutton Jul 20, 2022
1d9c7f2
sigh
n-hutton Jul 21, 2022
7601a21
fix test
n-hutton Jul 21, 2022
2904777
fix another test
n-hutton Jul 21, 2022
21a5a34
merge to master
n-hutton Jul 22, 2022
1139ff3
fix build
n-hutton Jul 23, 2022
b019d75
Merge branch 'master' into feature/evm_rpc
n-hutton Jul 28, 2022
152d26e
pr feedback except for unit tests
Jul 28, 2022
af1b70d
add unit tests
n-hutton Jul 28, 2022
dd8a036
style...
n-hutton Jul 28, 2022
109df60
more style
n-hutton Jul 28, 2022
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
Prev Previous commit
Next Next commit
tidying
  • Loading branch information
n-hutton committed Jun 28, 2022
commit ef23f5439c266c93446a7ded0348c90d18a2b511
22 changes: 11 additions & 11 deletions src/libServer/IsolatedServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ using namespace std;

// temporary functions to add Eth style functions to the isolated server
void IsolatedServer::AddJSONRpc() {

AbstractServer<IsolatedServer>::bindAndAddMethod(
jsonrpc::Procedure("eth_chainId", jsonrpc::PARAMS_BY_POSITION,
jsonrpc::JSON_STRING, NULL),
Expand All @@ -43,20 +42,20 @@ void IsolatedServer::AddJSONRpc() {

AbstractServer<IsolatedServer>::bindAndAddMethod(
jsonrpc::Procedure("eth_getBalance", jsonrpc::PARAMS_BY_POSITION,
jsonrpc::JSON_STRING, "param01", jsonrpc::JSON_STRING, "param02", jsonrpc::JSON_STRING,
NULL),
jsonrpc::JSON_STRING, "param01", jsonrpc::JSON_STRING,
"param02", jsonrpc::JSON_STRING, NULL),
&IsolatedServer::GetBalanceEth);

AbstractServer<IsolatedServer>::bindAndAddMethod(
jsonrpc::Procedure("eth_getBlockByNumber", jsonrpc::PARAMS_BY_POSITION,
jsonrpc::JSON_STRING, "param01", jsonrpc::JSON_STRING, "param02", jsonrpc::JSON_STRING,
NULL),
jsonrpc::JSON_STRING, "param01", jsonrpc::JSON_STRING,
"param02", jsonrpc::JSON_STRING, NULL),
&IsolatedServer::GetBlockByNumber);

//AbstractServer<IsolatedServer>::bindAndAddMethod(
// AbstractServer<IsolatedServer>::bindAndAddMethod(
// jsonrpc::Procedure("GetTransaction", jsonrpc::PARAMS_BY_POSITION,
// jsonrpc::JSON_OBJECT, "param01", jsonrpc::JSON_STRING,
// NULL),
// jsonrpc::JSON_OBJECT, "param01",
// jsonrpc::JSON_STRING, NULL),
// &LookupServer::GetTransactionI);
}

Expand Down Expand Up @@ -184,7 +183,6 @@ IsolatedServer::IsolatedServer(Mediator& mediator,
bool IsolatedServer::ValidateTxn(const Transaction& tx, const Address& fromAddr,
const Account* sender,
const uint128_t& gasPrice) {

if (DataConversion::UnpackA(tx.GetVersion()) != CHAIN_ID) {
throw JsonRpcException(ServerBase::RPC_VERIFY_REJECTED,
"CHAIN_ID incorrect");
Expand Down Expand Up @@ -297,7 +295,6 @@ bool IsolatedServer::RetrieveHistory(const bool& nonisoload) {
}

Json::Value IsolatedServer::CreateTransaction(const Json::Value& _json) {

try {
if (!JSONConversion::checkJsonTx(_json)) {
throw JsonRpcException(RPC_PARSE_ERROR, "Invalid Transaction JSON");
Expand Down Expand Up @@ -528,7 +525,10 @@ string IsolatedServer::SetMinimumGasPrice(const string& gasPrice) {
return m_gasPrice.str();
}

string IsolatedServer::GetMinimumGasPrice() { cout << "..." << std::endl; return m_gasPrice.str(); }
string IsolatedServer::GetMinimumGasPrice() {
cout << "..." << std::endl;
return m_gasPrice.str();
}

bool IsolatedServer::StartBlocknumIncrement() {
LOG_GENERAL(INFO, "Starting automatic increment " << m_timeDelta);
Expand Down
14 changes: 7 additions & 7 deletions src/libServer/IsolatedServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ class IsolatedServer : public LookupServer,
Json::Value& response) {
(void)request;
response = this->GetBlocknum();
//static uint64_t block_number = 9;
//block_number++;
// static uint64_t block_number = 9;
// block_number++;

//std::stringstream stream;
//stream << "0x" << std::hex << block_number;
//std::string result( stream.str() );
//std::cout << stream.str() << std::endl;
// std::stringstream stream;
// stream << "0x" << std::hex << block_number;
// std::string result( stream.str() );
// std::cout << stream.str() << std::endl;

//response = stream.str();
// response = stream.str();
}

inline virtual void GetTransactionsForTxBlockI(const Json::Value& request,
Expand Down
8 changes: 3 additions & 5 deletions src/libServer/LookupServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ LookupServer::LookupServer(Mediator& mediator,
: Server(mediator),
jsonrpc::AbstractServer<LookupServer>(server,
jsonrpc::JSONRPC_SERVER_V2) {


this->bindAndAddMethod(
jsonrpc::Procedure("eth_chainId", jsonrpc::PARAMS_BY_POSITION,
jsonrpc::JSON_STRING, NULL),
Expand Down Expand Up @@ -807,7 +805,6 @@ Json::Value LookupServer::GetTxBlock(const string& blockNum, bool verbose) {
}

string LookupServer::GetMinimumGasPrice() {

std::cout << "GetMinGasPrice! " << std::endl;
if (!LOOKUP_NODE_MODE) {
throw JsonRpcException(RPC_INVALID_REQUEST, "Sent to a non-lookup");
Expand Down Expand Up @@ -851,7 +848,6 @@ Json::Value LookupServer::GetLatestTxBlock() {
}

Json::Value LookupServer::GetBalance(const string& address) {

std::cout << "Getting balance!" << std::endl;

if (!LOOKUP_NODE_MODE) {
Expand All @@ -872,7 +868,9 @@ Json::Value LookupServer::GetBalance(const string& address) {

ret["balance"] = balance.str();
ret["nonce"] = static_cast<unsigned int>(nonce);
LOG_GENERAL(INFO, "DEBUG: Addr: " << address << " balance: " << balance.str() << " nonce: " << nonce << " " << account);
LOG_GENERAL(INFO,
"DEBUG: Addr: " << address << " balance: " << balance.str()
<< " nonce: " << nonce << " " << account);
} else if (account == nullptr) {
throw JsonRpcException(RPC_INVALID_ADDRESS_OR_KEY,
"Account is not created");
Expand Down
73 changes: 47 additions & 26 deletions src/libServer/LookupServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,23 +257,22 @@ class LookupServer : public Server,
}

// Eth style functions here
inline virtual void GetChainIdI(const Json::Value&,
Json::Value& response) {
inline virtual void GetChainIdI(const Json::Value&, Json::Value& response) {
//(void)request;
std::cout << "REQ" << std::endl;
response = "0x666"; // 1638 decimal - mainnet is reserved for chainId 1
response = "0x666"; // 1638 decimal - mainnet is reserved for chainId 1
}

inline virtual void GetBlocknumEthI(const Json::Value& request,
Json::Value& response) {
(void)request;
//response = this->GetBlocknum();
// response = this->GetBlocknum();
static uint64_t block_number = 9;
block_number++;

std::stringstream stream;
stream << "0x" << std::hex << block_number;
std::string result( stream.str() );
std::string result(stream.str());
std::cout << stream.str() << std::endl;

response = stream.str();
Expand All @@ -284,26 +283,34 @@ class LookupServer : public Server,
// "extraData": "0x476574682f76312e302e302f6c696e75782f676f312e342e32",
// "gasLimit": "0x1388",
// "gasUsed": "0x0",
// "hash": "0x88e96d4537bea4d9c05d12549907b32561d3bf31f45aae734cdc119f13406cb6",
// "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
// "hash":
// "0x88e96d4537bea4d9c05d12549907b32561d3bf31f45aae734cdc119f13406cb6",
// "logsBloom":
// "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
// "miner": "0x05a56e2d52c817161883f50c441c3228cfe54d9f",
// "mixHash": "0x969b900de27b6ac6a67742365dd65f55a0526c41fd18e1b16f1a1215c2e66f59",
// "mixHash":
// "0x969b900de27b6ac6a67742365dd65f55a0526c41fd18e1b16f1a1215c2e66f59",
// "nonce": "0x539bd4979fef1ec4",
// "number": "0x1",
// "parentHash": "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
// "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
// "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
// "parentHash":
// "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
// "receiptsRoot":
// "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
// "sha3Uncles":
// "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
// "size": "0x219",
// "stateRoot": "0xd67e4d450343046425ae4271474353857ab860dbc0a1dde64b41b5cd3a532bf3",
// "stateRoot":
// "0xd67e4d450343046425ae4271474353857ab860dbc0a1dde64b41b5cd3a532bf3",
// "timestamp": "0x55ba4224",
// "totalDifficulty": "0x7ff800000",
// "transactions": [],
// "transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
// "transactionsRoot":
// "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
// "uncles": []
//},

inline virtual void GetBlockByNumber(const Json::Value& request,
Json::Value& response) {
Json::Value& response) {
(void)request;
std::cout << "GBBN " << request[0u].asString() << std::endl;
std::cout << "GBBN2 " << request[1u].asString() << std::endl;
Expand All @@ -314,35 +321,49 @@ class LookupServer : public Server,
ret["extraData"] = "0x476574682f76312e302e302f6c696e75782f676f312e342e32";
ret["gasLimit"] = "0x1388";
ret["gasUsed"] = "0x0";
ret["hash"] = "0x88e96d4537bea4d9c05d12549907b32561d3bf31f45aae734cdc119f13406cb6";
ret["logsBloom"] = "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
ret["hash"] =
"0x88e96d4537bea4d9c05d12549907b32561d3bf31f45aae734cdc119f13406cb6";
ret["logsBloom"] =
"0x00000000000000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000";
ret["miner"] = "0x05a56e2d52c817161883f50c441c3228cfe54d9f";
ret["mixHash"] = "0x969b900de27b6ac6a67742365dd65f55a0526c41fd18e1b16f1a1215c2e66f59";
ret["mixHash"] =
"0x969b900de27b6ac6a67742365dd65f55a0526c41fd18e1b16f1a1215c2e66f59";
ret["nonce"] = "0x539bd4979fef1ec4";
ret["number"] = "0x1";
ret["parentHash"] = "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3";
ret["receiptsRoot"] = "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421";
ret["sha3Uncles"] = "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347";
ret["parentHash"] =
"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3";
ret["receiptsRoot"] =
"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421";
ret["sha3Uncles"] =
"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347";
ret["size"] = "0x219";
ret["stateRoot"] = "0xd67e4d450343046425ae4271474353857ab860dbc0a1dde64b41b5cd3a532bf3";
ret["stateRoot"] =
"0xd67e4d450343046425ae4271474353857ab860dbc0a1dde64b41b5cd3a532bf3";
ret["timestamp"] = "0x55ba4224";
ret["totalDifficulty"] = "0x7ff800000";
ret["transactions"] = Json::arrayValue;
ret["transactionsRoot"] = "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421";
ret["transactionsRoot"] =
"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421";
ret["uncles"] = Json::arrayValue;

response = ret;
}

inline virtual void GetNetVersionI(const Json::Value& request,
Json::Value& response) {
Json::Value& response) {
(void)request;
response = "0x666"; // 1638 decimal - mainnet is reserved for chainId 1
response = "0x666"; // 1638 decimal - mainnet is reserved for chainId 1
}

inline virtual void GetBalanceEth(const Json::Value& request,
Json::Value& response) {

Json::Value& response) {
std::cout << "GETB " << request[0u].asString() << std::endl;
(void)request;
response = "0x1010000000000000000000000";
Expand Down