-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add batch precompile * typo * add tests * minor fixes and updates * refactor, add batch to local * fix expect_arguments * add logs * update license * taplo fix * more refactor, remote evm crate * remove evm crate, update utils version, add std in dappsstaking * update pallet_balances::config in mock * update pallet_evm config * update license * add to std-feature * utils: rectify patch to minor update * remove pub from logs function * fix typos * remove comments * refactor * fmt
- Loading branch information
1 parent
855053a
commit f577d2c
Showing
21 changed files
with
2,578 additions
and
461 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
pragma solidity >=0.8.3; | ||
|
||
/// Interface to the precompiled contract on Shibuya/Shiden/Astar | ||
/// Predeployed at the address 0x0000000000000000000000000000000000005006 | ||
/// For better understanding check the source code: | ||
/// repo: https://github.com/AstarNetwork/astar | ||
|
||
/// @title Batch precompile | ||
/// @dev Allows to perform multiple calls through one call to the precompile. | ||
/// Can be used by EOA to do multiple calls in a single transaction. | ||
interface Batch { | ||
/// @dev Batch multiple calls into a single transaction. | ||
/// All calls are performed from the address calling this precompile. | ||
/// | ||
/// In case of one subcall reverting following subcalls will still be attempted. | ||
/// | ||
/// @param to List of addresses to call. | ||
/// @param value List of values for each subcall. If array is shorter than `to` then additional | ||
/// calls will be performed with a value of 0. | ||
/// @param callData Call data for each `to` address. If array is shorter than `to` then | ||
/// additional calls will be performed with an empty call data. | ||
/// @param gasLimit Gas limit for each `to` address. Use 0 to forward all the remaining gas. | ||
/// If array is shorter than `to` then the remaining gas available will be used. | ||
function batchSome( | ||
address[] memory to, | ||
uint256[] memory value, | ||
bytes[] memory callData, | ||
uint64[] memory gasLimit | ||
) external; | ||
|
||
/// @dev Batch multiple calls into a single transaction. | ||
/// All calls are performed from the address calling this precompile. | ||
/// | ||
/// In case of one subcall reverting, no more subcalls will be executed but | ||
/// the batch transaction will succeed. Use "batchAll" to revert on any subcall revert. | ||
/// | ||
/// @param to List of addresses to call. | ||
/// @param value List of values for each subcall. If array is shorter than `to` then additional | ||
/// calls will be performed with a value of 0. | ||
/// @param callData Call data for each `to` address. If array is shorter than `to` then | ||
/// additional calls will be performed with an empty call data. | ||
/// @param gasLimit Gas limit for each `to` address. Use 0 to forward all the remaining gas. | ||
/// If array is shorter than `to` then the remaining gas available will be used. | ||
function batchSomeUntilFailure( | ||
address[] memory to, | ||
uint256[] memory value, | ||
bytes[] memory callData, | ||
uint64[] memory gasLimit | ||
) external; | ||
|
||
/// @dev Batch multiple calls into a single transaction. | ||
/// All calls are performed from the address calling this precompile. | ||
/// | ||
/// In case of one subcall reverting, the entire batch will revert. | ||
/// | ||
/// @param to List of addresses to call. | ||
/// @param value List of values for each subcall. If array is shorter than `to` then additional | ||
/// calls will be performed with a value of 0. | ||
/// @param callData Call data for each `to` address. If array is shorter than `to` then | ||
/// additional calls will be performed with an empty call data. | ||
/// @param gasLimit Gas limit for each `to` address. Use 0 to forward all the remaining gas. | ||
/// If array is shorter than `to` then the remaining gas available will be used. | ||
function batchAll( | ||
address[] memory to, | ||
uint256[] memory value, | ||
bytes[] memory callData, | ||
uint64[] memory gasLimit | ||
) external; | ||
|
||
/// Emitted when a subcall succeeds. | ||
event SubcallSucceeded(uint256 index); | ||
|
||
/// Emitted when a subcall fails. | ||
event SubcallFailed(uint256 index); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
[package] | ||
name = "pallet-evm-precompile-batch" | ||
description = "A Precompile to batch multiple calls." | ||
version = "0.1.0" | ||
authors = ["StakeTechnologies", "PureStake"] | ||
edition.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true | ||
|
||
[dependencies] | ||
log = { workspace = true } | ||
num_enum = { workspace = true } | ||
paste = { workspace = true } | ||
slices = { workspace = true } | ||
|
||
# Moonbeam | ||
precompile-utils = { workspace = true } | ||
|
||
# Substrate | ||
frame-support = { workspace = true } | ||
frame-system = { workspace = true } | ||
parity-scale-codec = { workspace = true, features = ["max-encoded-len"] } | ||
sp-core = { workspace = true } | ||
sp-io = { workspace = true } | ||
sp-std = { workspace = true } | ||
|
||
# Frontier | ||
evm = { workspace = true, features = ["with-codec"] } | ||
fp-evm = { workspace = true } | ||
pallet-evm = { workspace = true } | ||
|
||
[dev-dependencies] | ||
derive_more = { workspace = true } | ||
hex-literal = { workspace = true } | ||
serde = { workspace = true } | ||
sha3 = { workspace = true } | ||
|
||
pallet-balances = { workspace = true, features = ["std"] } | ||
pallet-timestamp = { workspace = true, features = ["std"] } | ||
parity-scale-codec = { workspace = true, features = ["max-encoded-len", "std"] } | ||
precompile-utils = { workspace = true, features = ["std", "testing"] } | ||
scale-info = { workspace = true, features = ["derive", "std"] } | ||
sp-runtime = { workspace = true, features = ["std"] } | ||
|
||
[features] | ||
default = ["std"] | ||
std = [ | ||
"fp-evm/std", | ||
"frame-support/std", | ||
"frame-system/std", | ||
"pallet-evm/std", | ||
"parity-scale-codec/std", | ||
"precompile-utils/std", | ||
"sp-core/std", | ||
"sp-io/std", | ||
"sp-std/std", | ||
] |
Oops, something went wrong.