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

In design, are system contracts addresses able to be payable? #1490

Closed
yangby-cryptape opened this issue Oct 20, 2023 · 6 comments
Closed

In design, are system contracts addresses able to be payable? #1490

yangby-cryptape opened this issue Oct 20, 2023 · 6 comments
Assignees

Comments

@yangby-cryptape
Copy link
Collaborator

yangby-cryptape commented Oct 20, 2023

Question

In other words, could I send tokens to a system contract address?

@KaoImin
Copy link
Contributor

KaoImin commented Oct 20, 2023

Currently, you can do this. However, it is a waste of tokens.

@yangby-cryptape
Copy link
Collaborator Author

yangby-cryptape commented Oct 20, 2023

Currently, you can do this. However, it is a waste of tokens.

But when I do transfer in MetaMask, it returns "Invalid system script transaction".

So, can you confirm what you said above?

@KaoImin
Copy link
Contributor

KaoImin commented Oct 20, 2023

Currently, you can do this. However, it is a waste of tokens.

But when I do transfer in MetaMask, it returns "Invalid system script transaction".

So, can you confirm what you said above?

Sorry, I forget the call system contract inspection:

async fn check_system_script_tx_authorization(
&self,
ctx: Context,
stx: &SignedTransaction,
) -> ProtocolResult<U256> {
let addr = &stx.sender;
let block = self.storage.get_latest_block(ctx.clone()).await?;
let root = self.executor_backend(ctx).await?.get_metadata_root();
if MetadataHandle::new(root).is_validator(block.header.number + 1, *addr)? {
return Ok(U256::zero());
}
Err(MemPoolError::CheckAuthorization {
tx_hash: stx.transaction.hash,
err_info: "Invalid system script transaction".to_string(),
}
.into())
}

Nobody can send tokens to a system contract address because if the transaction calls a system contract address, executor will not execute it in EVM.
pub fn system_contract_dispatch<Adapter: ExecutorAdapter + ApplyBackend>(
adapter: &mut Adapter,
tx: &SignedTransaction,
) -> Option<TxResp> {
if let Some(addr) = tx.get_to() {
log::debug!("execute addr {:}", addr);
if addr == NATIVE_TOKEN_CONTRACT_ADDRESS {
return Some(NativeTokenContract::default().exec_(adapter, tx));
} else if addr == METADATA_CONTRACT_ADDRESS {
return Some(MetadataContract::default().exec_(adapter, tx));
} else if addr == CKB_LIGHT_CLIENT_CONTRACT_ADDRESS {
return Some(CkbLightClientContract::default().exec_(adapter, tx));
} else if addr == IMAGE_CELL_CONTRACT_ADDRESS {
return Some(ImageCellContract::default().exec_(adapter, tx));
}
}
None
}

@yangby-cryptape
Copy link
Collaborator Author

Nobody can send tokens to a system contract address ...

Please check the Metadata contract address in the Axon internal testnet.

Its balance is 1,539.471495196523525479 ETH.

I forget the call system contract inspection ...

The inspection could be bypassed.


How to reproduce?


I have checked the latest commit 8a0e1a9. I think I have got the same result.

@yangby-cryptape yangby-cryptape changed the title [Question] In design, are system contracts addresses able to be payable? [Bug?] In design, are system contracts addresses able to be payable? Oct 20, 2023
@KaoImin
Copy link
Contributor

KaoImin commented Oct 23, 2023

@driftluo please check why the transfer process of system contract transactions can be executed. The system contract does not execute in EVM and change the balance.

@yangby-cryptape
Copy link
Collaborator Author

yangby-cryptape commented Oct 23, 2023

@driftluo please check why the transfer process of system contract transactions can be executed. The system contract does not execute in EVM and change the balance.

Because the rust code won't be called in the EVM executor.

The executor will fetch the data of that address and execute the data as code.

@Flouse Flouse closed this as not planned Won't fix, can't repro, duplicate, stale Nov 9, 2023
@yangby-cryptape yangby-cryptape changed the title [Bug?] In design, are system contracts addresses able to be payable? In design, are system contracts addresses able to be payable? Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants