I am trying to understand how smart contracts interact with each other and the blockchain. So, let's say that I have a smart contract SC1 which asks a node A in my peer to peer network to send some information to another node B. When B receives the request it will run another smart contract SC2 to generate some data to publish on the blockchain. Now the two Smart Contracts depend on each other so does it mean they will always be mined in two different blocks?
2 Answers
Smart contracts don't interact with the blockchain, they are part of the blockchain. Smart contracts also can't connect to external services, they're in a world that we can see and interact with, even provide data to, but they can't touch the outside world. The best way to imagine it is that each smart contract is a program in the Ethereum Virtual Machine. Users send transactions to contracts on the EVM to call functions of these contracts, which can make these contracts talk to each other and exchange data.
let's say that I have a smart contract SC1 which asks a node A in my peer to peer network to send some information to another node B. It is impossible. Contract can only react on request to it. But let's suppose that contract sends some transaction.
When B receives the request it will run another smart contract SC2 to generate some data to publish on the blockchain.
yes, smart contract can request another contract. And another contract can change its state or send new transaction to some address. - That all is the "publishing on the blockchain"
Now the two Smart Contracts depend on each other so does it mean they will always be mined in two different blocks?
No. Each transaction is mined in its own block, which can be the same for two specific transactions (most likely for ones closest in time) or can not. The same block for two different transactions is not quaranteed.