Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
ChainID is passed to EVMC as a part of tx context
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 committed Jul 31, 2019
1 parent 7351dbc commit 4c4be07
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion libaleth-interpreter/VM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ void VM::interpretCases()

updateIOGas();

m_SPP[0] = fromEvmC(m_context->host->get_chain_id(m_context));
m_SPP[0] = fromEvmC(getTxContext().chain_id);
}
NEXT

Expand Down
18 changes: 8 additions & 10 deletions libevm/ExtVMFace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,14 @@ evmc_tx_context EvmCHost::get_tx_context() noexcept
evmc_tx_context result = {};
result.tx_gas_price = toEvmC(m_extVM.gasPrice);
result.tx_origin = toEvmC(m_extVM.origin);
result.block_coinbase = toEvmC(m_extVM.envInfo().author());
result.block_number = m_extVM.envInfo().number();
result.block_timestamp = m_extVM.envInfo().timestamp();
result.block_gas_limit = static_cast<int64_t>(m_extVM.envInfo().gasLimit());
result.block_difficulty = toEvmC(m_extVM.envInfo().difficulty());

auto const& envInfo = m_extVM.envInfo();
result.block_coinbase = toEvmC(envInfo.author());
result.block_number = envInfo.number();
result.block_timestamp = envInfo.timestamp();
result.block_gas_limit = static_cast<int64_t>(envInfo.gasLimit());
result.block_difficulty = toEvmC(envInfo.difficulty());
result.chain_id = toEvmC(envInfo.chainID());
return result;
}

Expand All @@ -155,11 +158,6 @@ evmc_bytes32 EvmCHost::get_block_hash(int64_t _number) noexcept
return toEvmC(m_extVM.blockHash(_number));
}

evmc_bytes32 EvmCHost::get_chain_id() noexcept
{
return toEvmC(m_extVM.envInfo().chainID());
}

evmc::result EvmCHost::create(evmc_message const& _msg) noexcept
{
u256 gas = _msg.gas;
Expand Down
2 changes: 0 additions & 2 deletions libevm/ExtVMFace.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,6 @@ class EvmCHost : public evmc::Host

evmc_bytes32 get_block_hash(int64_t _blockNumber) noexcept override;

evmc_bytes32 get_chain_id() noexcept override;

void emit_log(const evmc_address& _addr, const uint8_t* _data, size_t _dataSize,
const evmc_bytes32 _topics[], size_t _numTopics) noexcept override;

Expand Down

0 comments on commit 4c4be07

Please sign in to comment.