Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
55 changes: 55 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,61 @@ MODULE_zcash-main_NODES[]=http://login:password@127.0.0.2:1234/
MODULE_zcash-main_REQUESTER_TIMEOUT=60
MODULE_zcash-main_REQUESTER_THREADS=12

######################
## Main Filecoin Module
######################

MODULES[]=filecoin-main
MODULE_filecoin-main_CLASS=FilecoinMainModule
MODULE_filecoin-main_NODES[]=http://login:password@127.0.0.2:1234/
MODULE_filecoin-main_NODES[]=http://login:password@127.0.0.2:1234/
MODULE_filecoin-main_REQUESTER_TIMEOUT=60
MODULE_filecoin-main_REQUESTER_THREADS=12

######################
## Trace Filecoin Module
######################

MODULES[]=filecoin-trace
MODULE_filecoin-trace_CLASS=FilecoinTraceModule
MODULE_filecoin-trace_NODES[]=http://login:password@127.0.0.2:1234/
MODULE_filecoin-trace_NODES[]=http://login:password@127.0.0.2:1234/
MODULE_filecoin-trace_REQUESTER_TIMEOUT=60
MODULE_filecoin-trace_REQUESTER_THREADS=12

######################
## ERC20 EVM Filecoin Module
######################

MODULES[]=filecoin-evm-erc-20
MODULE_filecoin-evm-erc-20_CLASS=FilecoinEVMERC20Module
MODULE_filecoin-evm-erc-20_NODES[]=http://login:password@127.0.0.2:1234/
MODULE_filecoin-evm-erc-20_NODES[]=http://login:password@127.0.0.2:1234/
MODULE_filecoin-evm-erc-20_REQUESTER_TIMEOUT=60
MODULE_filecoin-evm-erc-20_REQUESTER_THREADS=12

######################
## ERC721 EVM Filecoin Module
######################

MODULES[]=filecoin-evm-erc-721
MODULE_filecoin-evm-erc-721_CLASS=FilecoinEVMERC721Module
MODULE_filecoin-evm-erc-721_NODES[]=http://login:password@127.0.0.2:1234/
MODULE_filecoin-evm-erc-721_NODES[]=http://login:password@127.0.0.2:1234/
MODULE_filecoin-evm-erc-721_REQUESTER_TIMEOUT=60
MODULE_filecoin-evm-erc-721_REQUESTER_THREADS=12

######################
## ERC1155 EVM Filecoin Module
######################

MODULES[]=filecoin-evm-erc-1155
MODULE_filecoin-evm-erc-1155_CLASS=FilecoinEVMERC1155Module
MODULE_filecoin-evm-erc-1155_NODES[]=http://login:password@127.0.0.2:1234/
MODULE_filecoin-evm-erc-1155_NODES[]=http://login:password@127.0.0.2:1234/
MODULE_filecoin-evm-erc-1155_REQUESTER_TIMEOUT=60
MODULE_filecoin-evm-erc-1155_REQUESTER_THREADS=12

