Skip to content

Commit

Permalink
Merge pull request ethereum#94 from OffchainLabs/extend-node-interface
Browse files Browse the repository at this point in the history
`NodeInterfaceDebug.sol` address
  • Loading branch information
rachel-bousfield committed Apr 27, 2022
2 parents 9ff50a5 + 426875b commit 6ff0381
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
29 changes: 19 additions & 10 deletions arbitrum/apibackend.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,7 @@ func (a *APIBackend) FeeHistory(
}

nitroGenesis := core.NitroGenesisBlock
latestBlock := rpc.BlockNumber(a.CurrentBlock().NumberU64())
if newestBlock == rpc.LatestBlockNumber || newestBlock == rpc.PendingBlockNumber {
newestBlock = latestBlock
}
if newestBlock > latestBlock {
newestBlock = latestBlock
}
if newestBlock < nitroGenesis {
newestBlock = nitroGenesis
}
newestBlock, latestBlock := ClipToPostNitroGenesis(a, newestBlock)

maxFeeHistory := int(a.b.config.FeeHistoryMaxBlockCount)
if blocks > maxFeeHistory {
Expand Down Expand Up @@ -425,3 +416,21 @@ func (a *APIBackend) ChainConfig() *params.ChainConfig {
func (a *APIBackend) Engine() consensus.Engine {
return a.blockChain().Engine()
}

type GetsCurrentBlock interface {
CurrentBlock() *types.Block
}

func ClipToPostNitroGenesis(getter GetsCurrentBlock, blockNum rpc.BlockNumber) (rpc.BlockNumber, rpc.BlockNumber) {
currentBlock := rpc.BlockNumber(getter.CurrentBlock().NumberU64())
if blockNum == rpc.LatestBlockNumber || blockNum == rpc.PendingBlockNumber {
blockNum = currentBlock
}
if blockNum > currentBlock {
blockNum = currentBlock
}
if blockNum < core.NitroGenesisBlock {
blockNum = core.NitroGenesisBlock
}
return blockNum, currentBlock
}
2 changes: 2 additions & 0 deletions core/arbitrum_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var InterceptRPCMessage func(
msg types.Message,
ctx context.Context,
statedb *state.StateDB,
header *types.Header,
backend NodeInterfaceBackendAPI,
) (types.Message, *ExecutionResult, error)

Expand All @@ -53,4 +54,5 @@ type NodeInterfaceBackendAPI interface {
CurrentBlock() *types.Block
BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error)
GetLogs(ctx context.Context, blockHash common.Hash) ([][]*types.Log, error)
GetEVM(ctx context.Context, msg Message, state *state.StateDB, header *types.Header, vmConfig *vm.Config) (*vm.EVM, func() error, error)
}
1 change: 1 addition & 0 deletions core/types/arbitrum_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var ArbosAddress = common.HexToAddress("0xa4b05")
var ArbSysAddress = common.HexToAddress("0x64")
var ArbRetryableTxAddress = common.HexToAddress("0x6e")
var NodeInterfaceAddress = common.HexToAddress("0xc8")
var NodeInterfaceDebugAddress = common.HexToAddress("0xc9")

type arbitrumSigner struct{ Signer }

Expand Down
2 changes: 1 addition & 1 deletion internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ func DoCall(ctx context.Context, b Backend, args TransactionArgs, blockNrOrHash
// Arbitrum: support NodeInterface.sol by swapping out the message if needed
if core.InterceptRPCMessage != nil {
var res *core.ExecutionResult
msg, res, err = core.InterceptRPCMessage(msg, ctx, state, b)
msg, res, err = core.InterceptRPCMessage(msg, ctx, state, header, b)
if err != nil || res != nil {
return res, err
}
Expand Down

0 comments on commit 6ff0381

Please sign in to comment.