bitcoin core development – Get node 1 to mine another block, send it to node 2, and check that node 2 received it

I am trying to write a test with the bitcoin/test/functional/example_test.py to get node 1 to mine another block, send it to node 2, and check that node 2 received it. Any idea on how to go about/get started on this? I am familiar with python but this is fairly new to me.

Thanks.

Selfish mining attack: Probability of block being mined – CS251 exam question

I am currently studying for the CS251 Cryptocurrencies and Blockchain Technologies exam. In a past exam, there is this question without an answer and I would really appreciate your help so that I can better understand it:

Recall that a selfish miner temporarily refrains from publishing mined blocks in an
effort to get several blocks ahead of other miners, thereby causing other miners to
waste effort mining orphan blocks. When a selfish miner is only one block S ahead of
the public chain, if another miner mines and publishes a block O at the same height as
S, the selfish miner immediately publishes S. Let γ be the probability that, when this
happens, an honest miner will try to mine the next block on S instead of on O.

A) How can an attacker ensure that γ ≈ 1 (in other words, S almost always overrides O) on today’s Bitcoin network?

Thank you very much in advance for your help!

How do I set up a views block that filters contextually on a field included in a paragraph?

I have two content types (ContentA, ContentB) which both use the same paragraph (MyParagraph) as field type “Entity reference revisions.”

MyParagraph consists of two “List (text)” fields: ParagraphFieldA, ParagraphFieldB.

The values for ParagraphFieldA and ParagraphFieldB come in both cases from allowed values lists which have a key and label.

ContentA is limited to one MyParagraph reference but ContentB can have multiple MyParagraph references.

I have been trying to set up a Views Block that will be shown with any ContentA node. I want it to list titles of all ContentB nodes that have the same ParagraphFieldA value as the ContentA node.

I have a Views Block with Fields: Content: Title; and Filter Criteria: Content: Content type (=ContentB).

It has relationships to Paragraph referenced from MyParagraph and Content using MyParagraph.

I have added a contextual filter to (MyParagraph: Paragraph) Paragraph: ParagraphFieldA with “Content ID from URL” selected under “Provide default value.” I expected this to filter on the ParagraphFieldA value from the displayed ContentA node, but no results are returned.

If I put a key value from ParagraphFieldA in the preview box, I get a list of the relevant ContentB titles, but the view is not getting this automatically from the URL.

I have searched high and low for a solution and have tried various permutations without success. Clearly I am making a basic mistake here but I can’t see what it is.

Can anyone help?

redirect – Nginx rewrite and return interfere with different location block

I have the following configuration in nginx for redirecting in a certain scenario.

location /prefix-someurl {
   if (condition) {
            return 301 $scheme://$host/xyz.html;
   }
   proxy_pass someValue;
}

and in another block there are some rewrite rules like this

location /someurl {
   if (condition) {
            rewrite ^(.*)abc(.*)$ $1test/abc$2 break;               
            rewrite ^(.*)someurl/$(.*) $1someurl/test/index.html$2;

   }
   proxy_pass value;
}

The above configuration works as intended. However if for the latter I make this modification;

location /someurl {
   if (condition) {
            return 301 $scheme://$host/xyz.html;
   }
   if (condition) {
            rewrite ^(.*)abc(.*)$ $1test/abc$2 break;               
            rewrite ^(.*)someurl/$(.*) $1someurl/test/index.html$2;

   }
   proxy_pass value;
}

I get too many redirect errors for accessing /prefix-someurl.If I modify the /someurl to the following the error goes away;

location /someurl {
  if (condition) {
        return 301 $scheme://$host/xyz.html;
  }    
  proxy_pass value;
}

I cannot understand why modifying /someurl has an impact on /prefix-someurl. Or am I missing something regarding nginx rewrite evaluation. Insight on this would be appreciated.

Find if widget block is active

I’m used to check if a widget from installed my plugin is active.

With the new block editor extending to widgets in WordPress 5.8, I was wondering if there is a way to check the widget block that I created (both old php-based and gutenberg-based widgets are installed by my plugin) is activated by the user.

Thanks!

WordPress post using block editor displays error when adding the string “cmd.exe”

Today a member of our content team reported that when they attempted to save a post in block editor mode, they continually received an error.

Updating failed. The response is not a valid JSON response.

After some debugging steps we determined that the string “cmd.exe” was to blame. When that string was present the author always got the above error. But when the string was gone or had a space after the “.”, the post saved and displayed just fine. I recreated it in a brand new post, with only the string “cmd.exe” and confirmed that I got the same error.

enter image description here

When viewing the post in the “code editor” view, this is the contents:

<!-- wp:paragraph -->
<p>cmd.exe</p>
<!-- /wp:paragraph -->

We’re currently running WP 5.7.2 on WP Engine.

Does anyone know why this might be happening? I understand it’s probably a security issue, but this seems quite the ham-fisted approach.

magento2 – Promotional content block on the cart which changes by customer segment

A merchant would like a promotional content block on the cart which changes by customer segment. the
content should only appear when you cart total is $50 or more excluding shipping

