Skip to content

Conversation

@f-gate
Copy link

@f-gate f-gate commented Feb 5, 2025

Notable changes to pallet-revive:

New runtime-apis:

Balance

/// Returns the free balance of the given `[H160]` address.
fn balance(address: H160) -> Balance;

The comment doesnt specify wether it wants the balance in ETH decimals or Native.. After a search at the only other implementation of this i could find: here i gather it is the balance as EVM units as it calls:

/// Get the balance with EVM decimals of the given `address`.
pub fn evm_balance(address: &H160) -> U256 {
	let account = T::AddressMapper::to_account_id(&address);
	Self::convert_native_to_evm(T::Currency::reducible_balance(&account, Preserve, Polite))
}

Since this evm_balance does not exist in revive 0.4.0 i have implemented my own convert_native_to_evm directly in the api..

Nonce

/// Returns the nonce of the given `[H160]` address.
fn nonce(address: H160) -> Nonce;

Essentially convert the H160 address to the runtime's address and read the nonce.

Eth transact

////// Perform an Ethereum call.
///
/// See [`crate::Pallet::bare_eth_transact`]
fn eth_transact(
    origin: H160, 
    dest: Option<H160>,
    value: Balance,
    input: Vec<u8>,
    gas_limit: Option<Weight>,
    storage_deposit_limit: Option<Balance>,
) -> pallet_revive::EthContractResult<Balance>;

Again the only other reference i had for this was here .Since many of the api paramters match the call to Revive::bare_eth_transact i only had to convert the H160 address to the standard runtime AccountId and give a closure for the utx encoded size.

Config items

AddressGenerator has been removed
MaxCodeLen has been removed
Migrations has been removed

AddressMapper has been added. AccountId32Mapper is "The mapper to be used if the account id is AccountId32." Simple enough.

 type AddressMapper = pallet_revive::AccountId32Mapper<Runtime>;

ChainId is used as a unique identifier assigned to each blockchain, used for preventing replay attacks. I have set is as 1 for the meantime.

type ChainId = ChainId;

Finally NativeToEthRatio has been added ref
which i have defined as the ETH_UNIT / UNIT. It is used to convert from a Native balance Unit to an Eth balance Unit.

type NativeToEthRatio = ConstU32<{(ETH_UNIT / UNIT) as u32}>;

[sc-1937]

chungquantin and others added 5 commits December 31, 2024 11:32
* 2412 upgrade

* fmt

* clippy

* TransactionExtension and node refactor

* fmt

* sp_keyring

* stray-key-gen

* todo and runtime-benchmark warning

---------

Co-authored-by: f-gate <[email protected]>
Copy link
Collaborator

@AlexD10S AlexD10S left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing pallet_revive doesn’t seem logical to me. We introduced it in the last release, and while pop-cli doesn’t support it yet, that’s a short-term goal.

I noticed some new versions on crates.io: https://crates.io/crates/pallet-revive/versions maybe the last one fixes the issue?

@f-gate f-gate force-pushed the chore-upgrade-2412 branch from c00e22d to 026323c Compare February 19, 2025 12:41
@f-gate f-gate requested a review from AlexD10S February 19, 2025 13:29
@AlexD10S AlexD10S mentioned this pull request Jun 18, 2025
16 tasks
@AlexD10S
Copy link
Collaborator

Closing this as is outdated, this was already upgraded

@AlexD10S AlexD10S closed this Oct 17, 2025
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

Successfully merging this pull request may close these issues.

5 participants