@@ -29,9 +29,9 @@ export interface RunResult {
2929 logs : Log [ ]
3030 returnValue ?: Uint8Array
3131 /**
32- * A map from the accounts that have self-destructed to the addresses to send their funds to
32+ * A set of accounts to selfdestruct
3333 */
34- selfdestruct : { [ k : string ] : Uint8Array }
34+ selfdestruct : Set < string >
3535
3636 /**
3737 * A map which tracks which addresses were created (used in EIP 6780)
@@ -160,7 +160,7 @@ export class Interpreter {
160160 this . _result = {
161161 logs : [ ] ,
162162 returnValue : undefined ,
163- selfdestruct : { } ,
163+ selfdestruct : new Set ( ) ,
164164 }
165165 }
166166
@@ -840,7 +840,7 @@ export class Interpreter {
840840 }
841841
842842 async _baseCall ( msg : Message ) : Promise < bigint > {
843- const selfdestruct = { ... this . _result . selfdestruct }
843+ const selfdestruct = new Set ( this . _result . selfdestruct )
844844 msg . selfdestruct = selfdestruct
845845 msg . gasRefund = this . _runState . gasRefund
846846
@@ -882,7 +882,9 @@ export class Interpreter {
882882 }
883883
884884 if ( ! results . execResult . exceptionError ) {
885- Object . assign ( this . _result . selfdestruct , selfdestruct )
885+ for ( const addressToSelfdestructHex of selfdestruct ) {
886+ this . _result . selfdestruct . add ( addressToSelfdestructHex )
887+ }
886888 if ( this . _common . isActivatedEIP ( 6780 ) ) {
887889 // copy over the items to result via iterator
888890 for ( const item of createdAddresses ! ) {
@@ -910,7 +912,7 @@ export class Interpreter {
910912 data : Uint8Array ,
911913 salt ?: Uint8Array
912914 ) : Promise < bigint > {
913- const selfdestruct = { ... this . _result . selfdestruct }
915+ const selfdestruct = new Set ( this . _result . selfdestruct )
914916 const caller = this . _env . address
915917 const depth = this . _env . depth + 1
916918
@@ -954,6 +956,12 @@ export class Interpreter {
954956 versionedHashes : this . _env . versionedHashes ,
955957 } )
956958
959+ let createdAddresses : Set < string >
960+ if ( this . _common . isActivatedEIP ( 6780 ) ) {
961+ createdAddresses = new Set ( this . _result . createdAddresses )
962+ message . createdAddresses = createdAddresses
963+ }
964+
957965 const results = await this . _evm . runCall ( { message } )
958966
959967 if ( results . execResult . logs ) {
@@ -975,7 +983,15 @@ export class Interpreter {
975983 ! results . execResult . exceptionError ||
976984 results . execResult . exceptionError . error === ERROR . CODESTORE_OUT_OF_GAS
977985 ) {
978- Object . assign ( this . _result . selfdestruct , selfdestruct )
986+ for ( const addressToSelfdestructHex of selfdestruct ) {
987+ this . _result . selfdestruct . add ( addressToSelfdestructHex )
988+ }
989+ if ( this . _common . isActivatedEIP ( 6780 ) ) {
990+ // copy over the items to result via iterator
991+ for ( const item of createdAddresses ! ) {
992+ this . _result . createdAddresses ! . add ( item )
993+ }
994+ }
979995 // update stateRoot on current contract
980996 const account = await this . _stateManager . getAccount ( this . _env . address )
981997 if ( ! account ) {
@@ -1017,11 +1033,11 @@ export class Interpreter {
10171033
10181034 async _selfDestruct ( toAddress : Address ) : Promise < void > {
10191035 // only add to refund if this is the first selfdestruct for the address
1020- if ( this . _result . selfdestruct [ bytesToHex ( this . _env . address . bytes ) ] === undefined ) {
1036+ if ( ! this . _result . selfdestruct . has ( bytesToHex ( this . _env . address . bytes ) ) ) {
10211037 this . refundGas ( this . _common . param ( 'gasPrices' , 'selfdestructRefund' ) )
10221038 }
10231039
1024- this . _result . selfdestruct [ bytesToHex ( this . _env . address . bytes ) ] = toAddress . bytes
1040+ this . _result . selfdestruct . add ( bytesToHex ( this . _env . address . bytes ) )
10251041
10261042 // Add to beneficiary balance
10271043 let toAccount = await this . _stateManager . getAccount ( toAddress )
0 commit comments