File tree Expand file tree Collapse file tree 2 files changed +58
-0
lines changed
src/ethereum/osaka/vm/instructions Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -252,6 +252,7 @@ class Ops(enum.Enum):
252
252
EXTDELEGATECALL = 0xF9
253
253
STATICCALL = 0xFA
254
254
EXTSTATICCALL = 0xFB
255
+ PAY = 0xFC
255
256
REVERT = 0xFD
256
257
INVALID = 0xFE
257
258
SELFDESTRUCT = 0xFF
@@ -427,6 +428,7 @@ class Ops(enum.Enum):
427
428
Ops .EXTCALL : system_instructions .ext_call ,
428
429
Ops .EXTDELEGATECALL : system_instructions .ext_delegatecall ,
429
430
Ops .EXTSTATICCALL : system_instructions .ext_staticcall ,
431
+ Ops .PAY : system_instructions .pay ,
430
432
}
431
433
432
434
@@ -659,6 +661,7 @@ class Ops(enum.Enum):
659
661
Ops .EXTCALL : OpcodeStackItemCount (inputs = 4 , outputs = 1 ),
660
662
Ops .EXTDELEGATECALL : OpcodeStackItemCount (inputs = 3 , outputs = 1 ),
661
663
Ops .EXTSTATICCALL : OpcodeStackItemCount (inputs = 3 , outputs = 1 ),
664
+ Ops .PAY : OpcodeStackItemCount (inputs = 2 , outputs = 1 ),
662
665
}
663
666
664
667
Original file line number Diff line number Diff line change @@ -1379,3 +1379,58 @@ def return_contract(evm: Evm) -> None:
1379
1379
1380
1380
# PROGRAM COUNTER
1381
1381
evm .running = False
1382
+
1383
+
1384
+ def pay (evm : Evm ) -> None :
1385
+ """
1386
+ Transfer ether to an account.
1387
+
1388
+ Parameters
1389
+ ----------
1390
+ evm :
1391
+ The current EVM frame.
1392
+ """
1393
+ # STACK
1394
+ try :
1395
+ to = to_address_without_mask (pop (evm .stack ))
1396
+ except ValueError as e :
1397
+ raise ExceptionalHalt from e
1398
+ value = pop (evm .stack )
1399
+
1400
+ # GAS
1401
+ if to in evm .accessed_addresses :
1402
+ access_gas_cost = GAS_WARM_ACCESS
1403
+ else :
1404
+ evm .accessed_addresses .add (to )
1405
+ access_gas_cost = GAS_COLD_ACCOUNT_ACCESS
1406
+
1407
+ create_gas_cost = (
1408
+ Uint (0 )
1409
+ if is_account_alive (evm .message .block_env .state , to ) or value == 0
1410
+ else GAS_NEW_ACCOUNT
1411
+ )
1412
+
1413
+ transfer_gas_cost = Uint (0 ) if value == U256 (0 ) else GAS_CALL_VALUE
1414
+
1415
+ charge_gas (evm , access_gas_cost + create_gas_cost + transfer_gas_cost )
1416
+
1417
+ # OPERATION
1418
+ if value > U256 (0 ):
1419
+ try :
1420
+ move_ether (
1421
+ evm .message .block_env .state ,
1422
+ evm .message .current_target ,
1423
+ to ,
1424
+ value ,
1425
+ )
1426
+ push (evm .stack , U256 (1 ))
1427
+ except AssertionError :
1428
+ # TODO: This behavior has not been
1429
+ # finalized yet and is simply based on
1430
+ # ongoing discussions. The final update
1431
+ # needs to be made to this based on the
1432
+ # agreed upon spec.
1433
+ push (evm .stack , U256 (0 ))
1434
+
1435
+ # PROGRAM COUNTER
1436
+ evm .pc += Uint (1 )
You can’t perform that action at this time.
0 commit comments