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

evm: DST20 support #2231

Merged
merged 44 commits into from
Jul 28, 2023
Merged
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
2fd1273
WIP: counter contract
shohamc1 Jul 21, 2023
2c293c6
Run code during finalize_block instead of through FFI
shohamc1 Jul 24, 2023
a3f181a
Merge branch 'master' into evm/state-root-fix
shohamc1 Jul 24, 2023
8574bd8
Remove FFI code, move contract and utils to new crate
shohamc1 Jul 24, 2023
474b21b
Undo more changes
shohamc1 Jul 24, 2023
3a8cafc
Declare addresses in contracts crate
shohamc1 Jul 24, 2023
608aaef
Rename contracts to ain-contracts
shohamc1 Jul 24, 2023
906b8c9
Fix clippy errors
shohamc1 Jul 24, 2023
e0508b0
Remove extra new line, update gitignore
shohamc1 Jul 24, 2023
4ee9b8d
Undo old changes
shohamc1 Jul 24, 2023
0ffc20a
Remove unwraps
shohamc1 Jul 24, 2023
034ff16
Add test header
shohamc1 Jul 25, 2023
49ec7c6
Refactor to use `get_contract_storage`
shohamc1 Jul 25, 2023
ad1c1a0
Make `basic` optional in `apply`
shohamc1 Jul 25, 2023
45f8c29
Rename to `pkg_install_solc`
shohamc1 Jul 25, 2023
6192b98
Fix make.sh, remove redundant clone
shohamc1 Jul 25, 2023
e0b1646
Merge branch 'master' into evm/state-root-fix
shohamc1 Jul 25, 2023
6fbd318
Compile multiple contracts
shohamc1 Jul 25, 2023
979b731
Add DST20 support
shohamc1 Jul 25, 2023
3264493
Only deploy DST20 of DATs
shohamc1 Jul 25, 2023
2ce3492
Use executor state for bridge, add more tests
shohamc1 Jul 25, 2023
a32949f
Add tests, fix empty balance bridge issue
shohamc1 Jul 26, 2023
e72341f
Refactor rest of DST20 tests
shohamc1 Jul 26, 2023
82fc996
Merge branch 'master' into evm/dst20-2
shohamc1 Jul 27, 2023
96476ae
Add 0 balance test
shohamc1 Jul 27, 2023
2407513
Fix lints
shohamc1 Jul 27, 2023
10e93a2
Merge branch 'master' into evm/dst20-2
prasannavl Jul 27, 2023
2d034e5
Merge branch 'master' into evm/dst20-2
prasannavl Jul 27, 2023
c776c5e
Merge branch 'master' into evm/dst20-2
prasannavl Jul 27, 2023
43e6fed
Use SOLC_PATH, fix build, add more tests
shohamc1 Jul 28, 2023
e182e0e
Add check for same token ID
shohamc1 Jul 28, 2023
6c5c0ed
Merge branch 'master' into evm/dst20-2
shohamc1 Jul 28, 2023
e199b26
Move BridgeTx into SystemTx
shohamc1 Jul 28, 2023
b1f647d
Validate DST20 code during transferdomain
shohamc1 Jul 28, 2023
08ebc28
Check for address usage before deployment
shohamc1 Jul 28, 2023
f87de98
Merge remote-tracking branch 'origin/master' into evm/dst20-2
shohamc1 Jul 28, 2023
0059792
Add feature flag for transferdomain
shohamc1 Jul 28, 2023
4513fa8
Merge branch master into evm/dst20-2
Jouzo Jul 28, 2023
a0a6ad3
Feature flag every edges
Jouzo Jul 28, 2023
e6e6159
Trigger actions
Jouzo Jul 28, 2023
ec856c5
Merge branch master into evm/dst20-2
Jouzo Jul 28, 2023
ec1c8c1
Merge branch 'master' into evm/dst20-2
prasannavl Jul 28, 2023
dbde6ec
Merge branch 'master' into evm/dst20-2
Jouzo Jul 28, 2023
6062ead
Remove unused attributes
Jouzo Jul 28, 2023
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
Merge branch master into evm/dst20-2
Jouzo committed Jul 28, 2023

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit ec856c58f14f34991c9436ed183d8e6f61b9aa7b
16 changes: 8 additions & 8 deletions src/masternodes/errors.h
Original file line number Diff line number Diff line change
@@ -438,20 +438,20 @@ class DeFiErrors {
return Res::Err("Source token and destination token must be the same");
}