############################
# Titles, descriptions, etc.
############################
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@
- Beacon Chain modules
* [alexqrid](https://github.com/alexqrid)
- TVM modules
* [Kirill Kuzminykh](https://github.com/Oskal174)
- Filecoin modules
* [Oleg Makaussov](https://github.com/Lorgansar)
- Cardano Tokens modules
4 changes: 2 additions & 2 deletions Engine/Requester.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/* Various curl functions for requesting data from nodes */

// Just a single curl request
function requester_single($daemon, $endpoint = '', $params = [], $result_in = '', $timeout = 600, $valid_codes = [200], $no_json_encode = false, $flags = [])
function requester_single($daemon, $endpoint = '', $params = [], $result_in = '', $ignore_errors = false, $timeout = 600, $valid_codes = [200], $no_json_encode = false, $flags = [])
{
static $curl = null;

Expand Down Expand Up @@ -106,7 +106,7 @@ function requester_single($daemon, $endpoint = '', $params = [], $result_in = ''
throw new RequesterException("requester_request(daemon:({$daemon_clean}), endpoint:({$endpoint}), params:({$params_log}), result_in:({$result_in})) failed: bad JSON; preg error: {$e_preg}, json error: {$e_json}"); // . print_r($output, true)
}

if (isset($output['error']))
if (isset($output['error']) && !$ignore_errors)
{
throw new RequesterException("requester_request(daemon:({$daemon_clean}), endpoint:({$endpoint}), params:({$params_log}), result_in:({$result_in})) errored: " . print_r($output['error'], true));
}
Expand Down
8 changes: 8 additions & 0 deletions Modules/Common/EVMERC1155Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ final public function pre_process_block($block_id)

if ((!in_array(EVMSpecialFeatures::zkEVM, $this->extra_features)))
{
// Filecoin may have empty tipsets (ex. 3508881)
if (in_array(EVMSpecialFeatures::fEVM, $this->extra_features) && $this->block_hash === '')
{
$this->set_return_events([]);
$this->set_return_currencies([]);
return;
}

$multi_curl[] = requester_multi_prepare($this->select_node(),
params: ['jsonrpc' => '2.0',
'method' => 'eth_getLogs',
Expand Down
8 changes: 8 additions & 0 deletions Modules/Common/EVMERC20Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ final public function pre_process_block($block_id)

if ((!in_array(EVMSpecialFeatures::zkEVM, $this->extra_features)))
{
// Filecoin may have empty tipsets (ex. 3508881)
if (in_array(EVMSpecialFeatures::fEVM, $this->extra_features) && $this->block_hash === '')
{
$this->set_return_events([]);
$this->set_return_currencies([]);
return;
}

$logs = requester_single($this->select_node(),
params: ['jsonrpc' => '2.0',
'method' => 'eth_getLogs',
Expand Down
8 changes: 8 additions & 0 deletions Modules/Common/EVMERC721Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ final public function pre_process_block($block_id)

if ((!in_array(EVMSpecialFeatures::zkEVM, $this->extra_features)))
{
// Filecoin may have empty tipsets (ex. 3508881)
if (in_array(EVMSpecialFeatures::fEVM, $this->extra_features) && $this->block_hash === '')
{
$this->set_return_events([]);
$this->set_return_currencies([]);
return;
}

$logs = requester_single($this->select_node(),
params: ['jsonrpc' => '2.0',
'method' => 'eth_getLogs',
Expand Down
28 changes: 27 additions & 1 deletion Modules/Common/EVMTraits.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ enum EVMSpecialFeatures
case zkEVM;
case HasSystemTransactions;
case EffectiveGasPriceCanBeZero;
case fEVM; // Filecoin EVM
}

trait EVMTraits
Expand Down Expand Up @@ -87,7 +88,32 @@ public function ensure_block($block_id, $break_on_first = false)
throw new RequesterException("ensure_block(block_id: {$block_id}): no connection, previously: " . $e->getMessage());
}

$result0 = requester_multi_process($curl_results[0], result_in: 'result');
$ignore_errors = false;
$result_in = 'result';
if (in_array(EVMSpecialFeatures::fEVM, $this->extra_features))
{
$ignore_errors = true;
$result_in = '';
}

$result0 = requester_multi_process($curl_results[0], ignore_errors: $ignore_errors, result_in: $result_in);

// Filecoin may have empty tipsets (ex. 3508881)
if (in_array(EVMSpecialFeatures::fEVM, $this->extra_features))
{
if (isset($result0['error']))
{
if ($result0['error']['message'] === 'requested epoch was a null round')
{
$this->block_hash = '';
$this->block_time = date('Y-m-d H:i:s', 0);
return;
}
throw new ModuleException("requester_multi_process errored: " . print_r($result0['error'], true));
}

$result0 = $result0['result'];
}

$hash_key = (!in_array(EVMSpecialFeatures::zkEVM, $this->extra_features))
? 'hash'
Expand Down
Loading