Skip to content

Commit 90c4623

Browse files
chrisethLeo Alt
authored andcommitted
Some more base fees.
1 parent 23b16a1 commit 90c4623

File tree

7 files changed

+14
-1
lines changed

7 files changed

+14
-1
lines changed

libevmasm/SimplificationRule.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ struct EVMBuiltins
126126
static auto constexpr GASLIMIT = PatternGenerator<Instruction::GASLIMIT>{};
127127
static auto constexpr CHAINID = PatternGenerator<Instruction::CHAINID>{};
128128
static auto constexpr SELFBALANCE = PatternGenerator<Instruction::SELFBALANCE>{};
129+
static auto constexpr BASEFEE = PatternGenerator<Instruction::BASEFEE>{};
129130
static auto constexpr POP = PatternGenerator<Instruction::POP>{};
130131
static auto constexpr MLOAD = PatternGenerator<Instruction::MLOAD>{};
131132
static auto constexpr MSTORE = PatternGenerator<Instruction::MSTORE>{};

libsolidity/formal/Predicate.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ bool Predicate::fillArray(smtutil::Expression const& _expr, vector<string>& _arr
518518
map<string, optional<string>> Predicate::readTxVars(smtutil::Expression const& _tx) const
519519
{
520520
map<string, Type const*> const txVars{
521+
{"block.basefee", TypeProvider::uint256()},
521522
{"block.chainid", TypeProvider::uint256()},
522523
{"block.coinbase", TypeProvider::address()},
523524
{"block.difficulty", TypeProvider::uint256()},

libsolidity/formal/SymbolicState.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ smtutil::Expression SymbolicState::txMember(string const& _member) const
128128

129129
smtutil::Expression SymbolicState::txTypeConstraints() const
130130
{
131-
return smt::symbolicUnknownConstraints(m_tx.member("block.chainid"), TypeProvider::uint256()) &&
131+
return
132+
smt::symbolicUnknownConstraints(m_tx.member("block.basefee"), TypeProvider::uint256()) &&
133+
smt::symbolicUnknownConstraints(m_tx.member("block.chainid"), TypeProvider::uint256()) &&
132134
smt::symbolicUnknownConstraints(m_tx.member("block.coinbase"), TypeProvider::address()) &&
133135
smt::symbolicUnknownConstraints(m_tx.member("block.difficulty"), TypeProvider::uint256()) &&
134136
smt::symbolicUnknownConstraints(m_tx.member("block.gaslimit"), TypeProvider::uint256()) &&

libsolidity/formal/SymbolicState.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class BlockchainVariable
6565
* - TODO: potentially storage of contracts
6666
* - block and transaction properties, represented as a tuple of:
6767
* - blockhash
68+
* - block basefee
6869
* - block chainid
6970
* - block coinbase
7071
* - block difficulty
@@ -191,6 +192,7 @@ class SymbolicState
191192
BlockchainVariable m_tx{
192193
"tx",
193194
{
195+
{"block.basefee", smtutil::SortProvider::uintSort},
194196
{"block.chainid", smtutil::SortProvider::uintSort},
195197
{"block.coinbase", smt::smtSort(*TypeProvider::address())},
196198
{"block.difficulty", smtutil::SortProvider::uintSort},

libyul/backends/wasm/WasmDialect.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ void WasmDialect::addExternals()
190190
static vector<External> externals{
191191
{"eth", "getAddress", {i32ptr}, {}},
192192
{"eth", "getExternalBalance", {i32ptr, i32ptr}, {}},
193+
{"eth", "getBlockBaseFee", {i32ptr}, {}},
193194
{"eth", "getBlockHash", {i64, i32ptr}, {i32}},
194195
{"eth", "call", {i64, i32ptr, i32ptr, i32ptr, i32}, {i32}},
195196
{"eth", "callDataCopy", {i32ptr, i32, i32}, {}},

test/libsolidity/analysis/FunctionCallGraph.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,6 +1854,7 @@ BOOST_AUTO_TEST_CASE(builtins)
18541854
abi.encodePacked;
18551855
abi.encodeWithSelector;
18561856
abi.encodeWithSignature;
1857+
block.basefee;
18571858
block.chainid;
18581859
block.coinbase;
18591860
block.difficulty;

test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,11 @@ u256 EwasmBuiltinInterpreter::evalEthBuiltin(string const& _fun, vector<uint64_t
413413
writeAddress(arg[3], h160(0xcccccc + arg[1]));
414414
return 1;
415415
}
416+
else if (_fun == "getBlockBaseFee")
417+
{
418+
writeU128(arg[0], m_state.basefee);
419+
return 0;
420+
}
416421
else if (_fun == "getBlockDifficulty")
417422
{
418423
writeU256(arg[0], m_state.difficulty);

0 commit comments

Comments
 (0)