static Res TransferDomainDVMNativeNotEnabled() {
return Res::Err("transferdomain for DFI from DVM is not enabled");
static Res TransferDomainDVMToEVMNativeTokenNotEnabled() {
return Res::Err("transferdomain for DFI from DVM to EVM is not enabled");
}

static Res TransferDomainEVMNativeNotEnabled() {
return Res::Err("transferdomain for DFI from EVM is not enabled");
static Res TransferDomainEVMToDVMNativeTokenNotEnabled() {
return Res::Err("transferdomain for DFI from EVM to DVM is not enabled");
}

static Res TransferDomainDST20DVMNotEnabled() {
return Res::Err("transferdomain for DST20 from DVM is not enabled");
static Res TransferDomainDVMToEVMDATNotEnabled() {
return Res::Err("transferdomain for DST20 from DVM to EVM is not enabled");
}

static Res TransferDomainDST20EVMNotEnabled() {
return Res::Err("transferdomain for DST20 from EVM is not enabled");
static Res TransferDomainEVMToDVMDATNotEnabled() {
return Res::Err("transferdomain for DST20 from EVM to DVM is not enabled");
}

static Res TransferDomainIncorrectToken() {
45 changes: 14 additions & 31 deletions src/masternodes/mn_checks.cpp
Original file line number Diff line number Diff line change
@@ -4131,17 +4131,17 @@ Res ValidateTransferDomainEdge(const CTransaction &tx,
if (src.amount.nTokenId != dst.amount.nTokenId)
return DeFiErrors::TransferDomainDifferentTokens();

if (src.amount.nTokenId == DCT_ID{0} && !transferdomainConfig.dvmNativeToken)
return DeFiErrors::TransferDomainDVMNativeNotEnabled();
if (src.amount.nTokenId == DCT_ID{0} && !config.dvmToEvmNativeTokenEnabled)
return DeFiErrors::TransferDomainDVMToEVMNativeTokenNotEnabled();

if (dst.amount.nTokenId == DCT_ID{0} && !transferdomainConfig.evmNativeToken)
return DeFiErrors::TransferDomainEVMNativeNotEnabled();
if (dst.amount.nTokenId == DCT_ID{0} && !config.evmToDvmNativeTokenEnabled)
return DeFiErrors::TransferDomainEVMToDVMNativeTokenNotEnabled();

if (src.amount.nTokenId != DCT_ID{0} && !transferdomainConfig.dvmDatEnabled)
return DeFiErrors::TransferDomainDST20DVMNotEnabled();
if (src.amount.nTokenId != DCT_ID{0} && !config.dvmToEvmDatEnabled)
return DeFiErrors::TransferDomainDVMToEVMDATNotEnabled();

if (dst.amount.nTokenId != DCT_ID{0} && !transferdomainConfig.evmDatEnabled)
return DeFiErrors::TransferDomainDST20EVMNotEnabled();
if (dst.amount.nTokenId != DCT_ID{0} && !config.evmToDvmDatEnabled)
return DeFiErrors::TransferDomainEVMToDVMDATNotEnabled();

if (src.domain == static_cast<uint8_t>(VMDomain::DVM) && dst.domain == static_cast<uint8_t>(VMDomain::EVM)) {
if (height >= static_cast<uint32_t>(consensus.ChangiIntermediateHeight4)) {
@@ -4199,15 +4199,15 @@ TransferDomainLiveConfig GetTransferDomainConfig(CCustomCSView &mnview) {
TransferDomainLiveConfig config{
attributes->GetValue(dvm_to_evm_enabled, true),
attributes->GetValue(evm_to_dvm_enabled, true),
attributes->GetValue(dvm_to_evm_src_formats, XVmAddressFormatItems {
attributes->GetValue(dvm_to_evm_src_formats, XVmAddressFormatItems {
XVmAddressFormatTypes::Bech32, XVmAddressFormatTypes::PkHash }),
attributes->GetValue(dvm_to_evm_dest_formats, XVmAddressFormatItems {
attributes->GetValue(dvm_to_evm_dest_formats, XVmAddressFormatItems {
XVmAddressFormatTypes::Erc55 }),
attributes->GetValue(evm_to_dvm_dest_formats, XVmAddressFormatItems {
attributes->GetValue(evm_to_dvm_dest_formats, XVmAddressFormatItems {
XVmAddressFormatTypes::Bech32, XVmAddressFormatTypes::PkHash }),
attributes->GetValue(evm_to_dvm_src_formats, XVmAddressFormatItems {
attributes->GetValue(evm_to_dvm_src_formats, XVmAddressFormatItems {
XVmAddressFormatTypes::Erc55 }),
attributes->GetValue(evm_to_dvm_auth_formats, XVmAddressFormatItems {
attributes->GetValue(evm_to_dvm_auth_formats, XVmAddressFormatItems {
XVmAddressFormatTypes::Bech32ProxyErc55, XVmAddressFormatTypes::PkHashProxyErc55 }),
attributes->GetValue(dvm_to_evm_native_enabled, true),
attributes->GetValue(evm_to_dvm_native_enabled, true),
@@ -4246,24 +4246,7 @@ Res ValidateTransferDomain(const CTransaction &tx,
}
}

CDataStructureV0 evm_dvm{AttributeTypes::Transfer, TransferIDs::Edges, TransferKeys::EVM_DVM};
CDataStructureV0 dvm_evm{AttributeTypes::Transfer, TransferIDs::Edges, TransferKeys::DVM_EVM};
CDataStructureV0 dst20_dvm{AttributeTypes::Param, ParamIDs::Feature, DFIPKeys::DST20DVM};
CDataStructureV0 dst20_evm{AttributeTypes::Param, ParamIDs::Feature, DFIPKeys::DST20EVM};
CDataStructureV0 transferdomainNativeDVM{AttributeTypes::Param, ParamIDs::Feature, DFIPKeys::TransferDomainNativeDVM};
CDataStructureV0 transferdomainNativeEVM{AttributeTypes::Param, ParamIDs::Feature, DFIPKeys::TransferDomainNativeEVM};
const auto attributes = mnview.GetAttributes();
assert(attributes);
TransferDomainLiveConfig transferdomainConfig{
attributes->GetValue(dvm_evm, false),
attributes->GetValue(evm_dvm, false),
attributes->GetValue(transferdomainNativeDVM, false),
attributes->GetValue(transferdomainNativeEVM, false),
attributes->GetValue(dst20_dvm, false),
attributes->GetValue(dst20_evm, false),
{},
{}
};
auto config = GetTransferDomainConfig(mnview);

for (const auto &[src, dst] : obj.transfers) {
auto res = ValidateTransferDomainEdge(tx, config, height, coins, consensus, src, dst);
You are viewing a condensed version of this merge commit. You can view the full changes here.