diff --git a/.github/workflows/amoy_deb_profiles.yml b/.github/workflows/amoy_deb_profiles.yml index 80b73335cf..0031a1d5c4 100644 --- a/.github/workflows/amoy_deb_profiles.yml +++ b/.github/workflows/amoy_deb_profiles.yml @@ -384,7 +384,7 @@ jobs: uses: softprops/action-gh-release@v2 with: tag_name: ${{ env.GIT_TAG }} - prerelease: true + make_latest: false files: | packaging/deb/bor-amoy-**.deb packaging/deb/bor-pbss-amoy-**.deb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 292212e609..20cf328b1b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -110,7 +110,7 @@ jobs: - name: Test run: make test - - uses: actions/upload-artifact@v4.4.0 + - uses: PaloAltoNetworks/upload-secure-artifact@main with: name: unitTest-coverage path: cover.out @@ -161,7 +161,7 @@ jobs: - name: test-integration run: make test-integration - - uses: actions/upload-artifact@v4.4.0 + - uses: PaloAltoNetworks/upload-secure-artifact@main with: name: integrationTest-coverage path: cover.out @@ -275,13 +275,17 @@ jobs: echo "Starting RPC Tests..." timeout 5m bash bor/integration-tests/rpc_test.sh + - name: Resolve absolute path for logs + id: pathfix + run: | + echo "ABS_LOG_PATH=$(realpath matic-cli/devnet/logs)" >> $GITHUB_ENV + - name: Upload logs if: always() - uses: actions/upload-artifact@v4.4.0 + uses: PaloAltoNetworks/upload-secure-artifact@main with: name: logs_${{ github.run_id }} - path: | - matic-cli/devnet/logs + path: ${{ env.ABS_LOG_PATH }} - name: Package code and chain data if: always() @@ -292,11 +296,11 @@ jobs: mkdir -p ${{ github.run_id }}/matic-cli sudo mv bor ${{ github.run_id }} sudo mv matic-cli/devnet ${{ github.run_id }}/matic-cli - sudo tar czf code.tar.gz ${{ github.run_id }} + sudo tar --warning=no-file-changed --exclude='.git' -czf code.tar.gz ${{ github.run_id }} - name: Upload code and chain data if: always() - uses: actions/upload-artifact@v4.4.0 + uses: PaloAltoNetworks/upload-secure-artifact@main with: name: code_${{ github.run_id }} path: code.tar.gz diff --git a/.github/workflows/mainnet_deb_profiles.yml b/.github/workflows/mainnet_deb_profiles.yml index 893e5dce80..1edf37ee78 100644 --- a/.github/workflows/mainnet_deb_profiles.yml +++ b/.github/workflows/mainnet_deb_profiles.yml @@ -394,7 +394,7 @@ jobs: uses: softprops/action-gh-release@v2 with: tag_name: ${{ env.GIT_TAG }} - prerelease: true + make_latest: false files: | packaging/deb/bor-mainnet-**.deb packaging/deb/bor-pbss-mainnet-**.deb diff --git a/.github/workflows/packager_deb.yml b/.github/workflows/packager_deb.yml index 6d178e7293..fb733cd43b 100644 --- a/.github/workflows/packager_deb.yml +++ b/.github/workflows/packager_deb.yml @@ -122,7 +122,7 @@ jobs: uses: softprops/action-gh-release@v2 with: tag_name: ${{ env.GIT_TAG }} - prerelease: true + make_latest: false files: | packaging/deb/bor**.deb packaging/deb/bor**.deb.checksum diff --git a/accounts/usbwallet/ledger.go b/accounts/usbwallet/ledger.go index eb6c729594..f48008d3f4 100644 --- a/accounts/usbwallet/ledger.go +++ b/accounts/usbwallet/ledger.go @@ -531,6 +531,12 @@ func (w *ledgerDriver) ledgerSignTypedMessage(derivationPath []uint32, domainHas // APDU length | 1 byte // Optional APDU data | arbitrary func (w *ledgerDriver) ledgerExchange(opcode ledgerOpcode, p1 ledgerParam1, p2 ledgerParam2, data []byte) ([]byte, error) { + // max safe length check + const maxDataLength = 128 * 1024 * 1024 // 128 MB + if len(data) > maxDataLength { + return nil, errors.New("data too large") + } + // Construct the message payload, possibly split into multiple chunks apdu := make([]byte, 2, 7+len(data)) diff --git a/core/blockchain.go b/core/blockchain.go index 74c58eda1b..4cd6feb3d8 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -586,7 +586,7 @@ func NewParallelBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis return bc, nil } -func (bc *BlockChain) ProcessBlock(block *types.Block, parent *types.Header) (_ types.Receipts, _ []*types.Log, _ uint64, _ *state.StateDB, vtime time.Duration, blockEndErr error) { +func (bc *BlockChain) ProcessBlock(block *types.Block, parent *types.Header, witness *stateless.Witness) (_ types.Receipts, _ []*types.Log, _ uint64, _ *state.StateDB, vtime time.Duration, blockEndErr error) { // Process the block using processor and parallelProcessor at the same time, take the one which finishes first, cancel the other, and return the result ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -631,14 +631,11 @@ func (bc *BlockChain) ProcessBlock(block *types.Block, parent *types.Header) (_ if err != nil { return nil, nil, 0, nil, 0, err } - // TODO(manav): confirm if not setting logger here affects block-stm or not as it's removed - // from upstream - // parallelStatedb.SetLogger(bc.logger) processorCount++ go func() { - parallelStatedb.StartPrefetcher("chain", nil) + parallelStatedb.StartPrefetcher("chain", witness) pstart := time.Now() res, err := bc.parallelProcessor.Process(block, parallelStatedb, bc.vmConfig, ctx) blockExecutionParallelTimer.UpdateSince(pstart) @@ -663,7 +660,7 @@ func (bc *BlockChain) ProcessBlock(block *types.Block, parent *types.Header) (_ processorCount++ go func() { - statedb.StartPrefetcher("chain", nil) + statedb.StartPrefetcher("chain", witness) pstart := time.Now() res, err := bc.processor.Process(block, statedb, bc.vmConfig, ctx) blockExecutionSerialTimer.UpdateSince(pstart) @@ -2355,7 +2352,10 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool, makeWitness return nil, it.index, err } } - statedb.StartPrefetcher("chain", witness) + // Bor: We start the prefetcher in process block function called below + // and not here as we copy state for block-stm in that function. Also, + // we don't want to start duplicate prefetchers per block. + // statedb.StartPrefetcher("chain", witness) } activeState = statedb @@ -2384,7 +2384,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool, makeWitness // Process block using the parent state as reference point pstart := time.Now() - receipts, logs, usedGas, statedb, vtime, err := bc.ProcessBlock(block, parent) + receipts, logs, usedGas, statedb, vtime, err := bc.ProcessBlock(block, parent, witness) activeState = statedb if err != nil { diff --git a/core/blockchain_test.go b/core/blockchain_test.go index 51efbd6258..6971ad1987 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -174,7 +174,7 @@ func testBlockChainImport(chain types.Blocks, blockchain *BlockChain) error { if err != nil { return err } - receipts, logs, usedGas, statedb, _, err := blockchain.ProcessBlock(block, blockchain.GetBlockByHash(block.ParentHash()).Header()) + receipts, logs, usedGas, statedb, _, err := blockchain.ProcessBlock(block, blockchain.GetBlockByHash(block.ParentHash()).Header(), nil) res := &ProcessResult{ Receipts: receipts, Logs: logs, diff --git a/core/chain_makers.go b/core/chain_makers.go index 0fe2467fb7..fbe8af3feb 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -507,11 +507,12 @@ func GenerateVerkleChain(config *params.ChainConfig, parent *types.Block, engine // Save pre state for proof generation // preState := statedb.Copy() - // EIP-2935 / 7709 - blockContext := NewEVMBlockContext(b.header, cm, &b.header.Coinbase) - blockContext.Random = &common.Hash{} // enable post-merge instruction set - evm := vm.NewEVM(blockContext, statedb, cm.config, vm.Config{}) - ProcessParentBlockHash(b.header.ParentHash, evm) + if config.Bor == nil { // EIP-2935 / 7709 + blockContext := NewEVMBlockContext(b.header, cm, &b.header.Coinbase) + blockContext.Random = &common.Hash{} // enable post-merge instruction set + evm := vm.NewEVM(blockContext, statedb, cm.config, vm.Config{}) + ProcessParentBlockHash(b.header.ParentHash, evm) + } // Execute any user modifications to the block. if gen != nil { diff --git a/core/genesis.go b/core/genesis.go index 209c6a5c70..bdb0da17d0 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -539,7 +539,7 @@ func (g *Genesis) toBlockWithRoot(root common.Hash) *types.Block { head.BlobGasUsed = new(uint64) } } - if conf.IsPrague(num) { + if conf.IsPrague(num) && conf.Bor == nil { head.RequestsHash = &types.EmptyRequestsHash } } diff --git a/core/state/statedb.go b/core/state/statedb.go index d14958022d..a9ee5ddb7a 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -796,7 +796,6 @@ func (s *StateDB) SubBalance(addr common.Address, amount *uint256.Int, reason tr s.GetBalance(addr) } - // TODO(manav): Confirm if we need to record if amount is zero stateObject = s.mvRecordWritten(stateObject) MVWrite(s, blockstm.NewSubpathKey(addr, BalancePath)) diff --git a/core/state_processor.go b/core/state_processor.go index 7846b8bdd5..8890ca8d4b 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -89,7 +89,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg if beaconRoot := block.BeaconRoot(); beaconRoot != nil { ProcessBeaconBlockRoot(*beaconRoot, evm) } - if p.config.IsPrague(block.Number()) || p.config.IsVerkle(block.Number()) { + if (p.config.IsPrague(block.Number()) || p.config.IsVerkle(block.Number())) && p.config.Bor == nil { ProcessParentBlockHash(block.ParentHash(), evm) } diff --git a/core/types/block.go b/core/types/block.go index 27ec6d26fb..f5db54413c 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -221,7 +221,7 @@ func (h *Header) ValidateBlockNumberOptionsPIP15(minBlockNumber *big.Int, maxBlo return nil } -// ValidateBlockNumberOptionsPIP15 validates the timestamp range passed as in the options parameter in the conditional transaction (PIP-15) +// ValidateTimestampOptionsPIP15 validates the timestamp range passed as in the options parameter in the conditional transaction (PIP-15) func (h *Header) ValidateTimestampOptionsPIP15(minTimestamp *uint64, maxTimestamp *uint64) error { currentBlockTime := h.Time diff --git a/trie/encoding.go b/trie/encoding.go index 8f8440c8f0..c4a904fc0b 100644 --- a/trie/encoding.go +++ b/trie/encoding.go @@ -16,6 +16,8 @@ package trie +import "math" + // Trie keys are dealt with in three distinct encodings: // // KEYBYTES encoding contains the actual key and nothing else. This encoding is the @@ -104,6 +106,9 @@ func compactToHex(compact []byte) []byte { } func keybytesToHex(str []byte) []byte { + if len(str) > math.MaxInt/2 { + panic("input too large") + } l := len(str)*2 + 1 var nibbles = make([]byte, l)