Skip to content

Commit

Permalink
arbos: add BalanceChangeReason and fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
sduchesneau committed Aug 3, 2023
1 parent f349859 commit a578ba9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions arbos/arbosState/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func InitializeArbosInDatabase(db ethdb.Database, initData statetransfer.InitDat
if err != nil {
return common.Hash{}, err
}
statedb.SetBalance(account.Addr, account.EthBalance)
statedb.SetBalance(account.Addr, account.EthBalance, state.BalanceChangeGenesisBalance)
statedb.SetNonce(account.Addr, account.Nonce)
if account.ContractInfo != nil {
statedb.SetCode(account.Addr, account.ContractInfo.Code)
Expand Down Expand Up @@ -173,7 +173,7 @@ func initializeRetryables(statedb *state.StateDB, rs *retryables.RetryableState,
return err
}
if r.Timeout <= currentTimestamp {
statedb.AddBalance(r.Beneficiary, r.Callvalue)
statedb.AddBalance(r.Beneficiary, r.Callvalue, state.BalanceChangeGenesisBalance)
continue
}
retryablesList = append(retryablesList, r)
Expand All @@ -191,7 +191,7 @@ func initializeRetryables(statedb *state.StateDB, rs *retryables.RetryableState,
if r.To != (common.Address{}) {
to = &r.To
}
statedb.AddBalance(retryables.RetryableEscrowAddress(r.Id), r.Callvalue)
statedb.AddBalance(retryables.RetryableEscrowAddress(r.Id), r.Callvalue, state.BalanceChangeGenesisBalance)
_, err := rs.CreateRetryable(r.Id, r.Timeout, r.From, to, r.Callvalue, r.Beneficiary, r.Calldata)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion arbos/tx_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (p *TxProcessor) StartTxHook() (endTxNow bool, gasUsed uint64, err error, r
evm.IncrementDepth() // fake a call
tracer := evm.Config.Tracer
from := p.msg.From
tracer.CaptureStart(evm, from, *p.msg.To, false, p.msg.Data, p.msg.GasLimit, p.msg.Value)
tracer.CaptureStart(from, *p.msg.To, false, p.msg.Data, p.msg.GasLimit, p.msg.Value)

tracingInfo = util.NewTracingInfo(evm, from, *p.msg.To, util.TracingDuringEVM)
p.state = arbosState.OpenSystemArbosStateOrPanic(evm.StateDB, tracingInfo, false)
Expand Down
5 changes: 3 additions & 2 deletions arbos/util/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/log"
"github.com/offchainlabs/nitro/util/arbmath"
Expand All @@ -32,10 +33,10 @@ func TransferBalance(
if arbmath.BigLessThan(balance, amount) {
return fmt.Errorf("%w: addr %v have %v want %v", vm.ErrInsufficientBalance, *from, balance, amount)
}
evm.StateDB.SubBalance(*from, amount)
evm.StateDB.SubBalance(*from, amount, state.BalanceChangeTransfer)
}
if to != nil {
evm.StateDB.AddBalance(*to, amount)
evm.StateDB.AddBalance(*to, amount, state.BalanceChangeTransfer)
}
if evm.Config.Debug {
tracer := evm.Config.Tracer
Expand Down

0 comments on commit a578ba9

Please sign in to comment.