Skip to content

Commit

Permalink
Merge branch 'external-signer' of github.com:OffchainLabs/nitro into …
Browse files Browse the repository at this point in the history
…external-signer
  • Loading branch information
anodar committed Oct 16, 2023
2 parents 4661888 + 73eb315 commit 3816204
Show file tree
Hide file tree
Showing 25 changed files with 333 additions and 130 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ jobs:
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: Start background nitro-testnode
shell: bash
run: |
cd nitro-testnode
./test-node.bash --init --dev &
- name: Wait for rpc to come up
shell: bash
run: |
${{ github.workspace }}/.github/workflows/waitForNitro.sh
- name: Print WAVM module root
id: module-root
run: |
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/waitForNitro.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# poll the nitro endpoint until we get a 0 return code
while true
do
curl -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":45678,"method":"eth_chainId","params":[]}' 'http://localhost:8547'
if [ "$?" -eq "0" ]; then
exit 0
else
sleep 20
fi
done
4 changes: 1 addition & 3 deletions arbitrator/prover/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,7 @@ fn main() -> Result<()> {
while let Some((module, func, profile)) = func_stack.pop() {
sum.total_cycles += profile.total_cycles;
sum.count += profile.count;
let entry = func_profile
.entry((module, func))
.or_insert_with(SimpleProfile::default);
let entry = func_profile.entry((module, func)).or_default();
entry.count += sum.count;
entry.total_cycles += sum.total_cycles;
entry.local_cycles += profile.local_cycles;
Expand Down
2 changes: 1 addition & 1 deletion arbitrator/prover/test-cases/go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func main() {
verified, err = MerkleSample(data, -1)
if err != nil {
if verified {
panic("succeded to verify proof invalid")
panic("succeeded to verify proof invalid")
}
}

Expand Down
4 changes: 2 additions & 2 deletions arbnode/dataposter/data_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
// is initialized with specified sender/signer and keeps nonce of that address
// as it posts transactions.
// Transactions are also saved in the queue when it's being sent, and when
// persistant storage is used for the queue, after restarting the node
// persistent storage is used for the queue, after restarting the node
// dataposter will pick up where it left.
// DataPoster must be RLP serializable and deserializable
type DataPoster struct {
Expand Down Expand Up @@ -185,7 +185,7 @@ func externalSigner(ctx context.Context, opts *ExternalSignerCfg) (signerFn, com

var hasher types.Signer
return func(ctx context.Context, addr common.Address, tx *types.Transaction) (*types.Transaction, error) {
// According to the "eth_signTransaction" API definition, this shoul be
// According to the "eth_signTransaction" API definition, this should be
// RLP encoded transaction object.
// https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_signtransaction
var data hexutil.Bytes
Expand Down
9 changes: 9 additions & 0 deletions arbnode/inbox_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/rlp"

"github.com/offchainlabs/nitro/arbos/arbostypes"
"github.com/offchainlabs/nitro/arbstate"
"github.com/offchainlabs/nitro/arbutil"
Expand All @@ -24,6 +26,11 @@ import (
"github.com/offchainlabs/nitro/util/containers"
)

var (
inboxLatestBatchGauge = metrics.NewRegisteredGauge("arb/inbox/latest/batch", nil)
inboxLatestBatchMessageGauge = metrics.NewRegisteredGauge("arb/inbox/latest/batch/message", nil)
)

type InboxTracker struct {
db ethdb.Database
txStreamer *TransactionStreamer
Expand Down Expand Up @@ -676,6 +683,8 @@ func (t *InboxTracker) AddSequencerBatches(ctx context.Context, client arbutil.L
"l1Block", latestL1Block,
"l1Timestamp", time.Unix(int64(latestTimestamp), 0),
)
inboxLatestBatchGauge.Update(int64(pos))
inboxLatestBatchMessageGauge.Update(int64(newMessageCount))

if t.validator != nil {
t.validator.ReorgToBatchCount(startPos)
Expand Down
2 changes: 1 addition & 1 deletion arbos/addressSet/addressSet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func TestRectifyMapping(t *testing.T) {
// Non owner's should not be able to call RectifyMapping
err := aset.RectifyMapping(testhelpers.RandomAddress())
if err == nil {
Fail(t, "RectifyMapping was succesfully called by non owner")
Fail(t, "RectifyMapping was successfully called by non owner")
}

// Corrupt the list and verify if RectifyMapping fixes it
Expand Down
2 changes: 1 addition & 1 deletion arbos/l1pricing/l1pricing.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const (
InitialInertia = 10
InitialPerUnitReward = 10
InitialPerBatchGasCostV6 = 100_000
InitialPerBatchGasCostV12 = 210_000 // overriden as part of the upgrade
InitialPerBatchGasCostV12 = 210_000 // overridden as part of the upgrade
)

// one minute at 100000 bytes / sec
Expand Down
2 changes: 1 addition & 1 deletion arbos/tx_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ func (p *TxProcessor) EndTxHook(gasLeft uint64, success bool) {
err = util.TransferBalance(&refundFrom, &inner.RefundTo, toRefundAddr, p.evm, scenario, "refund")
if err != nil {
// Normally the network fee address should be holding any collected fees.
// However, in theory, they could've been transfered out during the redeem attempt.
// However, in theory, they could've been transferred out during the redeem attempt.
// If the network fee address doesn't have the necessary balance, log an error and don't give a refund.
log.Error(errLog, "err", err, "feeAddress", refundFrom)
}
Expand Down
4 changes: 2 additions & 2 deletions arbos/util/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/offchainlabs/nitro/util/arbmath"
)

// TransferBalance represents a balance change occuring aside from a call.
// TransferBalance represents a balance change occurring aside from a call.
// While most uses will be transfers, setting `from` or `to` to nil will mint or burn funds, respectively.
func TransferBalance(
from, to *common.Address,
Expand All @@ -39,7 +39,7 @@ func TransferBalance(
}
if tracer := evm.Config.Tracer; tracer != nil {
if evm.Depth() != 0 && scenario != TracingDuringEVM {
// A non-zero depth implies this transfer is occuring inside EVM execution
// A non-zero depth implies this transfer is occurring inside EVM execution
log.Error("Tracing scenario mismatch", "scenario", scenario, "depth", evm.Depth())
return errors.New("tracing scenario mismatch")
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/nitro/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"fmt"
"math/big"
"os"
"reflect"
"regexp"
"runtime"
"strings"
Expand Down Expand Up @@ -296,7 +297,7 @@ func findImportantRoots(ctx context.Context, chainDb ethdb.Database, stack *node
return nil, err
}
if initConfig.Prune == "validator" {
if l1Client == nil {
if l1Client == nil || reflect.ValueOf(l1Client).IsNil() {
return nil, errors.New("an L1 connection is required for validator pruning")
}
callOpts := bind.CallOpts{
Expand Down
5 changes: 4 additions & 1 deletion cmd/nitro/nitro.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ import (
)

func printSampleUsage(name string) {
fmt.Printf("Sample usage: %s --help \n", name)
fmt.Printf("Sample usage: %s [OPTIONS] \n\n", name)
fmt.Printf("Options:\n")
fmt.Printf(" --help\n")
fmt.Printf(" --dev: Start a default L2-only dev chain\n")
}

func addUnlockWallet(accountManager *accounts.Manager, walletConf *genericconf.WalletConfig) (common.Address, error) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/seq-coordinator-manager/seq-coordinator-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var addSeqForm = tview.NewForm()
var priorityForm = tview.NewForm()
var nonPriorityForm = tview.NewForm()

// Sequencer coordinator managment UI data store
// Sequencer coordinator management UI data store
type manager struct {
redisCoordinator *rediscoordinator.RedisCoordinator
prioritiesSet map[string]bool
Expand Down
22 changes: 22 additions & 0 deletions cmd/util/confighelpers/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,32 @@ func PrintErrorAndExit(err error, usage func(string)) {
}
}

func devFlagArgs() []string {
args := []string{
"--init.dev-init",
"--init.dev-init-address", "0x3f1Eae7D46d88F08fc2F8ed27FCb2AB183EB2d0E",
"--node.dangerous.no-l1-listener",
"--node.parent-chain-reader.enable=false",
"--parent-chain.id=1337",
"--chain.id=412346",
"--persistent.chain", "/tmp/dev-test",
"--node.sequencer",
"--node.dangerous.no-sequencer-coordinator",
"--node.staker.enable=false",
"--init.empty=false",
"--http.port", "8547",
"--http.addr", "127.0.0.1",
}
return args
}

func BeginCommonParse(f *flag.FlagSet, args []string) (*koanf.Koanf, error) {
for _, arg := range args {
if arg == "--version" || arg == "-v" {
return nil, ErrVersion
} else if arg == "--dev" {
args = devFlagArgs()
break
}
}
if err := f.Parse(args); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions das/das.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ func dataAvailabilityConfigAddOptions(prefix string, f *flag.FlagSet, r role) {
IpfsStorageServiceConfigAddOptions(prefix+".ipfs-storage", f)
RestfulClientAggregatorConfigAddOptions(prefix+".rest-aggregator", f)

f.String(prefix+".parent-chain-node-url", DefaultDataAvailabilityConfig.ParentChainNodeURL, "URL for L1 node, only used in standalone daserver; when running as part of a node that node's L1 configuration is used")
f.Int(prefix+".parent-chain-connection-attempts", DefaultDataAvailabilityConfig.ParentChainConnectionAttempts, "layer 1 RPC connection attempts (spaced out at least 1 second per attempt, 0 to retry infinitely), only used in standalone daserver; when running as part of a node that node's L1 configuration is used")
f.String(prefix+".sequencer-inbox-address", DefaultDataAvailabilityConfig.SequencerInboxAddress, "L1 address of SequencerInbox contract")
f.String(prefix+".parent-chain-node-url", DefaultDataAvailabilityConfig.ParentChainNodeURL, "URL for parent chain node, only used in standalone daserver; when running as part of a node that node's L1 configuration is used")
f.Int(prefix+".parent-chain-connection-attempts", DefaultDataAvailabilityConfig.ParentChainConnectionAttempts, "parent chain RPC connection attempts (spaced out at least 1 second per attempt, 0 to retry infinitely), only used in standalone daserver; when running as part of a node that node's parent chain configuration is used")
f.String(prefix+".sequencer-inbox-address", DefaultDataAvailabilityConfig.SequencerInboxAddress, "parent chain address of SequencerInbox contract")
}

func Serialize(c *arbstate.DataAvailabilityCertificate) []byte {
Expand Down
7 changes: 6 additions & 1 deletion execution/gethexec/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"reflect"
"sync/atomic"
"testing"

Expand Down Expand Up @@ -73,6 +74,7 @@ func (c *Config) Validate() error {
func ConfigAddOptions(prefix string, f *flag.FlagSet) {
arbitrum.ConfigAddOptions(prefix+".rpc", f)
SequencerConfigAddOptions(prefix+".sequencer", f)
headerreader.AddOptions(prefix+".parent-chain-reader", f)
arbitrum.RecordingDatabaseConfigAddOptions(prefix+".recording-database", f)
f.String(prefix+".forwarding-target", ConfigDefault.ForwardingTarget, "transaction forwarding target URL, or \"null\" to disable forwarding (iff not sequencer)")
AddOptionsForNodeForwarderConfig(prefix+".forwarder", f)
Expand All @@ -85,6 +87,7 @@ func ConfigAddOptions(prefix string, f *flag.FlagSet) {
var ConfigDefault = Config{
RPC: arbitrum.DefaultConfig,
Sequencer: DefaultSequencerConfig,
ParentChainReader: headerreader.DefaultConfig,
RecordingDatabase: arbitrum.DefaultRecordingDatabaseConfig,
ForwardingTarget: "",
TxPreChecker: DefaultTxPreCheckerConfig,
Expand All @@ -96,6 +99,7 @@ var ConfigDefault = Config{

func ConfigDefaultNonSequencerTest() *Config {
config := ConfigDefault
config.ParentChainReader = headerreader.Config{}
config.Sequencer.Enable = false
config.Forwarder = DefaultTestForwarderConfig
config.ForwardingTarget = "null"
Expand All @@ -107,6 +111,7 @@ func ConfigDefaultNonSequencerTest() *Config {

func ConfigDefaultTest() *Config {
config := ConfigDefault
config.ParentChainReader = headerreader.Config{}
config.Sequencer = TestSequencerConfig
config.ForwardingTarget = "null"

Expand Down Expand Up @@ -149,7 +154,7 @@ func CreateExecutionNode(
var sequencer *Sequencer

var parentChainReader *headerreader.HeaderReader
if l1client != nil {
if l1client != nil && !reflect.ValueOf(l1client).IsNil() {
arbSys, _ := precompilesgen.NewArbSys(types.ArbSysAddress, l1client)
parentChainReader, err = headerreader.New(ctx, l1client, func() *headerreader.Config { return &configFetcher().ParentChainReader }, arbSys)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion nitro-testnode
2 changes: 1 addition & 1 deletion precompiles/precompile.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ func MakePrecompile(metadata *bind.MetaData, implementer interface{}) (addr, *Pr
emitCost := gascost(args)
cost := emitCost[0].Interface().(uint64) //nolint:errcheck
if !emitCost[1].IsNil() {
// an error occured during gascost()
// an error occurred during gascost()
return []reflect.Value{emitCost[1]}
}
if err := callerCtx.Burn(cost); err != nil {
Expand Down
Loading

0 comments on commit 3816204

Please sign in to comment.