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

Add Cronos support #58

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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:[email protected]:1234/
MODULE_zcash-main_REQUESTER_TIMEOUT=60
MODULE_zcash-main_REQUESTER_THREADS=12

######################
## Main Cronos Module
######################

MODULES[]=cronos-main
MODULE_cronos-main_CLASS=CronosMainModule
MODULE_cronos-main_NODES[]=http://login:[email protected]:1234/
MODULE_cronos-main_NODES[]=http://login:[email protected]:1234/
MODULE_cronos-main_REQUESTER_TIMEOUT=60
MODULE_cronos-main_REQUESTER_THREADS=12

######################
## Trace Cronos Module
######################

MODULES[]=cronos-trace
MODULE_cronos-trace_CLASS=CronosTraceModule
MODULE_cronos-trace_NODES[]=http://login:[email protected]:1234/
MODULE_cronos-trace_NODES[]=http://login:[email protected]:1234/
MODULE_cronos-trace_REQUESTER_TIMEOUT=60
MODULE_cronos-trace_REQUESTER_THREADS=12

######################
## ERC20 Cronos Module
######################

MODULES[]=cronos-erc-20
MODULE_cronos-erc-20_CLASS=CronosERC20Module
MODULE_cronos-erc-20_NODES[]=http://login:[email protected]:1234/
MODULE_cronos-erc-20_NODES[]=http://login:[email protected]:1234/
MODULE_cronos-erc-20_REQUESTER_TIMEOUT=60
MODULE_cronos-erc-20_REQUESTER_THREADS=12

######################
## ERC721 Cronos Module
######################

MODULES[]=cronos-erc-721
MODULE_cronos-erc-721_CLASS=CronosERC721Module
MODULE_cronos-erc-721_NODES[]=http://login:[email protected]:1234/
MODULE_cronos-erc-721_NODES[]=http://login:[email protected]:1234/
MODULE_cronos-erc-721_REQUESTER_TIMEOUT=60
MODULE_cronos-erc-721_REQUESTER_THREADS=12

######################
## ERC1155 Cronos Module
######################

MODULES[]=cronos-erc-1155
MODULE_cronos-erc-1155_CLASS=CronosERC1155Module
MODULE_cronos-erc-1155_NODES[]=http://login:[email protected]:1234/
MODULE_cronos-erc-1155_NODES[]=http://login:[email protected]:1234/
MODULE_cronos-erc-1155_REQUESTER_TIMEOUT=60
MODULE_cronos-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 @@ -9,3 +9,5 @@
- TVM modules
* [Oleg Makaussov](https://github.com/Lorgansar)
- Cardano Tokens modules
* [Kirill Kuzminykh](https://github.com/Oskal174)
- Cronos modules
5 changes: 4 additions & 1 deletion Modules/Common/EVMMainModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ final public function post_post_initialize()

if (is_null($this->reward_function))
throw new DeveloperError("`reward_function` is not set (developer error)");

if (in_array(EVMSpecialFeatures::PoSWithdrawals, $this->extra_features) && is_null($this->staking_contract))
throw new DeveloperError('`staking_contract` is not set when `PoSWithdrawals` is enabled');

Expand Down Expand Up @@ -236,6 +236,9 @@ final public function pre_process_block($block_id)
result_in: 'result', timeout: $this->timeout);
}

if (in_array(EVMSpecialFeatures::FeesToTreasury, $this->extra_features))
$miner = 'treasury';

// Data processing

$this->block_time = date('Y-m-d H:i:s', to_int64_from_0xhex($block_time));
Expand Down
1 change: 1 addition & 0 deletions 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 FeesToTreasury;
}

trait EVMTraits
Expand Down
20 changes: 20 additions & 0 deletions Modules/CronosERC1155Module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php declare(strict_types = 1);

/* Idea (c) 2023 Nikita Zhavoronkov, [email protected]
* Copyright (c) 2023 3xpl developers, [email protected], see CONTRIBUTORS.md
* Distributed under the MIT software license, see LICENSE.md */

/* This module processes ERC-1155 MT transfers in Cronos. */

final class CronosERC1155Module extends EVMERC1155Module implements Module
{
function initialize()
{
// CoreModule
$this->blockchain = 'cronos';
$this->module = 'cronos-erc-1155';
$this->is_main = false;
$this->first_block_date = '2021-11-08';
$this->first_block_id = 0;
}
}
20 changes: 20 additions & 0 deletions Modules/CronosERC20Module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php declare(strict_types = 1);

/* Idea (c) 2023 Nikita Zhavoronkov, [email protected]
* Copyright (c) 2023 3xpl developers, [email protected], see CONTRIBUTORS.md
* Distributed under the MIT software license, see LICENSE.md */

/* This module processes ERC-20 token transfers in Cronos. */

final class CronosERC20Module extends EVMERC20Module implements Module
{
function initialize()
{
// CoreModule
$this->blockchain = 'cronos';
$this->module = 'cronos-erc-20';
$this->is_main = false;
$this->first_block_date = '2021-11-08';
$this->first_block_id = 1;
}
}
20 changes: 20 additions & 0 deletions Modules/CronosERC721Module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php declare(strict_types = 1);

/* Idea (c) 2023 Nikita Zhavoronkov, [email protected]
* Copyright (c) 2023 3xpl developers, [email protected], see CONTRIBUTORS.md
* Distributed under the MIT software license, see LICENSE.md */

/* This module processes ERC-721 NFT transfers in Cronos. */

final class CronosERC721Module extends EVMERC721Module implements Module
{
function initialize()
{
// CoreModule
$this->blockchain = 'cronos';
$this->module = 'cronos-erc-721';
$this->is_main = false;
$this->first_block_date = '2021-11-08';
$this->first_block_id = 0;
}
}
30 changes: 30 additions & 0 deletions Modules/CronosMainModule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php declare(strict_types = 1);

/* Idea (c) 2023 Nikita Zhavoronkov, [email protected]
* Copyright (c) 2023 3xpl developers, [email protected], see CONTRIBUTORS.md
* Distributed under the MIT software license, see LICENSE.md */

/* This is the main Cronos module. */

final class CronosMainModule extends EVMMainModule implements Module
{
function initialize()
{
// CoreModule
$this->blockchain = 'cronos';
$this->module = 'cronos-main';
$this->is_main = true;
$this->currency = 'cronos';
$this->currency_details = ['name' => 'Cronos', 'symbol' => 'CRO', 'decimals' => 18, 'description' => null];
$this->first_block_id = 1;
$this->first_block_date = '2021-11-08';

// EVMMainModule
$this->evm_implementation = EVMImplementation::geth;
$this->extra_features = [EVMSpecialFeatures::FeesToTreasury];
$this->reward_function = function($block_id)
{
return '0';
};
}
}
24 changes: 24 additions & 0 deletions Modules/CronosTraceModule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php declare(strict_types = 1);

/* Idea (c) 2023 Nikita Zhavoronkov, [email protected]
* Copyright (c) 2023 3xpl developers, [email protected], see CONTRIBUTORS.md
* Distributed under the MIT software license, see LICENSE.md */

/* This module processes internal Cronos transactions (using block tracing). */

final class CronosTraceModule extends EVMTraceModule implements Module
{
function initialize()
{
// CoreModule
$this->blockchain = 'cronos';
$this->module = 'cronos-trace';
$this->complements = 'cronos-main';
$this->is_main = false;
$this->first_block_id = 1;
$this->first_block_date = '2021-11-08';

// EVMTraceModule
$this->evm_implementation = EVMImplementation::geth;
}
}