What solution will meet the requirement?

  1. Create a widget with a static block assign to a customer price rule.

2]Create a dynamic block and choose the customer segment

3]Create a static block and add it to the layout area for the shopping cart with the customer segment

4]Create a banner, apply the ‘customer segment to the banner and choose the banner price rule

block header – How strict are the unix epoch time validation rules?

I think you have a misconception about what this clause means:

Full nodes will not accept blocks with headers more than two hours in the future according to their clock.

You appear to be interpreting this as, if a new block is more than two hours later than the previous block, then do not accept it. That is incorrect. This clause is not about gaps in time between blocks.

The actual meaning of this clause is that, if a new block says it’s literally from the future, from a time that the universe has not yet reached, then do not accept it. This clause is about preventing manipulation of the blockchain via falsified timestamps.

This comparison is between the new block’s timestamp and your clock, not the new block’s timestamp and the previous block’s timestamp.

Block Controls not showing – WordPress Development Stack Exchange

I’m building my first Gutenberg block and the problem that I have is that the block control toolbar doesn’t show.
I’ve spend hours comparing my code with other Gutenberg blocks, but couldn’t find what is wrong in my code.
I would highly appreciate if someone could look at my code and advice.

Here is my code:

import { registerBlockType } from '@wordpress/blocks';
import { 
    RichText,
    InspectorControls,
    ColorPalette,
    MediaUpload
        } from '@wordpress/block-editor';
import { 
    PanelBody,
    IconButton } from '@wordpress/components';
 
registerBlockType( 'luxworx-blocks/author-block', {
    apiVersion: 2,
    title: 'Luxworx: Author Block',
    icon: 'universal-access-alt',
    category: 'design',
    example: {},
    attributes: {
        title: {
            type: 'string',
            source: 'html',
            selector: 'h2'
        },
        body: {
            type: 'string',
            source: 'html',
            selector: 'p'
        },
        textColor: {
            type: 'string',
            default: 'black'
        },
        bgColor: {
            type: 'string',
            default: 'white'
        },
        authorImage: {
            type: 'string',
            default: null
        }
    },

    edit( {attributes, setAttributes}) {

        // Custom functions
        function updateTitle (newTitle) {
            setAttributes( { title: newTitle}) 
        }
        function updateBody (newBody) {
            setAttributes( { body: newBody}) 
        }
        function onTextColorChange (newColor) {
            setAttributes( {textColor: newColor})
        }
        function onBgColorChange (newColor2) {
            setAttributes( {bgColor: newColor2})
        }
        function onSelectImage(newImage) {
            setAttributes( {authorImage: newImage.sizes.full.url })
        }
 
        return (
            <InspectorControls key="lx-authors-block-setting" style={ { marginBottom:'40px'} }>
                <PanelBody title={ 'Color setting' }>
                    <p><strong>Select text color:</strong></p>
                    <ColorPalette value={ attributes.textColor }
                                    onChange={ onTextColorChange } />
                    <p><strong>Select block bacground color:</strong></p>
                    <ColorPalette value={ attributes.bgColor }
                                    onChange={ onBgColorChange } />
                </PanelBody>
                <PanelBody title={ 'Author image'}>
                    <p><strong>Select author image:</strong></p>
                    <MediaUpload
                        onSelect={ onSelectImage }
                        type="image"
                        value={ attributes.authorImage }
                        render={ ( { open } ) => (
                            <IconButton
                                onClick={ open }
                                icon="upload"
                                className="editor-media-placeholder__button button is-default">
                                Author Image
                            </IconButton>
                        ) } />
                        
                </PanelBody>
            </InspectorControls>,
            <div className="lx-authors-block wp-block" key="container" style={{ backgroundColor: attributes.bgColor}}>
                <img src={ attributes.authorImage} className="lx-authors-image" />
                <div className="lx-author-info">
                    <RichText   
                                placeholder="Authors name"
                                tagName="h2"
                                value={attributes.title}
                                onChange={updateTitle}
                                style={ {color: attributes.textColor }} />
                    
                    <RichText  
                                placeholder="Authors bio"
                                tagName="p"
                                value={attributes.body}
                                onChange={updateBody}
                                style={ {color:attributes.textColor}} />
                </div>
            </div> 
        );
    },
    save( {attributes}) {
        
        return (
            <div className="lx-authors-block wp-block" style={{ backgroundColor: attributes.bgColor }}>
                <img src={ attributes.authorImage} className="lx-authors-image" />
                <div className="lx-author-info">
                    <h2 style={ { color: attributes.textColor }}>{attributes.title}</h2>
                    <RichText.Content tagName="p"
                                    value={attributes.body}
                                    style={ {color:attributes.textColor}}
                                    />
                </div>
            </div>
        );
    },
} );

How to block the IP that requests excessive 404 page not found

On my site often I see thousands of requests thats ends up 404 – page not found error.
How can I block the IP that exceeds more than certain number of requests within a span of time from drupal. Any help would be appreciated. Thanks

enter image description here