From 65c5cc8d323462d67b66faaf7bfc8345fb1d61f7 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 24 Oct 2023 15:46:23 -0400 Subject: [PATCH] small --- bold | 2 +- cmd/bold-deploy/main.go | 1 + cmd/chaininfo/chain_info.go | 1 + cmd/nitro/nitro.go | 25 +----------- nitro-testnode | 2 +- staker/state_provider.go | 4 +- staker/stateless_block_validator.go | 3 -- tools/bold-challenges/main.go | 60 +++++++++++++++++++++++++++++ 8 files changed, 67 insertions(+), 31 deletions(-) create mode 100644 tools/bold-challenges/main.go diff --git a/bold b/bold index 53b5e7eacf..d94d4c9486 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 53b5e7eacf2149ab4d878913cac49293df4b7b3b +Subproject commit d94d4c9486072b87db86360723fae510e9ff6cfa diff --git a/cmd/bold-deploy/main.go b/cmd/bold-deploy/main.go index c1c608526e..e152aef979 100644 --- a/cmd/bold-deploy/main.go +++ b/cmd/bold-deploy/main.go @@ -329,6 +329,7 @@ func main() { Rollup: deployedAddresses.Rollup, ValidatorUtils: deployedAddresses.ValidatorUtils, ValidatorWalletCreator: deployedAddresses.ValidatorWalletCreator, + StakeToken: stakeToken, DeployedAt: deployedAddresses.DeployedAt, }, }, diff --git a/cmd/chaininfo/chain_info.go b/cmd/chaininfo/chain_info.go index f75779b4aa..a9ed783ac7 100644 --- a/cmd/chaininfo/chain_info.go +++ b/cmd/chaininfo/chain_info.go @@ -108,5 +108,6 @@ type RollupAddresses struct { Rollup common.Address `json:"rollup"` ValidatorUtils common.Address `json:"validator-utils"` ValidatorWalletCreator common.Address `json:"validator-wallet-creator"` + StakeToken common.Address `json:"stake-token"` DeployedAt uint64 `json:"deployed-at"` } diff --git a/cmd/nitro/nitro.go b/cmd/nitro/nitro.go index 38717e6c44..23d09030ff 100644 --- a/cmd/nitro/nitro.go +++ b/cmd/nitro/nitro.go @@ -229,7 +229,7 @@ func mainImpl() int { var l1TransactionOptsValidator *bind.TransactOpts var l1TransactionOptsBatchPoster *bind.TransactOpts sequencerNeedsKey := (nodeConfig.Node.Sequencer && !nodeConfig.Node.Feed.Output.DisableSigning) || nodeConfig.Node.BatchPoster.Enable - validatorNeedsKey := nodeConfig.Node.Staker.OnlyCreateWalletContract || nodeConfig.Node.Staker.Enable && !strings.EqualFold(nodeConfig.Node.Staker.Strategy, "watchtower") + validatorNeedsKey := nodeConfig.Node.Staker.OnlyCreateWalletContract || nodeConfig.Node.Bold.Enable || nodeConfig.Node.Staker.Enable && !strings.EqualFold(nodeConfig.Node.Staker.Strategy, "watchtower") l1Wallet.ResolveDirectoryNames(nodeConfig.Persistent.Chain) defaultL1WalletConfig := conf.DefaultL1WalletConfig @@ -282,29 +282,6 @@ func mainImpl() int { } } - if nodeConfig.Node.Bold.Enable { - if nodeConfig.Node.Bold.Evil { - validatorPrivateKey, err := crypto.HexToECDSA("dc04c5399f82306ec4b4d654a342f40e2e0620fe39950d967e1e574b32d4dd36") - if err != nil { - log.Crit("Failed to get privkey for validator", "err", err) - } - validatorTxOpts, err := bind.NewKeyedTransactorWithChainID(validatorPrivateKey, new(big.Int).SetUint64(nodeConfig.ParentChain.ID)) - if err != nil { - log.Crit("Failed to get validator tx opts", "err", err) - } - l1TransactionOptsValidator = validatorTxOpts - } else { - validatorPrivateKey, err := crypto.HexToECDSA("182fecf15bdf909556a0f617a63e05ab22f1493d25a9f1e27c228266c772a890") - if err != nil { - log.Crit("Failed to get privkey for validator", "err", err) - } - validatorTxOpts, err := bind.NewKeyedTransactorWithChainID(validatorPrivateKey, new(big.Int).SetUint64(nodeConfig.ParentChain.ID)) - if err != nil { - log.Crit("Failed to get validator tx opts", "err", err) - } - l1TransactionOptsValidator = validatorTxOpts - } - } combinedL2ChainInfoFile := nodeConfig.Chain.InfoFiles if nodeConfig.Chain.InfoIpfsUrl != "" { l2ChainInfoIpfsFile, err := util.GetL2ChainInfoIpfsFile(ctx, nodeConfig.Chain.InfoIpfsUrl, nodeConfig.Chain.InfoIpfsDownloadPath) diff --git a/nitro-testnode b/nitro-testnode index 6dc8caccff..9eec5fd632 160000 --- a/nitro-testnode +++ b/nitro-testnode @@ -1 +1 @@ -Subproject commit 6dc8caccffc8c51e58be3b960647766d8d36fc3e +Subproject commit 9eec5fd632c9b9319ed1f77a4a4ecb0cbdbb6d41 diff --git a/staker/state_provider.go b/staker/state_provider.go index d9d2cad68b..def701486c 100644 --- a/staker/state_provider.go +++ b/staker/state_provider.go @@ -304,9 +304,9 @@ func (s *StateManager) CollectMachineHashes( ) ([]common.Hash, error) { s.Lock() defer s.Unlock() - prevBatchMsgCount, err := s.validator.inboxTracker.GetBatchMessageCount(uint64(cfg.FromBatch) - 1) + prevBatchMsgCount, err := s.validator.inboxTracker.GetBatchMessageCount(uint64(cfg.FromBatch - 1)) if err != nil { - return nil, err + return nil, fmt.Errorf("could not get batch message count at %d: %w", cfg.FromBatch, err) } messageNum := (prevBatchMsgCount + arbutil.MessageIndex(cfg.BlockChallengeHeight)) cacheKey := &challengecache.Key{ diff --git a/staker/stateless_block_validator.go b/staker/stateless_block_validator.go index af6b3cb1d9..26a89c24c4 100644 --- a/staker/stateless_block_validator.go +++ b/staker/stateless_block_validator.go @@ -284,7 +284,6 @@ func (v *StatelessBlockValidator) ValidationEntryRecord(ctx context.Context, e * } if e.HasDelayedMsg { if v.config.Evil { - fmt.Println("Got evil block validator") chainId, ok := new(big.Int).SetString(v.config.ChainId, 10) if !ok { return errors.New("bad chainid") @@ -297,7 +296,6 @@ func (v *StatelessBlockValidator) ValidationEntryRecord(ctx context.Context, e * ) return fmt.Errorf("error while trying to read delayed msg for proving: %w", err) } - fmt.Printf("Encoded delayed L2: %#x\n", delayedMsg.L2msg) txes, err := arbos.ParseL2Transactions(delayedMsg, chainId, nil) if err != nil { @@ -460,7 +458,6 @@ func (v *StatelessBlockValidator) CreateReadyValidationEntry(ctx context.Context if err != nil { return nil, err } - fmt.Printf("Building validation run: start %+v, end %+v, pos %d...start pos %d end pos %d\n", start, end, pos, startPos, endPos) entry, err := newValidationEntry(pos, start, end, msg, seqMsg, prevDelayed) if err != nil { return nil, err diff --git a/tools/bold-challenges/main.go b/tools/bold-challenges/main.go new file mode 100644 index 0000000000..9049b83f44 --- /dev/null +++ b/tools/bold-challenges/main.go @@ -0,0 +1,60 @@ +package main + +import ( + "math/big" + + solimpl "github.com/OffchainLabs/bold/chain-abstraction/sol-implementation" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/crypto" +) + +func main() { + validatorPrivateKey, err := crypto.HexToECDSA("182fecf15bdf909556a0f617a63e05ab22f1493d25a9f1e27c228266c772a890") + if err != nil { + panic(err) + } + validatorTxOpts, err := bind.NewKeyedTransactorWithChainID(validatorPrivateKey, l1ChainId) + if err != nil { + panic(err) + } + mintTokens, ok := new(big.Int).SetString("10000", 10) + if !ok { + panic("could not set stake token value") + } + l1TransactionOpts.Value = mintTokens + tx, err = tokenBindings.Deposit(l1TransactionOpts) + if err != nil { + panic(err) + } + + // We then have the validator itself authorize the rollup and challenge manager + // contracts to spend its stake tokens. + chain, err := solimpl.NewAssertionChain( + ctx, + deployedAddresses.Rollup, + validatorTxOpts, + l1Reader.Client(), + ) + if err != nil { + panic(err) + } + chalManager, err := chain.SpecChallengeManager(ctx) + if err != nil { + panic(err) + } + amountToApproveSpend, ok := new(big.Int).SetString("10000", 10) + if !ok { + panic("not ok") + } + tx, err = tokenBindings.TestWETH9Transactor.Approve(validatorTxOpts, deployedAddresses.Rollup, amountToApproveSpend) + if err != nil { + panic(err) + } + ensureTxSucceeds(tx) + tx, err = tokenBindings.TestWETH9Transactor.Approve(validatorTxOpts, chalManager.Address(), amountToApproveSpend) + if err != nil { + panic(err) + } + ensureTxSucceeds(tx) + +}