Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gethpin v1.14.0 #2517

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6acb87a
Merge v1.13.14
amsanghi Jul 16, 2024
826b230
Merge v1.13.15
amsanghi Jul 16, 2024
b042b2a
Merge v1.14.0
amsanghi Jul 18, 2024
5dc1096
fix ci
amsanghi Jul 18, 2024
cedf55b
Fix
amsanghi Jul 18, 2024
ac6e0e7
update submodule
amsanghi Jul 22, 2024
6f0f050
Merge branch 'update-gethpin-v1.13.15' into update-gethpin-v1.14.0
amsanghi Jul 22, 2024
647e7b9
Merge branch 'master' into update-gethpin-v1.14.0
amsanghi Jul 23, 2024
3530a8d
Merge branch 'master' into update-gethpin-v1.14.0
amsanghi Jul 24, 2024
89c65f8
update submodule
amsanghi Jul 24, 2024
1ca29cf
fix build
amsanghi Jul 25, 2024
e5be704
update geth
amsanghi Jul 29, 2024
fc347f6
Merge branch 'master' into update-gethpin-v1.14.0
amsanghi Jul 29, 2024
203e767
fix lint
amsanghi Jul 29, 2024
be0a4bb
update geth
amsanghi Jul 29, 2024
ab6b652
update geth
amsanghi Jul 31, 2024
9f33596
Merge branch 'master' into update-gethpin-v1.14.0
amsanghi Jul 31, 2024
d9739f2
fix batch poster
amsanghi Jul 31, 2024
bc4b876
update geth
amsanghi Jul 31, 2024
16a11ea
update geth
amsanghi Jul 31, 2024
2456012
fix null reference
amsanghi Jul 31, 2024
f824474
Merge branch 'master' into update-gethpin-v1.14.0
amsanghi Jul 31, 2024
15834ae
fix test
amsanghi Aug 1, 2024
619c621
Merge branch 'master' into update-gethpin-v1.14.0
amsanghi Aug 1, 2024
c6ad8fa
fix test
amsanghi Aug 1, 2024
49d28d8
update geth
amsanghi Aug 5, 2024
ff9d4ad
Merge branch 'master' into update-gethpin-v1.14.0
amsanghi Aug 5, 2024
707b0d3
Merge branch 'master' into update-gethpin-v1.14.0
amsanghi Aug 21, 2024
04413ab
minor fix
amsanghi Aug 22, 2024
282d73c
Changes based on PR comments
amsanghi Aug 22, 2024
605a137
Changes based on PR comments
amsanghi Aug 22, 2024
1b410ab
Merge branch 'master' into update-gethpin-v1.14.0
amsanghi Aug 22, 2024
c2a069e
Merge branch 'master' into update-gethpin-v1.14.0
amsanghi Sep 3, 2024
b553f8c
update submodule
amsanghi Sep 3, 2024
48a5016
update submodule
amsanghi Sep 3, 2024
236884f
fix stylus build
amsanghi Sep 3, 2024
4132a49
Merge branch 'master' into update-gethpin-v1.14.0
amsanghi Sep 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arbnode/batch_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error)
}
var use4844 bool
config := b.config()
if config.Post4844Blobs && b.dapWriter == nil && latestHeader.ExcessBlobGas != nil && latestHeader.BlobGasUsed != nil {
if config.Post4844Blobs && b.dapWriter == nil && latestHeader.ExcessBlobGas != nil && *latestHeader.ExcessBlobGas != 0 && latestHeader.BlobGasUsed != nil && *latestHeader.BlobGasUsed != 0 {
arbOSVersion, err := b.arbOSVersionGetter.ArbOSVersionForMessageNumber(arbutil.MessageIndex(arbmath.SaturatingUSub(uint64(batchPosition.MessageCount), 1)))
if err != nil {
return false, err
Expand Down
5 changes: 3 additions & 2 deletions arbos/arbosState/initialization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ func tryMarshalUnmarshal(input *statetransfer.ArbosInitializationInfo, t *testin
cacheConfig := core.DefaultCacheConfigWithScheme(env.GetTestStateScheme())
stateroot, err := InitializeArbosInDatabase(raw, cacheConfig, initReader, chainConfig, arbostypes.TestInitMessage, 0, 0)
Require(t, err)

triedbConfig := cacheConfig.TriedbConfig()
number, err := initReader.GetNextBlockNumber()
Require(t, err)
triedbConfig := cacheConfig.TriedbConfig(chainConfig.IsVerkle(new(big.Int).SetUint64(number), 0))
stateDb, err := state.New(stateroot, state.NewDatabaseWithConfig(raw, triedbConfig), nil)
Require(t, err)

Expand Down
13 changes: 9 additions & 4 deletions arbos/arbosState/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package arbosState

import (
"errors"
"github.com/ethereum/go-ethereum/core/tracing"
"math/big"
"regexp"
"sort"
Expand Down Expand Up @@ -55,7 +56,11 @@ func MakeGenesisBlock(parentHash common.Hash, blockNumber uint64, timestamp uint
}

func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, timestamp uint64, accountsPerSync uint) (root common.Hash, err error) {
triedbConfig := cacheConfig.TriedbConfig()
number, err := initData.GetNextBlockNumber()
if err != nil {
return common.Hash{}, err
}
triedbConfig := cacheConfig.TriedbConfig(chainConfig.IsVerkle(new(big.Int).SetUint64(number), timestamp))
triedbConfig.Preimages = false
stateDatabase := state.NewDatabaseWithConfig(db, triedbConfig)
defer func() {
Expand Down Expand Up @@ -159,7 +164,7 @@ func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig,
if err != nil {
return common.Hash{}, err
}
statedb.SetBalance(account.Addr, uint256.MustFromBig(account.EthBalance))
statedb.SetBalance(account.Addr, uint256.MustFromBig(account.EthBalance), tracing.BalanceChangeUnspecified)
statedb.SetNonce(account.Addr, account.Nonce)
if account.ContractInfo != nil {
statedb.SetCode(account.Addr, account.ContractInfo.Code)
Expand Down Expand Up @@ -190,7 +195,7 @@ func initializeRetryables(statedb *state.StateDB, rs *retryables.RetryableState,
return err
}
if r.Timeout <= currentTimestamp {
statedb.AddBalance(r.Beneficiary, uint256.MustFromBig(r.Callvalue))
statedb.AddBalance(r.Beneficiary, uint256.MustFromBig(r.Callvalue), tracing.BalanceChangeUnspecified)
continue
}
retryablesList = append(retryablesList, r)
Expand All @@ -209,7 +214,7 @@ func initializeRetryables(statedb *state.StateDB, rs *retryables.RetryableState,
addr := r.To
to = &addr
}
statedb.AddBalance(retryables.RetryableEscrowAddress(r.Id), uint256.MustFromBig(r.Callvalue))
statedb.AddBalance(retryables.RetryableEscrowAddress(r.Id), uint256.MustFromBig(r.Callvalue), tracing.BalanceChangeUnspecified)
_, err := rs.CreateRetryable(r.Id, r.Timeout, r.From, to, r.Callvalue, r.Beneficiary, r.Calldata)
if err != nil {
return err
Expand Down
11 changes: 5 additions & 6 deletions arbos/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,15 @@ func (e Engine) Prepare(chain consensus.ChainHeaderReader, header *types.Header)
return nil
}

func (e Engine) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, withdrawals []*types.Withdrawal) {
FinalizeBlock(header, txs, state, chain.Config())
func (e Engine) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body) {
FinalizeBlock(header, body.Transactions, state, chain.Config())
}

func (e Engine) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction,
uncles []*types.Header, receipts []*types.Receipt, withdrawals []*types.Withdrawal) (*types.Block, error) {
func (e Engine) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body, receipts []*types.Receipt) (*types.Block, error) {

e.Finalize(chain, header, state, txs, uncles, withdrawals)
e.Finalize(chain, header, state, body)

block := types.NewBlock(header, txs, nil, receipts, trie.NewStackTrie(nil))
block := types.NewBlock(header, body.Transactions, nil, receipts, trie.NewStackTrie(nil))
return block, nil
}

Expand Down
3 changes: 2 additions & 1 deletion arbos/l1pricing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package arbos

import (
"github.com/ethereum/go-ethereum/core/tracing"
"math/big"
"testing"

Expand Down Expand Up @@ -172,7 +173,7 @@ func _testL1PricingFundsDue(t *testing.T, testParams *l1PricingTest, expectedRes
// create some fake collection
balanceAdded := new(big.Int).SetUint64(testParams.fundsCollectedPerSecond * 3)
unitsAdded := testParams.unitsPerSecond * 3
evm.StateDB.AddBalance(l1pricing.L1PricerFundsPoolAddress, uint256.MustFromBig(balanceAdded))
evm.StateDB.AddBalance(l1pricing.L1PricerFundsPoolAddress, uint256.MustFromBig(balanceAdded), tracing.BalanceChangeUnspecified)
err = l1p.SetL1FeesAvailable(balanceAdded)
Require(t, err)
err = l1p.SetUnitsSinceUpdate(unitsAdded)
Expand Down
8 changes: 6 additions & 2 deletions arbos/tx_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,17 @@ func (p *TxProcessor) StartTxHook() (endTxNow bool, gasUsed uint64, err error, r
}
evm.IncrementDepth() // fake a call
from := p.msg.From
tracer.CaptureStart(evm, from, *p.msg.To, false, p.msg.Data, p.msg.GasLimit, p.msg.Value)
if tracer.OnEnter != nil {
tracer.OnEnter(evm.Depth(), byte(vm.CALL), from, *p.msg.To, 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)

return func() {
tracer.CaptureEnd(nil, p.state.Burner.Burned(), nil)
if tracer.OnExit != nil {
tracer.OnExit(evm.Depth(), nil, p.state.Burner.Burned(), nil, false)
}
evm.DecrementDepth() // fake the return to the first faked call

tracingInfo = util.NewTracingInfo(evm, from, *p.msg.To, util.TracingAfterEVM)
Expand Down
35 changes: 26 additions & 9 deletions arbos/util/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/tracing"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/log"
"github.com/holiman/uint256"
Expand All @@ -22,7 +23,7 @@ const (
)

type TracingInfo struct {
Tracer vm.EVMLogger
Tracer *tracing.Hooks
Scenario TracingScenario
Contract *vm.Contract
Depth int
Expand Down Expand Up @@ -59,7 +60,9 @@ func (info *TracingInfo) RecordStorageGet(key common.Hash) {
Stack: TracingStackFromArgs(HashToUint256(key)),
Contract: info.Contract,
}
tracer.CaptureState(0, vm.SLOAD, 0, 0, scope, []byte{}, info.Depth, nil)
if tracer.OnOpcode != nil {
tracer.OnOpcode(0, byte(vm.SLOAD), 0, 0, scope, []byte{}, info.Depth, nil)
}
} else {
tracer.CaptureArbitrumStorageGet(key, info.Depth, info.Scenario == TracingBeforeEVM)
}
Expand All @@ -73,7 +76,9 @@ func (info *TracingInfo) RecordStorageSet(key, value common.Hash) {
Stack: TracingStackFromArgs(HashToUint256(key), HashToUint256(value)),
Contract: info.Contract,
}
tracer.CaptureState(0, vm.SSTORE, 0, 0, scope, []byte{}, info.Depth, nil)
if tracer.OnOpcode != nil {
tracer.OnOpcode(0, byte(vm.SSTORE), 0, 0, scope, []byte{}, info.Depth, nil)
}
} else {
tracer.CaptureArbitrumStorageSet(key, value, info.Depth, info.Scenario == TracingBeforeEVM)
}
Expand All @@ -98,8 +103,12 @@ func (info *TracingInfo) MockCall(input []byte, gas uint64, from, to common.Addr
),
Contract: contract,
}
tracer.CaptureState(0, vm.CALL, 0, 0, scope, []byte{}, depth, nil)
tracer.CaptureEnter(vm.INVALID, from, to, input, 0, amount)
if tracer.OnOpcode != nil {
tracer.OnOpcode(0, byte(vm.CALL), 0, 0, scope, []byte{}, depth, nil)
}
if tracer.OnEnter != nil {
tracer.OnEnter(depth, byte(vm.CALL), from, to, input, gas, amount)
}

retScope := &vm.ScopeContext{
Memory: vm.NewMemory(),
Expand All @@ -109,8 +118,12 @@ func (info *TracingInfo) MockCall(input []byte, gas uint64, from, to common.Addr
),
Contract: contract,
}
tracer.CaptureState(0, vm.RETURN, 0, 0, retScope, []byte{}, depth+1, nil)
tracer.CaptureExit(nil, 0, nil)
if tracer.OnOpcode != nil {
tracer.OnOpcode(0, byte(vm.RETURN), 0, 0, retScope, []byte{}, depth+1, nil)
}
if tracer.OnExit != nil {
tracer.OnExit(depth+1, nil, 0, nil, false)
}

popScope := &vm.ScopeContext{
Memory: vm.NewMemory(),
Expand All @@ -119,7 +132,9 @@ func (info *TracingInfo) MockCall(input []byte, gas uint64, from, to common.Addr
),
Contract: contract,
}
tracer.CaptureState(0, vm.POP, 0, 0, popScope, []byte{}, depth, nil)
if tracer.OnOpcode != nil {
tracer.OnOpcode(0, byte(vm.POP), 0, 0, popScope, []byte{}, depth, nil)
}
}

func (info *TracingInfo) CaptureEVMTraceForHostio(name string, args, outs []byte, startInk, endInk uint64) {
Expand Down Expand Up @@ -533,7 +548,9 @@ func (info *TracingInfo) captureState(op vm.OpCode, gas uint64, cost uint64, mem
Stack: TracingStackFromArgs(stack...),
Contract: info.Contract,
}
info.Tracer.CaptureState(0, op, gas, cost, scope, []byte{}, info.Depth, nil)
if info.Tracer.OnOpcode != nil {
info.Tracer.OnOpcode(0, byte(op), gas, cost, scope, []byte{}, info.Depth, nil)
}
}

func lenToBytes(data []byte) []byte {
Expand Down
58 changes: 30 additions & 28 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/tracing"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/log"
"github.com/holiman/uint256"
Expand All @@ -28,20 +29,6 @@ func TransferBalance(
if amount.Sign() < 0 {
panic(fmt.Sprintf("Tried to transfer negative amount %v from %v to %v", amount, from, to))
}
if from != nil {
balance := evm.StateDB.GetBalance(*from)
if arbmath.BigLessThan(balance.ToBig(), amount) {
return fmt.Errorf("%w: addr %v have %v want %v", vm.ErrInsufficientBalance, *from, balance, amount)
}
evm.StateDB.SubBalance(*from, uint256.MustFromBig(amount))
if evm.Context.ArbOSVersion >= 30 {
// ensure the from account is "touched" for EIP-161
evm.StateDB.AddBalance(*from, &uint256.Int{})
}
}
if to != nil {
evm.StateDB.AddBalance(*to, uint256.MustFromBig(amount))
}
if tracer := evm.Config.Tracer; tracer != nil {
if evm.Depth() != 0 && scenario != TracingDuringEVM {
// A non-zero depth implies this transfer is occurring inside EVM execution
Expand All @@ -50,24 +37,39 @@ func TransferBalance(
}

if scenario != TracingDuringEVM {
tracer.CaptureArbitrumTransfer(evm, from, to, amount, scenario == TracingBeforeEVM, purpose)
return nil
}
tracer.CaptureArbitrumTransfer(from, to, amount, scenario == TracingBeforeEVM, purpose)
} else {
fromCopy := from
toCopy := to
if fromCopy == nil {
fromCopy = &common.Address{}
}
if toCopy == nil {
toCopy = &common.Address{}
}

if from == nil {
from = &common.Address{}
info := &TracingInfo{
Tracer: evm.Config.Tracer,
Scenario: scenario,
Contract: vm.NewContract(addressHolder{*toCopy}, addressHolder{*fromCopy}, uint256.NewInt(0), 0),
Depth: evm.Depth(),
}
info.MockCall([]byte{}, 0, *fromCopy, *toCopy, amount)
}
if to == nil {
to = &common.Address{}
}
if from != nil {
balance := evm.StateDB.GetBalance(*from)
if arbmath.BigLessThan(balance.ToBig(), amount) {
return fmt.Errorf("%w: addr %v have %v want %v", vm.ErrInsufficientBalance, *from, balance, amount)
}

info := &TracingInfo{
Tracer: evm.Config.Tracer,
Scenario: scenario,
Contract: vm.NewContract(addressHolder{*to}, addressHolder{*from}, uint256.NewInt(0), 0),
Depth: evm.Depth(),
evm.StateDB.SubBalance(*from, uint256.MustFromBig(amount), tracing.BalanceChangeTransfer)
if evm.Context.ArbOSVersion >= 30 {
// ensure the from account is "touched" for EIP-161
evm.StateDB.AddBalance(*from, &uint256.Int{}, tracing.BalanceChangeTransfer)
}
info.MockCall([]byte{}, 0, *from, *to, amount)
}
if to != nil {
evm.StateDB.AddBalance(*to, uint256.MustFromBig(amount), tracing.BalanceChangeTransfer)
}
return nil
}
Expand Down
22 changes: 10 additions & 12 deletions blsSignatures/blsSignatures.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,22 @@ import (
cryptorand "crypto/rand"
"encoding/base64"
"errors"
"math/big"

"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto/bls12381"
bls12381 "github.com/kilic/bls12-381"
)

type PublicKey struct {
key *bls12381.PointG2
validityProof *bls12381.PointG1 // if this is nil, key came from a trusted source
}

type PrivateKey *big.Int
type PrivateKey *bls12381.Fr

type Signature *bls12381.PointG1

func GeneratePrivKeyString() (string, error) {
g2 := bls12381.NewG2()
privKey, err := cryptorand.Int(cryptorand.Reader, g2.Q())
fr := bls12381.NewFr()
privKey, err := fr.Rand(cryptorand.Reader)
if err != nil {
return "", err
}
Expand All @@ -35,8 +33,8 @@ func GeneratePrivKeyString() (string, error) {
}

func GenerateKeys() (PublicKey, PrivateKey, error) {
g2 := bls12381.NewG2()
privateKey, err := cryptorand.Int(cryptorand.Reader, g2.Q())
fr := bls12381.NewFr()
privateKey, err := fr.Rand(cryptorand.Reader)
if err != nil {
return PublicKey{}, nil, err
}
Expand Down Expand Up @@ -120,7 +118,7 @@ func verifySignature2(sig Signature, message []byte, publicKey PublicKey, keyVal
return false, err
}

engine := bls12381.NewPairingEngine()
engine := bls12381.NewEngine()
engine.Reset()
engine.AddPair(pointOnCurve, publicKey.key)
leftSide := engine.Result()
Expand Down Expand Up @@ -156,7 +154,7 @@ func VerifyAggregatedSignatureDifferentMessages(sig Signature, messages [][]byte
if len(messages) != len(pubKeys) {
return false, errors.New("len(messages) does not match (len(pub keys) in verification")
}
engine := bls12381.NewPairingEngine()
engine := bls12381.NewEngine()
engine.Reset()
for i, msg := range messages {
pointOnCurve, err := hashToG1Curve(msg, false)
Expand Down Expand Up @@ -242,11 +240,11 @@ func PublicKeyFromBytes(in []byte, trustedSource bool) (PublicKey, error) {
}

func PrivateKeyToBytes(priv PrivateKey) []byte {
return ((*big.Int)(priv)).Bytes()
return bls12381.NewFr().Set(priv).ToBytes()
}

func PrivateKeyFromBytes(in []byte) (PrivateKey, error) {
return new(big.Int).SetBytes(in), nil
return bls12381.NewFr().FromBytes(in), nil
}

func SignatureToBytes(sig Signature) []byte {
Expand Down
2 changes: 1 addition & 1 deletion cmd/genericconf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ package genericconf
import (
"errors"
"io"
"log/slog"
"time"

"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
flag "github.com/spf13/pflag"
"golang.org/x/exp/slog"
)

type ConfConfig struct {
Expand Down
Loading
Loading