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 the smart chain id to the evm tx signature #204

Merged
merged 2 commits into from
Jul 4, 2022
Merged
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
3 changes: 3 additions & 0 deletions contracts/periphery/contracts/s2s/calls/PangolinCalls.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ library PangolinCalls {
// https://github.com/darwinia-network/darwinia-messages-substrate/issues/107#issuecomment-1164185135
uint64 public constant MAX_GAS_LIMIT = 10_000_000;

uint64 public constant SMART_CHAIN_ID = 43;

function system_remark(bytes memory remark)
internal
pure
Expand Down Expand Up @@ -53,6 +55,7 @@ library PangolinCalls {
PalletEthereum.buildTransactionV2ForMessageTransact(
gasLimit,
to,
SMART_CHAIN_ID,
input
)
);
Expand Down
4 changes: 2 additions & 2 deletions contracts/periphery/contracts/s2s/examples/TransactDemo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ contract TransactDemo is PangoroXApp {
init();
}

uint256 public number;

///////////////////////////////////////////
// used on the source chain
///////////////////////////////////////////
Expand Down Expand Up @@ -42,6 +40,8 @@ contract TransactDemo is PangoroXApp {
///////////////////////////////////////////
// used on the target chain
///////////////////////////////////////////
uint256 public number;

function add(uint256 _value) public {
// This function is only allowed to be called by the derived address
// of the message sender on the source chain.
Expand Down
1 change: 1 addition & 0 deletions contracts/periphery/contracts/s2s/test/Transact.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ contract Transact {
1000000000, // gasPrice, get from the target chain
600000, // gasLimit, get from the target chain
0x50275d3F95E0F2FCb2cAb2Ec7A231aE188d7319d, // <------------------ change to the contract address on the target chain
43, // smart chain id
0, // value, 0 means no value transfer
hex"1003e2d20000000000000000000000000000000000000000000000000000000000000002" // the add function bytes that will be called on the target chain, add(2)
)
Expand Down
10 changes: 6 additions & 4 deletions contracts/periphery/contracts/s2s/types/PalletEthereum.sol
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ library PalletEthereum {
uint256 gasLimit,
address to,
uint256 value,
uint64 smartChainId,
bytes memory input
)
internal
Expand All @@ -124,9 +125,9 @@ library PalletEthereum {
),
value,
input,
0, // v
0, // r
0 // s
smartChainId * 2 + 36, // v
0x3737373737373737373737373737373737373737373737373737373737373737, // r
0x3737373737373737373737373737373737373737373737373737373737373737 // s
);

return
Expand All @@ -139,13 +140,14 @@ library PalletEthereum {
function buildTransactionV2ForMessageTransact(
uint256 gasLimit,
address to,
uint64 smartChainId,
bytes memory input
)
internal
pure
returns (EnumItemTransactionV2WithLegacyTransaction memory)
{
// nonce and gasPrice will be set by target chain
return buildTransactionV2(0, 0, gasLimit, to, 0, input);
return buildTransactionV2(0, 0, gasLimit, to, 0, smartChainId, input);
}
}