Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into kayan_last_block_number
Browse files Browse the repository at this point in the history
  • Loading branch information
taokayan committed Dec 7, 2023
2 parents c867dca + f45b0c0 commit e30bab3
Show file tree
Hide file tree
Showing 11 changed files with 520 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ jobs:
uses: AntelopeIO/asset-artifact-download-action@v3
with:
owner: eosnetworkfoundation
repo: eos-evm
repo: eos-evm-contract
target: '${{needs.versions.outputs.eos-evm-contract-target}}'
prereleases: ${{fromJSON(needs.versions.outputs.eos-evm-contract-prerelease)}}
file: 'contract.tar.gz'
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ project(eos-evm-node)

set(VERSION_MAJOR 0)
set(VERSION_MINOR 6)
set(VERSION_PATCH 1)
set(VERSION_PATCH 3)
#set(VERSION_SUFFIX stable)

if(VERSION_SUFFIX)
Expand Down
11 changes: 9 additions & 2 deletions peripherals/proxy/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,22 @@ http {
~^5 1;
}

limit_req_zone $http_x_forwarded_for zone=rate_limit_zone:10m rate=5r/s;
limit_conn_zone $http_x_forwarded_for zone=conn_limit_zone:10m;

server {
listen 80;
server_name localhost;

location / {
location / {
limit_req zone=rate_limit_zone burst=25 nodelay;
limit_req_dry_run on;
try_files /nonexistent @$http_upgrade;
}

location @websocket {
location @websocket {
limit_conn conn_limit_zone 2;
limit_conn_dry_run on;
# websocket related stuff
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
Expand Down
4 changes: 4 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ configure_file(nodeos_eos_evm_ws_test_basic.py . COPYONLY)
configure_file(nodeos_eos_evm_ws_test_fork.py . COPYONLY)
configure_file(nodeos_eos_evm_server.py . COPYONLY)
configure_file(nodeos_eos_evm_test.py . COPYONLY)
configure_file(defertest.wasm . COPYONLY)
configure_file(defertest.abi . COPYONLY)
configure_file(defertest2.wasm . COPYONLY)
configure_file(defertest2.abi . COPYONLY)
97 changes: 97 additions & 0 deletions tests/defertest.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"____comment": "This file was generated with eosio-abigen. DO NOT EDIT ",
"version": "eosio::abi/1.2",
"types": [],
"structs": [
{
"name": "pending",
"base": "",
"fields": [
{
"name": "id",
"type": "uint64"
},
{
"name": "account",
"type": "name"
},
{
"name": "miner",
"type": "name"
},
{
"name": "rlptx",
"type": "bytes"
}
]
},
{
"name": "pushdefer",
"base": "",
"fields": [
{
"name": "id",
"type": "uint64"
},
{
"name": "account",
"type": "name"
},
{
"name": "miner",
"type": "name"
},
{
"name": "rlptx",
"type": "bytes"
},
{
"name": "rlptx2",
"type": "bytes"
}
]
},
{
"name": "pushtxinline",
"base": "",
"fields": [
{
"name": "account",
"type": "name"
},
{
"name": "miner",
"type": "name"
},
{
"name": "rlptx",
"type": "bytes"
}
]
}
],
"actions": [
{
"name": "pushdefer",
"type": "pushdefer",
"ricardian_contract": ""
},
{
"name": "pushtxinline",
"type": "pushtxinline",
"ricardian_contract": ""
}
],
"tables": [
{
"name": "pending",
"type": "pending",
"index_type": "i64",
"key_names": [],
"key_types": []
}
],
"ricardian_clauses": [],
"variants": [],
"action_results": []
}
94 changes: 94 additions & 0 deletions tests/defertest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <type_traits>
#include <tuple>
#include <eosio/eosio.hpp>
#include <eosio/asset.hpp>
#include <eosio/contract.hpp>
#include <eosio/system.hpp>
#include <eosio/transaction.hpp>
#include <eosio/serialize.hpp>
#include <eosio/print.hpp>
#include <eosio/name.hpp>

using namespace eosio;
using namespace std;

extern "C" {
__attribute__((eosio_wasm_import))
uint64_t current_time();
}

class [[eosio::contract("defertest")]] defertest : public eosio::contract {

public:
using contract::contract;

int32_t now() {
return current_time() / 1000000;
}

struct [[eosio::table]] pending {
uint64_t id;
eosio::name account;
eosio::name miner;
std::vector<char> rlptx;

uint64_t primary_key() const { return id; }
};
typedef eosio::multi_index<"pending"_n, pending> pending_table_t;

// notify by the contract account of contract "defertest2.cpp"
[[eosio::on_notify("*::notifytest")]] void notifytest(eosio::name recipient, eosio::name account, eosio::name miner, const std::vector<char> &rlptx, const std::vector<char> &rlptx2) {
action act({_self, "active"_n}, account, "pushtx"_n,
std::tuple<eosio::name, std::vector<char> >(miner, rlptx2));
act.send();
}

[[eosio::action]] void pushtxinline(eosio::name account, eosio::name miner, const std::vector<char> &rlptx) {
action act({_self, "active"_n}, account, "pushtx"_n,
std::tuple<eosio::name, std::vector<char> >(miner, rlptx));
act.send();
}

[[eosio::action]] void pushdefer(uint64_t id, eosio::name account, eosio::name miner, const std::vector<char> &rlptx, const std::vector<char> &rlptx2) {

printf("enter defertest.cpp::pushdefer:%d %d", (int)rlptx.size(), (int)rlptx2.size());

action act(permission_level{_self, "active"_n}, account, "pushtx"_n, std::tuple<eosio::name, std::vector<char> >(miner, rlptx));
transaction txn(time_point_sec(current_time() + 3590));
txn.actions.push_back(act);
auto serialize = pack(txn);
::send_deferred((uint128_t)(id), _self, serialize.data(), serialize.size(), true);

if (rlptx2.size()) {
pending_table_t pending_table(_self, _self.value);
pending_table.emplace(_self, [&](auto &v) {
v.id = id;
v.account = account;
v.miner = miner;
v.rlptx = rlptx2;
});
}
}

[[eosio::on_notify("eosio::onerror")]] void onerror() {

pending_table_t pending_table(_self, _self.value);
if (pending_table.begin() != pending_table.end()) {

printf("defertest.cpp::onerror() 1");
auto itr = pending_table.end();
--itr;
action act(permission_level{_self, "active"_n}, itr->account, "pushtx"_n,
std::tuple<eosio::name, std::vector<char> >(itr->miner, itr->rlptx));
act.send();
pending_table.erase(itr);
}
else {
printf("defertest.cpp::onerror() 2");
check(false, "hard-fail");
}
}
};
Binary file added tests/defertest.wasm
Binary file not shown.
44 changes: 44 additions & 0 deletions tests/defertest2.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"____comment": "This file was generated with eosio-abigen. DO NOT EDIT ",
"version": "eosio::abi/1.2",
"types": [],
"structs": [
{
"name": "notifytest",
"base": "",
"fields": [
{
"name": "recipient",
"type": "name"
},
{
"name": "account",
"type": "name"
},
{
"name": "miner",
"type": "name"
},
{
"name": "rlptx",
"type": "bytes"
},
{
"name": "rlptx2",
"type": "bytes"
}
]
}
],
"actions": [
{
"name": "notifytest",
"type": "notifytest",
"ricardian_contract": ""
}
],
"tables": [],
"ricardian_clauses": [],
"variants": [],
"action_results": []
}
32 changes: 32 additions & 0 deletions tests/defertest2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <type_traits>
#include <tuple>
#include <eosio/eosio.hpp>
#include <eosio/contract.hpp>
#include <eosio/system.hpp>
#include <eosio/transaction.hpp>
#include <eosio/serialize.hpp>
#include <eosio/print.hpp>
#include <eosio/name.hpp>

using namespace eosio;
using namespace std;

class [[eosio::contract("defertest2")]] defertest2 : public eosio::contract {

public:
using contract::contract;

// recipient is the contract account of contract "defertest.cpp"
[[eosio::action]] void notifytest(eosio::name recipient, eosio::name account, eosio::name miner, const std::vector<char> &rlptx, const std::vector<char> &rlptx2) {

action act({_self, "active"_n}, recipient, "pushtxinline"_n,
std::tuple<eosio::name, eosio::name, std::vector<char> >(account, miner, rlptx));
act.send();

require_recipient(recipient);
}

};
Binary file added tests/defertest2.wasm
Binary file not shown.
Loading

0 comments on commit e30bab3

Please sign in to comment.